⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1t.lst

📁 Embedded camera control program.
💻 LST
📖 第 1 页 / 共 5 页
字号:
0661:  DECFSZ 77,F
0662:  GOTO   658
0663:  BTFSS  21.7
0664:  GOTO   66A
0665:  COMF   78,F
0666:  COMF   79,F
0667:  INCF   78,F
0668:  BTFSC  03.2
0669:  INCF   79,F
066A:  NOP
066B:  BCF    03.5
066C:  RETLW  00
.................... #include <16f877.h> 
....................  //////// Standard Header file for the PIC16F877 device ////////////////  
.................... //#device PIC16F877  
.................... #list  
....................  
.................... #include <math.h> 
....................  ////////////////////////////////////////////////////////////////////////////  
.................... ////        (C) Copyright 1996,2003 Custom Computer Services            ////  
.................... //// This source code may only be used by licensed users of the CCS C   ////  
.................... //// compiler.  This source code may only be distributed to other       ////  
.................... //// licensed users of the CCS C compiler.  No other use, reproduction  ////  
.................... //// or distribution is permitted without written permission.           ////  
.................... //// Derivative programs created using this software in object code     ////  
.................... //// form are not restricted in any way.                                ////  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... ////                                                                    ////  
.................... //// History:                                                           ////  
.................... ////  * 9/20/2001 :  Improvments are made to sin/cos code.              ////  
.................... ////                 The code now is small, much faster,                ////  
.................... ////                 and more accurate.                                 ////  
.................... ////                                                                    ////  
.................... ////////////////////////////////////////////////////////////////////////////  
....................   
.................... #ifndef MATH_H  
.................... #define MATH_H  
....................   
....................   
.................... #undef  PI  
.................... #define PI     3.141592654  
....................   
....................   
.................... #define SQRT2  1.41421356  
....................   
.................... //float const ps[4] = {5.9304945, 21.125224, 8.9403076, 0.29730279};  
.................... //float const qs[4] = {1.0000000, 15.035723, 17.764134, 2.4934718};  
....................   
.................... ///////////////////////////// Round Functions //////////////////////////////  
....................   
.................... float CEIL_FLOOR(float x, int n)  
.................... {  
....................    float y, res;  
....................    long l;  
....................    int1 s;  
....................   
....................    s = 0;  
....................    y = x;  
....................   
....................    if (x < 0)  
....................    {  
....................       s = 1;  
....................       y = -y;  
....................    }  
....................   
....................    if (y <= 32768.0)  
....................   res = (float)(long)y;  
....................   
....................  else if (y < 10000000.0)  
....................    {  
....................   l = (long)(y/32768.0);  
....................       y = 32768.0*(y/32768.0 - (float)l);  
....................   res = 32768.0*(float)l;  
....................   res += (float)(long)y;  
....................  }  
....................   
....................  else  
....................   res = y;  
....................   
....................  y = y - (float)(long)y;  
....................   
....................  if (s)  
....................   res = -res;  
....................   
....................  if (y != 0)  
....................  {  
....................   if (s == 1 && n == 0)  
....................    res -= 1.0;  
....................   
....................   if (s == 0 && n == 1)  
....................    res += 1.0;  
....................  }  
....................  if (x == 0)  
....................     res = 0;  
....................   
....................  return (res);  
.................... }  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float floor(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : rounds down the number x.  
.................... // Date : N/A  
.................... //  
.................... float floor(float x)  
.................... {  
....................    return CEIL_FLOOR(x, 0);  
.................... }  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float ceil(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : rounds up the number x.  
.................... // Date : N/A  
.................... //  
.................... float ceil(float x)  
.................... {  
....................    return CEIL_FLOOR(x, 1);  
.................... }  
....................   
....................  ////////////////////////////////////////////////////////////////////////////  
.................... //	float fabs(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : Computes the absolute value of floating point number x  
.................... // Returns : returns the absolute value of x  
.................... // Date : N/A  
.................... //  
.................... #define fabs abs  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float fmod(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : Computes the floating point remainder of x/y  
.................... // Returns : returns the value of x= i*y, for some integer i such that, if y  
.................... // is non zero, the result has the same isgn of x na dmagnitude less than the  
.................... // magnitude of y. If y is zero then a domain error occurs.  
.................... // Date : N/A  
.................... //  
....................   
.................... float fmod(float x,float y)  
.................... {  
....................    float i;  
....................    if (y!=0.0)  
....................    {  
....................       i=(x/y < 0.0)?ceil(x/y): floor(x/y);  
....................       return(x-(i*y));  
....................    }  
....................    else  
....................    {  
....................    #ifdef _ERRNO  
....................    {  
....................       errno=EDOM;  
....................    }  
....................    #endif  
....................    }  
.................... }  
....................   
.................... //////////////////// Exponential and logarithmic functions ////////////////////  
....................   
.................... #define LN2 0.6931471806  
....................   
.................... float const pe[6] = {0.000207455774, 0.00127100575, 0.00965065093,  
....................                      0.0554965651,  0.240227138,  0.693147172};  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float exp(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the value (e^x)  
.................... // Date : N/A  
.................... //  
.................... float exp(float x)  
.................... {  
....................    float y, res, r;  
....................    signed int n;  
....................    int1 s;  
....................    #ifdef _ERRNO  
....................    if(x > 88.722838)  
....................    {  
....................       errno=ERANGE;  
....................       return(0);  
....................    }  
....................    #endif  
....................    n = (signed long)(x/LN2);  
....................    s = 0;  
....................    y = x;  
....................   
....................    if (x < 0)  
....................    {  
....................       s = 1;  
....................       n = -n;  
....................       y = -y;  
....................    }  
....................   
....................    res = 0.0;  
....................    *(&res) = n + 0x7F;  
....................   
....................    y = y/LN2 - (float)n;  
....................   
....................    r = pe[0]*y + pe[1];  
....................    r = r*y + pe[2];  
....................    r = r*y + pe[3];  
....................    r = r*y + pe[4];  
....................    r = r*y + pe[5];  
....................   
....................    res = res*(1.0 + y*r);  
....................   
....................    if (s)  
....................       res = 1.0/res;  
....................    return(res);  
.................... }  
....................   
.................... /************************************************************/  
....................   
.................... float const pl[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};  
.................... float const ql[4] = {1.0000000,  -8.1354259, 16.780517, -9.9300943};  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float log(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the the natural log of x  
.................... // Date : N/A  
.................... //  
.................... float log(float x)  
.................... {  
....................    float y, res, r, y2;  
....................    signed n;  
....................    #ifdef _ERRNO  
....................    if(x <0)  
....................    {  
....................       errno=EDOM;  
....................    }  
....................    if(x ==0)  
....................    {  
....................       errno=ERANGE;  
....................       return(0);  
....................    }  
....................    #endif  
....................    y = x;  
....................   
....................    if (y != 1.0)  
....................    {  
....................       *(&y) = 0x7E;  
....................   
....................       y = (y - 1.0)/(y + 1.0);  
....................   
....................       y2=y*y;  
....................   
....................       res = pl[0]*y2 + pl[1];  
....................       res = res*y2 + pl[2];  
....................       res = res*y2 + pl[3];  
....................   
....................       r = ql[0]*y2 + ql[1];  
....................       r = r*y2 + ql[2];  
....................       r = r*y2 + ql[3];  
....................   
....................       res = y*res/r;  
....................   
....................       n = *(&x) - 0x7E;  
....................   
....................       if (n<0)  
....................          r = -(float)-n;  
....................       else  
....................          r = (float)n;  
....................   
....................       res += r*LN2;  
....................    }  
....................   
....................    else  
....................       res = 0.0;  
....................   
....................    return(res);  
.................... }  
....................   
.................... #define LN10 2.30258509  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float log10(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the the log base 10 of x  
.................... // Date : N/A  
.................... //  
.................... float log10(float x)  
.................... {  
....................    float r;  
....................   
....................    r = log(x);  
....................    r = r/LN10;  
....................    return(r);  
.................... }  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float modf(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description :breaks the argument value int integral and fractional parts,  
.................... // ach of which have the same sign as the argument.  It stores the integral part  
.................... // as a float in the object pointed to by the iptr  
.................... // Returns : returns the signed fractional part of value.  
.................... // Date : N/A  
.................... //  
....................   
.................... float modf(float value,float *iptr)  
.................... {  
....................    *iptr=(value < 0.0)?ceil(value): floor(value);  
....................    return(value - *iptr);  
.................... }  
....................   
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float pwr(float x,float y)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the value (x^y)  
.................... // Date : N/A  
.................... //  
.................... float pwr(float x,float y)  
.................... {  
....................    if(x>=0)  
....................      return(  exp(y*log(x)) );  
....................    else  
....................      return(  -exp(y*log(-x)) );  
.................... }  
....................   
....................   
.................... //////////////////// Power functions ////////////////////  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float pow(float x,float y)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the value (x^y)  
.................... // Date : N/A  
.................... //  
.................... float pow(float x,float y)  
.................... {  
....................    if(x>=0)  
....................      return(  exp(y*log(x)) );  
....................    else  
....................      return(  -exp(y*log(-x)) );  
.................... }  
....................   
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float sqrt(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the square root of x  
.................... // Date : N/A  
.................... //  
.................... float sqrt(float x)  
.................... {  
....................    float y, res;  
....................    BYTE *p;  
....................   
....................    #ifdef _ERRNO  
....................    if(x < 0)  
....................    {  
....................       errno=EDOM;  
....................    }  
....................    #endif  
....................   
....................    if( x<=0.0)  
....................       return(0.0);  
....................   
....................    y=x;  
....................    p=&y;  
....................    (*p)=(BYTE)((((int16)(*p)) + 127) >> 1);  
....................   
....................    do {  
....................       res=y;  
....................       y+=(x/y);  
....................       (*p)--;  
....................    } while(res != y);  
....................   
....................    return(res);  
.................... }  
....................   
....................   
....................   
.................... ////////////////////////////// Trig Functions //////////////////////////////  
.................... #undef PI_DIV_BY_TWO  
.................... #define PI_DIV_BY_TWO	1.570796326794896  
.................... #undef TWOBYPI  
.................... #define TWOBYPI 			0.6366197724  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... //	float cos(float x)  
.................... ////////////////////////////////////////////////////////////////////////////  
.................... // Description : returns the cosine value of the angle x, which is in radian  
.................... // Date : 9/20/2001  
.................... //  
.................... float cos(float x)  
.................... {  
.................... 	float y, t, t2 = 1.0;  
*
0CBE:  MOVLW  7F
0CBF:  MOVWF  5A
0CC0:  CLRF   5B
0CC1:  CLRF   5C
0CC2:  CLRF   5D
.................... 	int quad, i;  
.................... 	float frac;  
.................... 	float p[4] = {  
.................... 		-0.499999993585,  
.................... 		 0.041666636258,  
.................... 		-0.0013888361399,  
.................... 		 0.00002476016134  
.................... 	};  
0CC3:  MOVLW  7E
0CC4:  MOVWF  64
0CC5:  MOVLW  80
0CC6:  MOVWF  65
0CC7:  CLRF   66
0CC8:  CLRF   67
0CC9:  MOVLW  7A
0CCA:  MOVWF  68
0CCB:  MOVLW  2A
0CCC:  MOVWF  69
0CCD:  MOVLW  AA
0CCE:  MOVWF  6A
0CCF:  MOVLW  A3
0CD0:  MOVWF  6B
0CD1:  MOVLW  75
0CD2:  MOVWF  6C
0CD3:  MOVLW  B6
0CD4:  MOVWF  6D
0CD5:  MOVLW  09
0CD6:  MOVWF  6E
0CD7:  MOVLW  9C
0CD8:  MOVWF  6F
0CD9:  MOVLW  6F
0CDA:  MOVWF  70
0CDB:  MOVLW  4F
0CDC:  MOVWF  71
0CDD:  MOVLW  B4
0CDE:  MOVWF  72
0CDF:  MOVLW  0B
0CE0:  MOVWF  73
....................   
.................... 	if (x < 0) x = -x;                  // absolute value of input  
0CE1:  MOVF   51,W
0CE2:  BSF    03.5
0CE3:  MOVWF  23
0CE4:  BCF    03.5
0CE5:  MOVF   50,W
0CE6:  BSF    03.5
0CE7:  MOVWF  22
0CE8:  BCF    03.5
0CE9:  MOVF   4F,W
0CEA:  BSF    03.5
0CEB:  MOVWF  21
0CEC:  BCF    03.5
0CED:  MOVF   4E,W
0CEE:  BSF    03.5
0CEF:  MOVWF  20
0CF0:  CLRF   27
0CF1:  CLRF   26
0CF2:  CLRF   25
0CF3:  CLRF   24
0CF4:  BCF    0A.3
0CF5:  BCF    03.5
0CF6:  CALL   60A
0CF7:  BSF    0A.3
0CF8:  BTFSS  03.0
0CF9:  GOTO   4FC
0CFA:  MOVLW  80
0CFB:  XORWF  4F,F
....................   
.................... 	quad = (int)(x / PI_DIV_BY_TWO);    // quadrant  
0CFC:  MOVF   51,W
0CFD:  BSF    03.5
0CFE:  MOVWF  23
0CFF:  BCF    03.5
0D00:  MOVF   50,W
0D01:  BSF    03.5
0D02:  MOVWF  22
0D03:  BCF    03.5
0D04:  MOVF   4F,W
0D05:  BSF    03.5
0D06:  MOVWF  21
0D07:  BCF    03.5
0D08:  MOVF   4E,W
0D09:  BSF    03.5
0D0A:  MOVWF  20
0D0B:  MOVLW  DB
0D0C:  MOVWF  27
0D0D:  MOVLW  0F
0D0E:  MOVWF  26
0D0F:  MOVLW  49
0D10:  MOVWF  25
0D11:  MOVLW  7F
0D12:  MOVWF  24
0D13:  BCF    0A.3
0D14:  BCF    03.5
0D15:  CALL   53D
0D16:  BSF    0A.3
0D17:  MOVF   7A,W
0D18:  BSF    03.5
0D19:  MOVWF  23
0D1A:  MOVF   79,W
0D1B:  MOVWF  22
0D1C:  MOVF   78,W
0D1D:  MOVWF  21
0D1E:  MOVF   77,W
0D1F:  MOVWF  20
0D20:  BCF    0A.3
0D21:  BCF    03.5
0D22:  CALL   64B
0D23:  BSF    0A.3
0D24:  MOVF   78,W
0D25:  MOVWF  5E
.................... 	frac = (x / PI_DIV_BY_TWO) - quad;  // fractional part of input  
0D26:  MOVF   51,W
0D27:  BSF    03.5
0D28:  MOVWF  23
0D29:  BCF    03.5
0D2A:  MOVF   50,W
0D2B:  BSF    03.5
0D2C:  MOVWF  22
0D2D:  BCF    03.5
0D2E:  MOVF   4F,W
0D2F:  BSF    03.5
0D30:  MOVWF  21
0D31:  BCF    03.5
0D32:  MOVF   4E,W
0D33:  BSF    03.5
0D34:  MOVWF  20
0D35:  MOVLW  DB
0D36:  MOVWF  27
0D37:  MOVLW  0F
0D38:  MOVWF  26

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -