CCS PCM C Compiler, Version 4.106, 47914 14-4-13 14:02
Filename: C:\Users\Honza\Documents\pic\uhel_sl\main.lst
ROM used: 3375 words (41%)
Largest free fragment is 2048
RAM used: 19 (5%) at main() level
81 (22%) worst case
Stack: 4 locations
*
0000: MOVLW 0C
0001: MOVWF 0A
0002: GOTO 45D
0003: NOP
.................... #include "C:\Users\Honza\Documents\pic\uhel_sl\main.h"
.................... #include <16F887.h>
.................... //////// Standard Header file for the PIC16F887 device ////////////////
.................... #device PIC16F887
.................... #list
....................
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES INTRC //Internal RC Osc
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOBROWNOUT //No brownout reset
.................... #FUSES IESO //Internal External Switch Over mode enabled
.................... #FUSES FCMEN //Fail-safe clock monitor enabled
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NODEBUG //No Debug mode for ICD
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES BORV40 //Brownout reset at 4.0V
....................
.................... #use delay(clock=8000000)
*
0330: MOVLW 3F
0331: MOVWF 04
0332: BCF 03.7
0333: MOVF 00,W
0334: BTFSC 03.2
0335: GOTO 343
0336: MOVLW 02
0337: MOVWF 78
0338: CLRF 77
0339: DECFSZ 77,F
033A: GOTO 339
033B: DECFSZ 78,F
033C: GOTO 338
033D: MOVLW 97
033E: MOVWF 77
033F: DECFSZ 77,F
0340: GOTO 33F
0341: DECFSZ 00,F
0342: GOTO 336
0343: RETURN
....................
....................
....................
....................
....................
.................... #define PIN_SDA PIN_B0
.................... #define PIN_SCL PIN_B1
.................... #use i2c(master, sda=PIN_SDA, scl=PIN_SCL)
*
00FE: MOVLW 08
00FF: MOVWF 78
0100: NOP
0101: BCF 06.1
0102: BSF 03.5
0103: BCF 06.1
0104: NOP
0105: BCF 03.5
0106: RLF 4D,F
0107: BCF 06.0
0108: BTFSS 03.0
0109: GOTO 10D
010A: BSF 03.5
010B: BSF 06.0
010C: BCF 03.5
010D: BTFSC 03.0
010E: GOTO 112
010F: BSF 03.5
0110: BCF 06.0
0111: BCF 03.5
0112: BSF 03.5
0113: BSF 06.1
0114: BCF 03.5
0115: BTFSS 06.1
0116: GOTO 115
0117: DECFSZ 78,F
0118: GOTO 100
0119: NOP
011A: BCF 06.1
011B: BSF 03.5
011C: BCF 06.1
011D: NOP
011E: BSF 06.0
011F: NOP
0120: NOP
0121: BSF 06.1
0122: BCF 03.5
0123: BTFSS 06.1
0124: GOTO 123
0125: CLRF 78
0126: NOP
0127: BTFSC 06.0
0128: BSF 78.0
0129: BCF 06.1
012A: BSF 03.5
012B: BCF 06.1
012C: BCF 03.5
012D: BCF 06.0
012E: BSF 03.5
012F: BCF 06.0
0130: BCF 03.5
0131: RETURN
*
015B: MOVLW 08
015C: MOVWF 4E
015D: MOVF 77,W
015E: MOVWF 4F
015F: BSF 03.5
0160: BSF 06.0
0161: NOP
0162: BSF 06.1
0163: BCF 03.5
0164: BTFSS 06.1
0165: GOTO 164
0166: BTFSC 06.0
0167: BSF 03.0
0168: BTFSS 06.0
0169: BCF 03.0
016A: RLF 78,F
016B: NOP
016C: BSF 03.5
016D: BCF 06.1
016E: BCF 03.5
016F: BCF 06.1
0170: DECFSZ 4E,F
0171: GOTO 15F
0172: BSF 03.5
0173: BSF 06.0
0174: NOP
0175: BCF 03.5
0176: BCF 06.0
0177: MOVF 4F,W
0178: BTFSC 03.2
0179: GOTO 17D
017A: BSF 03.5
017B: BCF 06.0
017C: BCF 03.5
017D: NOP
017E: BSF 03.5
017F: BSF 06.1
0180: BCF 03.5
0181: BTFSS 06.1
0182: GOTO 181
0183: NOP
0184: BCF 06.1
0185: BSF 03.5
0186: BCF 06.1
0187: NOP
0188: BCF 03.5
0189: BCF 06.0
018A: BSF 03.5
018B: BCF 06.0
018C: BCF 03.5
018D: RETURN
.................... #use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD
*
0071: BSF 03.5
0072: BCF 06.3
0073: BCF 03.5
0074: BCF 06.3
0075: MOVLW 08
0076: MOVWF 78
0077: GOTO 078
0078: NOP
0079: BSF 78.7
007A: GOTO 089
007B: BCF 78.7
007C: RRF 49,F
007D: BTFSC 03.0
007E: BSF 06.3
007F: BTFSS 03.0
0080: BCF 06.3
0081: BSF 78.6
0082: GOTO 089
0083: BCF 78.6
0084: DECFSZ 78,F
0085: GOTO 07C
0086: GOTO 087
0087: NOP
0088: BSF 06.3
0089: MOVLW 3F
008A: MOVWF 04
008B: DECFSZ 04,F
008C: GOTO 08B
008D: NOP
008E: BTFSC 78.7
008F: GOTO 07B
0090: BTFSC 78.6
0091: GOTO 083
0092: RETURN
.................... #include <math.h>
.................... ////////////////////////////////////////////////////////////////////////////
.................... //// (C) Copyright 1996,2008 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. ////
.................... //// * 2/21/2007 : Compiler handles & operator differently and does
.................... //// not return generic (int8 *) so type cast is done ////
.................... //// ////
.................... ////////////////////////////////////////////////////////////////////////////
....................
.................... #ifndef MATH_H
.................... #define MATH_H
....................
.................... #ifdef PI
.................... #undef PI
.................... #endif
.................... #define PI 3.1415926535897932
....................
....................
.................... #define SQRT2 1.4142135623730950
....................
.................... //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 //////////////////////////////
....................
.................... float32 CEIL_FLOOR(float32 x, unsigned int8 n)
.................... {
.................... float32 y, res;
.................... unsigned int16 l;
.................... int1 s;
....................
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y <= 32768.0)
.................... res = (float32)(unsigned int16)y;
....................
.................... else if (y < 10000000.0)
.................... {
.................... l = (unsigned int16)(y/32768.0);
.................... y = 32768.0*(y/32768.0 - (float32)l);
.................... res = 32768.0*(float32)l;
.................... res += (float32)(unsigned int16)y;
.................... }
....................
.................... else
.................... res = y;
....................
.................... y = y - (float32)(unsigned int16)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);
.................... }
....................
.................... // Overloaded Functions to take care for new Data types in PCD
.................... // Overloaded function CEIL_FLOOR() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 CEIL_FLOOR(float48 x, unsigned int8 n)
.................... {
.................... float48 y, res;
.................... unsigned int16 l;
.................... int1 s;
....................
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y <= 32768.0)
.................... res = (float48)(unsigned int16)y;
....................
.................... else if (y < 10000000.0)
.................... {
.................... l = (unsigned int16)(y/32768.0);
.................... y = 32768.0*(y/32768.0 - (float48)l);
.................... res = 32768.0*(float32)l;
.................... res += (float48)(unsigned int16)y;
.................... }
....................
.................... else
.................... res = y;
....................
.................... y = y - (float48)(unsigned int16)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);
.................... }
....................
....................
.................... // Overloaded function CEIL_FLOOR() for data type - Float64
.................... float64 CEIL_FLOOR(float64 x, unsigned int8 n)
.................... {
.................... float64 y, res;
.................... unsigned int16 l;
.................... int1 s;
....................
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y <= 32768.0)
.................... res = (float64)(unsigned int16)y;
....................
.................... else if (y < 10000000.0)
.................... {
.................... l = (unsigned int16)(y/32768.0);
.................... y = 32768.0*(y/32768.0 - (float64)l);
.................... res = 32768.0*(float64)l;
.................... res += (float64)(unsigned int16)y;
.................... }
....................
.................... else
.................... res = y;
....................
.................... y = y - (float64)(unsigned int16)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);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float floor(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : rounds down the number x.
.................... // Date : N/A
.................... //
.................... float32 floor(float32 x)
.................... {
.................... return CEIL_FLOOR(x, 0);
.................... }
.................... // Following 2 functions are overloaded functions of floor() for PCD
.................... // Overloaded function floor() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 floor(float48 x)
.................... {
.................... return CEIL_FLOOR(x, 0);
.................... }
....................
.................... // Overloaded function floor() for data type - Float64
.................... float64 floor(float64 x)
.................... {
.................... return CEIL_FLOOR(x, 0);
.................... }
.................... #endif
....................
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float ceil(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : rounds up the number x.
.................... // Date : N/A
.................... //
.................... float32 ceil(float32 x)
.................... {
.................... return CEIL_FLOOR(x, 1);
.................... }
.................... // Following 2 functions are overloaded functions of ceil() for PCD
.................... // Overloaded function ceil() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 ceil(float48 x)
.................... {
.................... return CEIL_FLOOR(x, 1);
.................... }
....................
.................... // Overloaded function ceil() for data type - Float64
.................... float64 ceil(float64 x)
.................... {
.................... return CEIL_FLOOR(x, 1);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // 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(float32 x,float32 y)
.................... {
.................... float32 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
.................... }
.................... }
.................... //Overloaded function for fmod() for PCD
.................... // Overloaded function fmod() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 fmod(float48 x,float48 y)
.................... {
.................... float48 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
.................... }
.................... }
.................... // Overloaded function fmod() for data type - Float64
.................... float64 fmod(float64 x,float64 y)
.................... {
.................... float64 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
.................... }
.................... }
.................... #endif
.................... //////////////////// Exponential and logarithmic functions ////////////////////
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float exp(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the value (e^x)
.................... // Date : N/A
.................... //
.................... #define LN2 0.6931471805599453
....................
.................... float const pe[6] = {0.000207455774, 0.00127100575, 0.00965065093,
.................... 0.0554965651, 0.240227138, 0.693147172};
....................
....................
.................... float32 exp(float32 x)
.................... {
.................... float32 y, res, r;
.................... #if defined(__PCD__)
.................... int8 data1;
.................... #endif
.................... signed int8 n;
.................... int1 s;
.................... #ifdef _ERRNO
.................... if(x > 88.722838)
.................... {
.................... errno=ERANGE;
.................... return(0);
.................... }
.................... #endif
.................... n = (signed int16)(x/LN2);
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... n = -n;
.................... y = -y;
.................... }
....................
.................... res = 0.0;
.................... #if !defined(__PCD__)
.................... *((unsigned int8 *)(&res)) = n + 0x7F;
.................... #endif
....................
.................... #if defined(__PCD__) // Takes care of IEEE format for PCD
.................... data1 = n+0x7F;
.................... if(bit_test(data1,0))
.................... bit_set(*(((unsigned int8 *)(&res)+2)),7);
.................... rotate_right(&data1,1);
.................... bit_clear(data1,7);
.................... *(((unsigned int8 *)(&res)+3)) = data1;
.................... #endif
....................
.................... y = y/LN2 - (float32)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);
.................... }
....................
....................
.................... //Overloaded function for exp() for PCD
.................... // Overloaded function exp() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 exp(float48 x)
.................... {
.................... float48 y, res, r;
.................... int8 data1;
.................... signed int8 n;
.................... int1 s;
.................... #ifdef _ERRNO
.................... if(x > 88.722838)
.................... {
.................... errno=ERANGE;
.................... return(0);
.................... }
.................... #endif
.................... n = (signed int16)(x/LN2);
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... n = -n;
.................... y = -y;
.................... }
....................
.................... res = 0.0;
....................
.................... data1 = n+0x7F;
.................... if(bit_test(data1,0))
.................... bit_set(*(((unsigned int8 *)(&res)+4)),7);
.................... rotate_right(&data1,1);
.................... bit_clear(data1,7);
.................... *(((unsigned int8 *)(&res)+5)) = data1;
....................
.................... y = y/LN2 - (float48)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);
.................... }
....................
.................... // Overloaded function exp() for data type - Float64
.................... float64 exp(float64 x)
.................... {
.................... float64 y, res, r;
.................... unsigned int16 data1, data2;
.................... unsigned int16 *p;
.................... signed int16 n;
.................... int1 s;
.................... #ifdef _ERRNO
.................... if(x > 709.7827128)
.................... {
.................... errno=ERANGE;
.................... return(0);
.................... }
.................... #endif
.................... n = (signed int16)(x/LN2);
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... n = -n;
.................... y = -y;
.................... }
....................
.................... res = 0.0;
....................
.................... #if !defined(__PCD__)
.................... *((unsigned int16 *)(&res)) = n + 0x7F;
.................... #endif
.................... p= (((unsigned int16 *)(&res))+3);
.................... data1 = *p;
.................... data2 = *p;
.................... data1 = n + 0x3FF;
.................... data1 = data1 <<4;
.................... if(bit_test(data2,15))
.................... bit_set(data1,15);
.................... data2 = data2 & 0x000F;
.................... data1 ^= data2;
....................
.................... *(((unsigned int16 *)(&res)+3)) = data1;
....................
....................
.................... y = y/LN2 - (float64)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);
.................... }
....................
.................... #ENDIF
....................
....................
.................... /************************************************************/
....................
.................... float32 const pl[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};
.................... float32 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
.................... //
.................... float32 log(float32 x)
.................... {
.................... float32 y, res, r, y2;
.................... #if defined(__PCD__)
.................... unsigned int8 data1,data2;
.................... #endif
.................... signed int8 n;
.................... #ifdef _ERRNO
.................... if(x <0)
.................... {
.................... errno=EDOM;
.................... }
.................... if(x ==0)
.................... {
.................... errno=ERANGE;
.................... return(0);
.................... }
.................... #endif
.................... y = x;
....................
.................... if (y != 1.0)
.................... {
.................... #if !defined(__PCD__)
.................... *((unsigned int8 *)(&y)) = 0x7E;
.................... #endif
....................
.................... #if defined(__PCD__) // Takes care of IEEE format
.................... data2 = *(((unsigned int8 *)(&y))+3);
.................... *(((unsigned int8 *)(&y))+3) = 0x3F;
.................... data1 = *(((unsigned int8 *)(&y))+2);
.................... bit_clear(data1,7);
.................... *(((unsigned int8 *)(&y))+2) = data1;
.................... if(bit_test(data2,7))
.................... bit_set(*(((unsigned int8 *)(&y))+3),7);
.................... #endif
....................
.................... 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;
.................... #if !defined(__PCD__)
.................... n = *((unsigned int8 *)(&x)) - 0x7E;
.................... #endif
.................... #if defined(__PCD__)
.................... data1 = *(((unsigned int8 *)(&x)+3));
.................... rotate_left(&data1,1);
.................... data2 = *(((unsigned int8 *)(&x)+2));
.................... if(bit_test (data2,7))
.................... bit_set(data1,0);
.................... n = data1 - 0x7E;
.................... #endif
....................
.................... if (n<0)
.................... r = -(float32)-n;
.................... else
.................... r = (float32)n;
....................
.................... res += r*LN2;
.................... }
....................
.................... else
.................... res = 0.0;
....................
.................... return(res);
.................... }
....................
.................... //Overloaded function for log() for PCD
.................... // Overloaded function log() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 log(float48 x)
.................... {
.................... float48 y, res, r, y2;
.................... unsigned int8 data1,data2;
.................... signed int8 n;
.................... #ifdef _ERRNO
.................... if(x <0)
.................... {
.................... errno=EDOM;
.................... }
.................... if(x ==0)
.................... {
.................... errno=ERANGE;
.................... return(0);
.................... }
.................... #endif
.................... y = x;
....................
.................... if (y != 1.0)
.................... {
....................
.................... #if !defined(__PCD__)
.................... *((unsigned int8 *)(&y)) = 0x7E;
.................... #endif
.................... data2 = *(((unsigned int8 *)(&y))+5);
.................... *(((unsigned int8 *)(&y))+5) = 0x3F;
.................... data1 = *(((unsigned int8 *)(&y))+4);
.................... bit_clear(data1,7);
.................... *(((unsigned int8 *)(&y))+4) = data1;
....................
.................... if(bit_test(data2,7))
.................... bit_set(*(((unsigned int8 *)(&y))+4),7);
.................... 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;
....................
.................... data1 = *(((unsigned int8 *)(&x)+5));
.................... rotate_left(&data1,1);
.................... data2 = *(((unsigned int8 *)(&x)+4));
.................... if(bit_test (data2,7))
.................... bit_set(data1,0);
....................
.................... n = data1 - 0x7E;
....................
.................... if (n<0)
.................... r = -(float48)-n;
.................... else
.................... r = (float48)n;
....................
.................... res += r*LN2;
.................... }
....................
.................... else
.................... res = 0.0;
....................
.................... return(res);
.................... }
....................
.................... // Overloaded function log() for data type - Float48
.................... #if defined(__PCD__)
.................... float32 const pl_64[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};
.................... float32 const ql_64[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943};
.................... #endif
.................... float64 log(float64 x)
.................... {
.................... float64 y, res, r, y2;
.................... unsigned int16 data1,data2;
.................... unsigned int16 *p;
.................... signed int16 n;
.................... #ifdef _ERRNO
.................... if(x <0)
.................... {
.................... errno=EDOM;
.................... }
.................... if(x ==0)
.................... {
.................... errno=ERANGE;
.................... return(0);
.................... }
.................... #endif
.................... y = x;
....................
.................... if (y != 1.0)
.................... {
.................... #if !defined(__PCD__)
.................... *((unsigned int8 *)(&y)) = 0x7E;
.................... #endif
.................... p= (((unsigned int16 *)(&y))+3);
.................... data1 = *p;
.................... data2 = *p;
.................... data1 = 0x3FE;
.................... data1 = data1 <<4;
.................... if(bit_test (data2,15))
.................... bit_set(data1,15);
.................... data2 = data2 & 0x000F;
.................... data1 ^=data2;
....................
.................... *p = data1;
....................
.................... y = (y - 1.0)/(y + 1.0);
....................
.................... y2=y*y;
....................
.................... res = pl_64[0]*y2 + pl_64[1];
.................... res = res*y2 + pl_64[2];
.................... res = res*y2 + pl_64[3];
....................
.................... r = ql_64[0]*y2 + ql_64[1];
.................... r = r*y2 + ql_64[2];
.................... r = r*y2 + ql_64[3];
....................
.................... res = y*res/r;
....................
.................... p= (((unsigned int16 *)(&x))+3);
.................... data1 = *p;
.................... bit_clear(data1,15);
.................... data1 = data1 >>4;
.................... n = data1 - 0x3FE;
....................
....................
.................... if (n<0)
.................... r = -(float64)-n;
.................... else
.................... r = (float64)n;
....................
.................... res += r*LN2;
.................... }
....................
.................... else
.................... res = 0.0;
....................
.................... return(res);
.................... }
.................... #endif
....................
....................
.................... #define LN10 2.3025850929940456
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float log10(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the the log base 10 of x
.................... // Date : N/A
.................... //
.................... float32 log10(float32 x)
.................... {
.................... float32 r;
....................
.................... r = log(x);
.................... r = r/LN10;
.................... return(r);
.................... }
....................
.................... //Overloaded functions for log10() for PCD
.................... // Overloaded function log10() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 log10(float48 x)
.................... {
.................... float48 r;
....................
.................... r = log(x);
.................... r = r/LN10;
.................... return(r);
.................... }
....................
.................... // Overloaded function log10() for data type - Float64
.................... float64 log10(float64 x)
.................... {
.................... float64 r;
....................
.................... r = log(x);
.................... r = r/LN10;
.................... return(r);
.................... }
.................... #endif
.................... ////////////////////////////////////////////////////////////////////////////
.................... // 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
.................... //
....................
.................... float32 modf(float32 value,float32 *iptr)
.................... {
.................... *iptr=(value < 0.0)? ceil(value): floor(value);
.................... return(value - *iptr);
.................... }
.................... //Overloaded functions for modf() for PCD
.................... // Overloaded function modf() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 modf(float48 value,float48 *iptr)
.................... {
.................... *iptr=(value < 0.0)? ceil(value): floor(value);
.................... return(value - *iptr);
.................... }
.................... // Overloaded function modf() for data type - Float64
.................... float64 modf(float64 value,float64 *iptr)
.................... {
.................... *iptr=(value < 0.0)? ceil(value): floor(value);
.................... return(value - *iptr);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float pwr(float x,float y)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the value (x^y)
.................... // Date : N/A
.................... // Note : 0 is returned when the function will generate an imaginary number
.................... //
.................... float32 pwr(float32 x,float32 y)
.................... {
.................... if(0 > x && fmod(y, 1) == 0) {
.................... if(fmod(y, 2) == 0) {
.................... return (exp(log(-x) * y));
.................... } else {
.................... return (-exp(log(-x) * y));
.................... }
.................... } else if(0 > x && fmod(y, 1) != 0) {
.................... return 0;
.................... } else {
.................... if(x != 0 || 0 >= y) {
.................... return (exp(log(x) * y));
.................... }
.................... }
.................... }
.................... //Overloaded functions for pwr() for PCD
.................... // Overloaded function pwr() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 pwr(float48 x,float48 y)
.................... {
.................... if(0 > x && fmod(y, 1) == 0) {
.................... if(fmod(y, 2) == 0) {
.................... return (exp(log(-x) * y));
.................... } else {
.................... return (-exp(log(-x) * y));
.................... }
.................... } else if(0 > x && fmod(y, 1) != 0) {
.................... return 0;
.................... } else {
.................... if(x != 0 || 0 >= y) {
.................... return (exp(log(x) * y));
.................... }
.................... }
.................... }
.................... // Overloaded function pwr() for data type - Float64
.................... float64 pwr(float64 x,float64 y)
.................... {
.................... if(0 > x && fmod(y, 1) == 0) {
.................... if(fmod(y, 2) == 0) {
.................... return (exp(log(-x) * y));
.................... } else {
.................... return (-exp(log(-x) * y));
.................... }
.................... } else if(0 > x && fmod(y, 1) != 0) {
.................... return 0;
.................... } else {
.................... if(x != 0 || 0 >= y) {
.................... return (exp(log(x) * y));
.................... }
.................... }
.................... }
.................... #endif
....................
.................... //////////////////// Power functions ////////////////////
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float pow(float x,float y)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the value (x^y)
.................... // Date : N/A
.................... // Note : 0 is returned when the function will generate an imaginary number
.................... //
.................... float32 pow(float32 x,float32 y)
.................... {
.................... if(0 > x && fmod(y, 1) == 0) {
.................... if(fmod(y, 2) == 0) {
.................... return (exp(log(-x) * y));
.................... } else {
.................... return (-exp(log(-x) * y));
.................... }
.................... } else if(0 > x && fmod(y, 1) != 0) {
.................... return 0;
.................... } else {
.................... if(x != 0 || 0 >= y) {
.................... return (exp(log(x) * y));
.................... }
.................... }
.................... }
.................... //Overloaded functions for pow() for PCD
.................... // Overloaded function for pow() data type - Float48
.................... #if defined(__PCD__)
.................... float48 pow(float48 x,float48 y)
.................... {
.................... if(0 > x && fmod(y, 1) == 0) {
.................... if(fmod(y, 2) == 0) {
.................... return (exp(log(-x) * y));
.................... } else {
.................... return (-exp(log(-x) * y));
.................... }
.................... } else if(0 > x && fmod(y, 1) != 0) {
.................... return 0;
.................... } else {
.................... if(x != 0 || 0 >= y) {
.................... return (exp(log(x) * y));
.................... }
.................... }
.................... }
....................
.................... // Overloaded function pow() for data type - Float64
.................... float64 pow(float64 x,float64 y)
.................... {
.................... if(0 > x && fmod(y, 1) == 0) {
.................... if(fmod(y, 2) == 0) {
.................... return (exp(log(-x) * y));
.................... } else {
.................... return (-exp(log(-x) * y));
.................... }
.................... } else if(0 > x && fmod(y, 1) != 0) {
.................... return 0;
.................... } else {
.................... if(x != 0 || 0 >= y) {
.................... return (exp(log(x) * y));
.................... }
.................... }
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float sqrt(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the square root of x
.................... // Date : N/A
.................... //
.................... float32 sqrt(float32 x)
.................... {
.................... float32 y, res;
.................... #if defined(__PCD__)
.................... unsigned int16 data1,data2;
.................... #endif
.................... BYTE *p;
....................
.................... #ifdef _ERRNO
.................... if(x < 0)
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
....................
.................... if( x<=0.0)
.................... return(0.0);
....................
.................... y=x;
....................
.................... #if !defined(__PCD__)
.................... p=&y;
.................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1);
.................... #endif
....................
.................... #if defined(__PCD__)
.................... p = (((unsigned int8 *)(&y))+3);
.................... data1 = *(((unsigned int8 *)(&y))+3);
.................... data2 = *(((unsigned int8 *)(&y))+2);
.................... rotate_left(&data1,1);
.................... if(bit_test(data2,7))
.................... bit_set(data1,0);
.................... data1 = ((data1+127) >>1);
.................... bit_clear(data2,7);
.................... if(bit_test(data1,0))
.................... bit_set(data2,7);
.................... data1 = data1 >>1;
.................... *(((unsigned int8 *)(&y))+3) = data1;
.................... *(((unsigned int8 *)(&y))+2) = data2;
....................
.................... #endif
....................
.................... do {
.................... res=y;
.................... y+=(x/y);
....................
.................... #if !defined(__PCD__)
.................... (*p)--;
.................... #endif
....................
.................... #if defined(__PCD__)
.................... data1 = *(((unsigned int8 *)(&y))+3);
.................... data2 = *(((unsigned int8 *)(&y))+2);
.................... rotate_left(&data1,1);
.................... if(bit_test(data2,7))
.................... bit_set(data1,0);
.................... data1--;
.................... bit_clear(data2,7);
.................... if(bit_test(data1,0))
.................... bit_set(data2,7);
.................... data1 = data1 >>1;
.................... *(((unsigned int8 *)(&y))+3) = data1;
.................... *(((unsigned int8 *)(&y))+2) = data2;
....................
.................... #endif
.................... } while(res != y);
....................
.................... return(res);
.................... }
.................... //Overloaded functions for sqrt() for PCD
.................... // Overloaded function sqrt() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 sqrt(float48 x)
.................... {
.................... float48 y, res;
.................... unsigned int16 data1,data2;
.................... BYTE *p;
....................
.................... #ifdef _ERRNO
.................... if(x < 0)
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
....................
.................... if( x<=0.0)
.................... return(0.0);
....................
.................... y=x;
....................
.................... #if !defined(__PCD__)
.................... p=&y;
.................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1);
.................... #endif
....................
.................... #if defined(__PCD__)
.................... p = (((unsigned int8 *)(&y))+5);
.................... data1 = *(((unsigned int8 *)(&y))+5);
.................... data2 = *(((unsigned int8 *)(&y))+4);
.................... rotate_left(&data1,1);
.................... if(bit_test(data2,7))
.................... bit_set(data1,0);
.................... data1 = ((data1+127) >>1);
.................... bit_clear(data2,7);
.................... if(bit_test(data1,0))
.................... bit_set(data2,7);
.................... data1 = data1 >>1;
.................... *(((unsigned int8 *)(&y))+5) = data1;
.................... *(((unsigned int8 *)(&y))+4) = data2;
....................
.................... #endif
....................
.................... do {
.................... res=y;
.................... y+=(x/y);
....................
.................... #if !defined(__PCD__)
.................... (*p)--;
.................... #endif
....................
.................... data1 = *(((unsigned int8 *)(&y))+5);
.................... data2 = *(((unsigned int8 *)(&y))+4);
.................... rotate_left(&data1,1);
.................... if(bit_test(data2,7))
.................... bit_set(data1,0);
.................... data1--;
.................... bit_clear(data2,7);
.................... if(bit_test(data1,0))
.................... bit_set(data2,7);
.................... data1 = data1 >>1;
.................... *(((unsigned int8 *)(&y))+5) = data1;
.................... *(((unsigned int8 *)(&y))+4) = data2;
....................
.................... } while(res != y);
....................
.................... return(res);
.................... }
....................
.................... // Overloaded function sqrt() for data type - Float64
.................... float64 sqrt(float64 x)
.................... {
.................... float64 y, res;
.................... unsigned int16 *p;
.................... unsigned int16 temp1,temp2;
....................
.................... #ifdef _ERRNO
.................... if(x < 0)
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
....................
.................... if( x<=0.0)
.................... return(0.0);
....................
.................... y=x;
.................... p= (((unsigned int16 *)(&y))+3);
.................... temp1 = *p;
.................... temp2 = *p;
.................... bit_clear(temp1,15);
.................... temp1 = (temp1>>4)+1023;
.................... temp1 = temp1 >> 1;
.................... temp1 = (temp1<<4) & 0xFFF0;
.................... if(bit_test(temp2,15))
.................... bit_set(temp1,15);
.................... temp2 = temp2 & 0x000F;
.................... temp1 ^= temp2;
....................
.................... (*p) = temp1;
....................
.................... do {
.................... res=y;
.................... y+=(x/y);
.................... temp1 = *p;
.................... temp2 = *p;
.................... bit_clear(temp1,15);
.................... temp1 = (temp1>>4);
.................... temp1--;
.................... temp1 = (temp1<<4) & 0xFFF0;
.................... if(bit_test(temp2,15))
.................... bit_set(temp1,15);
.................... temp2 = temp2 & 0x000F;
.................... temp1 ^= temp2;
.................... (*p) = temp1;
....................
.................... } while(res != y);
....................
.................... return(res);
.................... }
.................... #endif
....................
.................... ////////////////////////////// Trig Functions //////////////////////////////
.................... #ifdef PI_DIV_BY_TWO
.................... #undef PI_DIV_BY_TWO
.................... #endif
.................... #define PI_DIV_BY_TWO 1.5707963267948966
.................... #ifdef TWOBYPI
.................... #undef TWOBYPI
.................... #define TWOBYPI 0.6366197723675813
.................... #endif
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float cos(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the cosine value of the angle x, which is in radian
.................... // Date : 9/20/2001
.................... //
.................... float32 cos(float32 x)
.................... {
.................... float32 y, t, t2 = 1.0;
.................... unsigned int8 quad, i;
.................... float32 frac;
.................... float32 p[6] = { //by the series definition for cosine
.................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
.................... 0.04166666666667,
.................... -0.00138888888889,
.................... 0.00002480158730,
.................... -0.00000027557319,
.................... 0.00000000208767,
.................... //-0.00000000001147,
.................... // 0.00000000000005
.................... };
....................
.................... if (x < 0) x = -x; // absolute value of input
....................
.................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
.................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
.................... quad = quad % 4; // quadrant (0 to 3)
....................
.................... if (quad == 0 || quad == 2)
.................... t = frac * PI_DIV_BY_TWO;
.................... else if (quad == 1)
.................... t = (1-frac) * PI_DIV_BY_TWO;
.................... else // should be 3
.................... t = (frac-1) * PI_DIV_BY_TWO;
....................
.................... y = 1.0;
.................... t = t * t;
.................... for (i = 0; i <= 5; i++)
.................... {
.................... t2 = t2 * t;
.................... y = y + p[i] * t2;
.................... }
....................
.................... if (quad == 2 || quad == 1)
.................... y = -y; // correct sign
....................
.................... return (y);
.................... }
....................
....................
.................... //Overloaded functions for cos() for PCD
.................... // Overloaded function cos() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 cos(float48 x)
.................... {
.................... float48 y, t, t2 = 1.0;
.................... unsigned int8 quad, i;
.................... float48 frac;
.................... float48 p[6] = { //by the series definition for cosine
.................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
.................... 0.04166666666667,
.................... -0.00138888888889,
.................... 0.00002480158730,
.................... -0.00000027557319,
.................... 0.00000000208767,
.................... //-0.00000000001147,
.................... // 0.00000000000005
.................... };
....................
.................... if (x < 0) x = -x; // absolute value of input
....................
.................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
.................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
.................... quad = quad % 4; // quadrant (0 to 3)
....................
.................... if (quad == 0 || quad == 2)
.................... t = frac * PI_DIV_BY_TWO;
.................... else if (quad == 1)
.................... t = (1-frac) * PI_DIV_BY_TWO;
.................... else // should be 3
.................... t = (frac-1) * PI_DIV_BY_TWO;
....................
.................... y = 0.999999999781;
.................... t = t * t;
.................... for (i = 0; i <= 5; i++)
.................... {
.................... t2 = t2 * t;
.................... y = y + p[i] * t2;
.................... }
....................
.................... if (quad == 2 || quad == 1)
.................... y = -y; // correct sign
....................
.................... return (y);
.................... }
....................
.................... // Overloaded function cos() for data type - Float48
.................... float64 cos(float64 x)
.................... {
.................... float64 y, t, t2 = 1.0;
.................... unsigned int8 quad, i;
.................... float64 frac;
.................... float64 p[6] = { //by the series definition for cosine
.................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
.................... 0.04166666666667,
.................... -0.00138888888889,
.................... 0.00002480158730,
.................... -0.00000027557319,
.................... 0.00000000208767,
.................... //-0.00000000001147,
.................... // 0.00000000000005
.................... };
....................
.................... if (x < 0) x = -x; // absolute value of input
....................
.................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
.................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
.................... quad = quad % 4; // quadrant (0 to 3)
....................
.................... if (quad == 0 || quad == 2)
.................... t = frac * PI_DIV_BY_TWO;
.................... else if (quad == 1)
.................... t = (1-frac) * PI_DIV_BY_TWO;
.................... else // should be 3
.................... t = (frac-1) * PI_DIV_BY_TWO;
....................
.................... y = 0.999999999781;
.................... t = t * t;
.................... for (i = 0; i <= 5; i++)
.................... {
.................... t2 = t2 * t;
.................... y = y + p[i] * t2;
.................... }
....................
.................... if (quad == 2 || quad == 1)
.................... y = -y; // correct sign
....................
.................... return (y);
.................... }
....................
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float sin(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the sine value of the angle x, which is in radian
.................... // Date : 9/20/2001
.................... //
.................... float32 sin(float32 x)
.................... {
.................... return cos(x - PI_DIV_BY_TWO);
.................... }
....................
.................... //Overloaded functions for sin() for PCD
.................... // Overloaded function sin() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 sin(float48 x)
.................... {
.................... return cos(x - PI_DIV_BY_TWO);
.................... }
....................
.................... // Overloaded function sin() for data type - Float48
.................... float64 sin(float64 x)
.................... {
.................... return cos(x - PI_DIV_BY_TWO);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float tan(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the tangent value of the angle x, which is in radian
.................... // Date : 9/20/2001
.................... //
.................... float32 tan(float32 x)
.................... {
.................... float32 c, s;
....................
.................... c = cos(x);
.................... if (c == 0.0)
.................... return (1.0e+36);
....................
.................... s = sin(x);
.................... return(s/c);
.................... }
.................... //Overloaded functions for tan() for PCD
.................... // Overloaded function tan() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 tan(float48 x)
.................... {
.................... float48 c, s;
....................
.................... c = cos(x);
.................... if (c == 0.0)
.................... return (1.0e+36);
....................
.................... s = sin(x);
.................... return(s/c);
.................... }
....................
.................... // Overloaded function tan() for data type - Float48
.................... float64 tan(float64 x)
.................... {
.................... float64 c, s;
....................
.................... c = cos(x);
.................... if (c == 0.0)
.................... return (1.0e+36);
....................
.................... s = sin(x);
.................... return(s/c);
.................... }
.................... #endif
....................
.................... float32 const pas[3] = {0.49559947, -4.6145309, 5.6036290};
.................... float32 const qas[3] = {1.0000000, -5.5484666, 5.6036290};
....................
.................... float32 ASIN_COS(float32 x, unsigned int8 n)
.................... {
.................... float32 y, res, r, y2;
.................... int1 s;
.................... #ifdef _ERRNO
.................... if(x <-1 || x > 1)
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y > 0.5)
.................... {
.................... y = sqrt((1.0 - y)/2.0);
.................... n += 2;
.................... }
....................
.................... y2=y*y;
....................
.................... res = pas[0]*y2 + pas[1];
.................... res = res*y2 + pas[2];
....................
.................... r = qas[0]*y2 + qas[1];
.................... r = r*y2 + qas[2];
....................
.................... res = y*res/r;
....................
.................... if (n & 2) // |x| > 0.5
.................... res = PI_DIV_BY_TWO - 2.0*res;
.................... if (s)
.................... res = -res;
.................... if (n & 1) // take arccos
.................... res = PI_DIV_BY_TWO - res;
....................
.................... return(res);
.................... }
....................
.................... //Overloaded functions for ASIN_COS() for PCD
.................... // Overloaded function ASIN_COS() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 ASIN_COS(float48 x, unsigned int8 n)
.................... {
.................... float48 y, res, r, y2;
.................... int1 s;
.................... #ifdef _ERRNO
.................... if(x <-1 || x > 1)
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y > 0.5)
.................... {
.................... y = sqrt((1.0 - y)/2.0);
.................... n += 2;
.................... }
....................
.................... y2=y*y;
....................
.................... res = pas[0]*y2 + pas[1];
.................... res = res*y2 + pas[2];
....................
.................... r = qas[0]*y2 + qas[1];
.................... r = r*y2 + qas[2];
....................
.................... res = y*res/r;
....................
.................... if (n & 2) // |x| > 0.5
.................... res = PI_DIV_BY_TWO - 2.0*res;
.................... if (s)
.................... res = -res;
.................... if (n & 1) // take arccos
.................... res = PI_DIV_BY_TWO - res;
....................
.................... return(res);
.................... }
....................
.................... // Overloaded function ASIN_COS() for data type - Float64
.................... float64 ASIN_COS(float64 x, unsigned int8 n)
.................... {
.................... float64 y, res, r, y2;
.................... int1 s;
.................... #ifdef _ERRNO
.................... if(x <-1 || x > 1)
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... s = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y > 0.5)
.................... {
.................... y = sqrt((1.0 - y)/2.0);
.................... n += 2;
.................... }
....................
.................... y2=y*y;
....................
.................... res = pas[0]*y2 + pas[1];
.................... res = res*y2 + pas[2];
....................
.................... r = qas[0]*y2 + qas[1];
.................... r = r*y2 + qas[2];
....................
.................... res = y*res/r;
....................
.................... if (n & 2) // |x| > 0.5
.................... res = PI_DIV_BY_TWO - 2.0*res;
.................... if (s)
.................... res = -res;
.................... if (n & 1) // take arccos
.................... res = PI_DIV_BY_TWO - res;
....................
.................... return(res);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float asin(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the arcsine value of the value x.
.................... // Date : N/A
.................... //
.................... float32 asin(float32 x)
.................... {
.................... float32 r;
....................
.................... r = ASIN_COS(x, 0);
.................... return(r);
.................... }
.................... //Overloaded functions for asin() for PCD
.................... // Overloaded function asin() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 asin(float48 x)
.................... {
.................... float48 r;
....................
.................... r = ASIN_COS(x, 0);
.................... return(r);
.................... }
....................
.................... // Overloaded function asin() for data type - Float64
.................... float64 asin(float64 x)
.................... {
.................... float64 r;
....................
.................... r = ASIN_COS(x, 0);
.................... return(r);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float acos(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the arccosine value of the value x.
.................... // Date : N/A
.................... //
.................... float32 acos(float32 x)
.................... {
.................... float32 r;
....................
.................... r = ASIN_COS(x, 1);
.................... return(r);
.................... }
.................... //Overloaded functions for acos() for PCD
.................... // Overloaded function acos() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 acos(float48 x)
.................... {
.................... float48 r;
....................
.................... r = ASIN_COS(x, 1);
.................... return(r);
.................... }
....................
.................... // Overloaded function acos() for data type - Float64
.................... float64 acos(float64 x)
.................... {
.................... float64 r;
....................
.................... r = ASIN_COS(x, 1);
.................... return(r);
.................... }
.................... #endif
....................
.................... float32 const pat[4] = {0.17630401, 5.6710795, 22.376096, 19.818457};
.................... float32 const qat[4] = {1.0000000, 11.368190, 28.982246, 19.818457};
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float atan(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : returns the arctangent value of the value x.
.................... // Date : N/A
.................... //
.................... float32 atan(float32 x)
.................... {
.................... float32 y, res, r;
.................... int1 s, flag;
....................
.................... s = 0;
*
089B: BCF 57.0
.................... flag = 0;
089C: BCF 57.1
.................... y = x;
089D: MOVF 4A,W
089E: MOVWF 4E
089F: MOVF 49,W
08A0: MOVWF 4D
08A1: MOVF 48,W
08A2: MOVWF 4C
08A3: MOVF 47,W
08A4: MOVWF 4B
....................
.................... if (x < 0)
08A5: MOVF 4A,W
08A6: MOVWF 5B
08A7: MOVF 49,W
08A8: MOVWF 5A
08A9: MOVF 48,W
08AA: MOVWF 59
08AB: MOVF 47,W
08AC: MOVWF 58
08AD: CLRF 5F
08AE: CLRF 5E
08AF: CLRF 5D
08B0: CLRF 5C
08B1: BCF 0A.3
08B2: CALL 433
08B3: BSF 0A.3
08B4: BTFSS 03.0
08B5: GOTO 0BA
.................... {
.................... s = 1;
08B6: BSF 57.0
.................... y = -y;
08B7: MOVF 4C,W
08B8: XORLW 80
08B9: MOVWF 4C
.................... }
....................
.................... if (y > 1.0)
08BA: CLRF 5B
08BB: CLRF 5A
08BC: CLRF 59
08BD: MOVLW 7F
08BE: MOVWF 58
08BF: MOVF 4E,W
08C0: MOVWF 5F
08C1: MOVF 4D,W
08C2: MOVWF 5E
08C3: MOVF 4C,W
08C4: MOVWF 5D
08C5: MOVF 4B,W
08C6: MOVWF 5C
08C7: BCF 0A.3
08C8: CALL 433
08C9: BSF 0A.3
08CA: BTFSS 03.0
08CB: GOTO 0E5
.................... {
.................... y = 1.0/y;
08CC: CLRF 5F
08CD: CLRF 5E
08CE: CLRF 5D
08CF: MOVLW 7F
08D0: MOVWF 5C
08D1: MOVF 4E,W
08D2: MOVWF 63
08D3: MOVF 4D,W
08D4: MOVWF 62
08D5: MOVF 4C,W
08D6: MOVWF 61
08D7: MOVF 4B,W
08D8: MOVWF 60
08D9: BCF 0A.3
08DA: CALL 369
08DB: BSF 0A.3
08DC: MOVF 7A,W
08DD: MOVWF 4E
08DE: MOVF 79,W
08DF: MOVWF 4D
08E0: MOVF 78,W
08E1: MOVWF 4C
08E2: MOVF 77,W
08E3: MOVWF 4B
.................... flag = 1;
08E4: BSF 57.1
.................... }
....................
.................... res = pat[0]*y*y + pat[1];
08E5: MOVLW 0A
08E6: MOVWF 5F
08E7: MOVLW 89
08E8: MOVWF 5E
08E9: MOVLW 34
08EA: MOVWF 5D
08EB: MOVLW 7C
08EC: MOVWF 5C
08ED: MOVF 4E,W
08EE: MOVWF 63
08EF: MOVF 4D,W
08F0: MOVWF 62
08F1: MOVF 4C,W
08F2: MOVWF 61
08F3: MOVF 4B,W
08F4: MOVWF 60
08F5: BCF 0A.3
08F6: CALL 472
08F7: BSF 0A.3
08F8: MOVF 77,W
08F9: MOVWF 58
08FA: MOVF 78,W
08FB: MOVWF 59
08FC: MOVF 79,W
08FD: MOVWF 5A
08FE: MOVF 7A,W
08FF: MOVWF 5B
0900: MOVWF 5F
0901: MOVF 79,W
0902: MOVWF 5E
0903: MOVF 78,W
0904: MOVWF 5D
0905: MOVF 77,W
0906: MOVWF 5C
0907: MOVF 4E,W
0908: MOVWF 63
0909: MOVF 4D,W
090A: MOVWF 62
090B: MOVF 4C,W
090C: MOVWF 61
090D: MOVF 4B,W
090E: MOVWF 60
090F: BCF 0A.3
0910: CALL 472
0911: BSF 0A.3
0912: MOVF 77,W
0913: MOVWF 58
0914: MOVF 78,W
0915: MOVWF 59
0916: MOVF 79,W
0917: MOVWF 5A
0918: MOVF 7A,W
0919: MOVWF 5B
091A: BCF 03.1
091B: MOVF 7A,W
091C: MOVWF 5F
091D: MOVF 79,W
091E: MOVWF 5E
091F: MOVF 78,W
0920: MOVWF 5D
0921: MOVF 77,W
0922: MOVWF 5C
0923: MOVLW 7C
0924: MOVWF 63
0925: MOVLW 79
0926: MOVWF 62
0927: MOVLW 35
0928: MOVWF 61
0929: MOVLW 81
092A: MOVWF 60
092B: BCF 0A.3
092C: CALL 4E7
092D: BSF 0A.3
092E: MOVF 7A,W
092F: MOVWF 52
0930: MOVF 79,W
0931: MOVWF 51
0932: MOVF 78,W
0933: MOVWF 50
0934: MOVF 77,W
0935: MOVWF 4F
.................... res = res*y*y + pat[2];
0936: MOVF 52,W
0937: MOVWF 5F
0938: MOVF 51,W
0939: MOVWF 5E
093A: MOVF 50,W
093B: MOVWF 5D
093C: MOVF 4F,W
093D: MOVWF 5C
093E: MOVF 4E,W
093F: MOVWF 63
0940: MOVF 4D,W
0941: MOVWF 62
0942: MOVF 4C,W
0943: MOVWF 61
0944: MOVF 4B,W
0945: MOVWF 60
0946: BCF 0A.3
0947: CALL 472
0948: BSF 0A.3
0949: MOVF 77,W
094A: MOVWF 58
094B: MOVF 78,W
094C: MOVWF 59
094D: MOVF 79,W
094E: MOVWF 5A
094F: MOVF 7A,W
0950: MOVWF 5B
0951: MOVWF 5F
0952: MOVF 79,W
0953: MOVWF 5E
0954: MOVF 78,W
0955: MOVWF 5D
0956: MOVF 77,W
0957: MOVWF 5C
0958: MOVF 4E,W
0959: MOVWF 63
095A: MOVF 4D,W
095B: MOVWF 62
095C: MOVF 4C,W
095D: MOVWF 61
095E: MOVF 4B,W
095F: MOVWF 60
0960: BCF 0A.3
0961: CALL 472
0962: BSF 0A.3
0963: MOVF 77,W
0964: MOVWF 58
0965: MOVF 78,W
0966: MOVWF 59
0967: MOVF 79,W
0968: MOVWF 5A
0969: MOVF 7A,W
096A: MOVWF 5B
096B: BCF 03.1
096C: MOVF 7A,W
096D: MOVWF 5F
096E: MOVF 79,W
096F: MOVWF 5E
0970: MOVF 78,W
0971: MOVWF 5D
0972: MOVF 77,W
0973: MOVWF 5C
0974: MOVLW 3F
0975: MOVWF 63
0976: MOVLW 02
0977: MOVWF 62
0978: MOVLW 33
0979: MOVWF 61
097A: MOVLW 83
097B: MOVWF 60
097C: BCF 0A.3
097D: CALL 4E7
097E: BSF 0A.3
097F: MOVF 7A,W
0980: MOVWF 52
0981: MOVF 79,W
0982: MOVWF 51
0983: MOVF 78,W
0984: MOVWF 50
0985: MOVF 77,W
0986: MOVWF 4F
.................... res = res*y*y + pat[3];
0987: MOVF 52,W
0988: MOVWF 5F
0989: MOVF 51,W
098A: MOVWF 5E
098B: MOVF 50,W
098C: MOVWF 5D
098D: MOVF 4F,W
098E: MOVWF 5C
098F: MOVF 4E,W
0990: MOVWF 63
0991: MOVF 4D,W
0992: MOVWF 62
0993: MOVF 4C,W
0994: MOVWF 61
0995: MOVF 4B,W
0996: MOVWF 60
0997: BCF 0A.3
0998: CALL 472
0999: BSF 0A.3
099A: MOVF 77,W
099B: MOVWF 58
099C: MOVF 78,W
099D: MOVWF 59
099E: MOVF 79,W
099F: MOVWF 5A
09A0: MOVF 7A,W
09A1: MOVWF 5B
09A2: MOVWF 5F
09A3: MOVF 79,W
09A4: MOVWF 5E
09A5: MOVF 78,W
09A6: MOVWF 5D
09A7: MOVF 77,W
09A8: MOVWF 5C
09A9: MOVF 4E,W
09AA: MOVWF 63
09AB: MOVF 4D,W
09AC: MOVWF 62
09AD: MOVF 4C,W
09AE: MOVWF 61
09AF: MOVF 4B,W
09B0: MOVWF 60
09B1: BCF 0A.3
09B2: CALL 472
09B3: BSF 0A.3
09B4: MOVF 77,W
09B5: MOVWF 58
09B6: MOVF 78,W
09B7: MOVWF 59
09B8: MOVF 79,W
09B9: MOVWF 5A
09BA: MOVF 7A,W
09BB: MOVWF 5B
09BC: BCF 03.1
09BD: MOVF 7A,W
09BE: MOVWF 5F
09BF: MOVF 79,W
09C0: MOVWF 5E
09C1: MOVF 78,W
09C2: MOVWF 5D
09C3: MOVF 77,W
09C4: MOVWF 5C
09C5: MOVLW 33
09C6: MOVWF 63
09C7: MOVLW 8C
09C8: MOVWF 62
09C9: MOVLW 1E
09CA: MOVWF 61
09CB: MOVLW 83
09CC: MOVWF 60
09CD: BCF 0A.3
09CE: CALL 4E7
09CF: BSF 0A.3
09D0: MOVF 7A,W
09D1: MOVWF 52
09D2: MOVF 79,W
09D3: MOVWF 51
09D4: MOVF 78,W
09D5: MOVWF 50
09D6: MOVF 77,W
09D7: MOVWF 4F
....................
.................... r = qat[0]*y*y + qat[1];
09D8: CLRF 5F
09D9: CLRF 5E
09DA: CLRF 5D
09DB: MOVLW 7F
09DC: MOVWF 5C
09DD: MOVF 4E,W
09DE: MOVWF 63
09DF: MOVF 4D,W
09E0: MOVWF 62
09E1: MOVF 4C,W
09E2: MOVWF 61
09E3: MOVF 4B,W
09E4: MOVWF 60
09E5: BCF 0A.3
09E6: CALL 472
09E7: BSF 0A.3
09E8: MOVF 77,W
09E9: MOVWF 58
09EA: MOVF 78,W
09EB: MOVWF 59
09EC: MOVF 79,W
09ED: MOVWF 5A
09EE: MOVF 7A,W
09EF: MOVWF 5B
09F0: MOVWF 5F
09F1: MOVF 79,W
09F2: MOVWF 5E
09F3: MOVF 78,W
09F4: MOVWF 5D
09F5: MOVF 77,W
09F6: MOVWF 5C
09F7: MOVF 4E,W
09F8: MOVWF 63
09F9: MOVF 4D,W
09FA: MOVWF 62
09FB: MOVF 4C,W
09FC: MOVWF 61
09FD: MOVF 4B,W
09FE: MOVWF 60
09FF: BCF 0A.3
0A00: CALL 472
0A01: BSF 0A.3
0A02: MOVF 77,W
0A03: MOVWF 58
0A04: MOVF 78,W
0A05: MOVWF 59
0A06: MOVF 79,W
0A07: MOVWF 5A
0A08: MOVF 7A,W
0A09: MOVWF 5B
0A0A: BCF 03.1
0A0B: MOVF 7A,W
0A0C: MOVWF 5F
0A0D: MOVF 79,W
0A0E: MOVWF 5E
0A0F: MOVF 78,W
0A10: MOVWF 5D
0A11: MOVF 77,W
0A12: MOVWF 5C
0A13: MOVLW 1B
0A14: MOVWF 63
0A15: MOVLW E4
0A16: MOVWF 62
0A17: MOVLW 35
0A18: MOVWF 61
0A19: MOVLW 82
0A1A: MOVWF 60
0A1B: BCF 0A.3
0A1C: CALL 4E7
0A1D: BSF 0A.3
0A1E: MOVF 7A,W
0A1F: MOVWF 56
0A20: MOVF 79,W
0A21: MOVWF 55
0A22: MOVF 78,W
0A23: MOVWF 54
0A24: MOVF 77,W
0A25: MOVWF 53
.................... r = r*y*y + qat[2];
0A26: MOVF 56,W
0A27: MOVWF 5F
0A28: MOVF 55,W
0A29: MOVWF 5E
0A2A: MOVF 54,W
0A2B: MOVWF 5D
0A2C: MOVF 53,W
0A2D: MOVWF 5C
0A2E: MOVF 4E,W
0A2F: MOVWF 63
0A30: MOVF 4D,W
0A31: MOVWF 62
0A32: MOVF 4C,W
0A33: MOVWF 61
0A34: MOVF 4B,W
0A35: MOVWF 60
0A36: BCF 0A.3
0A37: CALL 472
0A38: BSF 0A.3
0A39: MOVF 77,W
0A3A: MOVWF 58
0A3B: MOVF 78,W
0A3C: MOVWF 59
0A3D: MOVF 79,W
0A3E: MOVWF 5A
0A3F: MOVF 7A,W
0A40: MOVWF 5B
0A41: MOVWF 5F
0A42: MOVF 79,W
0A43: MOVWF 5E
0A44: MOVF 78,W
0A45: MOVWF 5D
0A46: MOVF 77,W
0A47: MOVWF 5C
0A48: MOVF 4E,W
0A49: MOVWF 63
0A4A: MOVF 4D,W
0A4B: MOVWF 62
0A4C: MOVF 4C,W
0A4D: MOVWF 61
0A4E: MOVF 4B,W
0A4F: MOVWF 60
0A50: BCF 0A.3
0A51: CALL 472
0A52: BSF 0A.3
0A53: MOVF 77,W
0A54: MOVWF 58
0A55: MOVF 78,W
0A56: MOVWF 59
0A57: MOVF 79,W
0A58: MOVWF 5A
0A59: MOVF 7A,W
0A5A: MOVWF 5B
0A5B: BCF 03.1
0A5C: MOVF 7A,W
0A5D: MOVWF 5F
0A5E: MOVF 79,W
0A5F: MOVWF 5E
0A60: MOVF 78,W
0A61: MOVWF 5D
0A62: MOVF 77,W
0A63: MOVWF 5C
0A64: MOVLW A4
0A65: MOVWF 63
0A66: MOVLW DB
0A67: MOVWF 62
0A68: MOVLW 67
0A69: MOVWF 61
0A6A: MOVLW 83
0A6B: MOVWF 60
0A6C: BCF 0A.3
0A6D: CALL 4E7
0A6E: BSF 0A.3
0A6F: MOVF 7A,W
0A70: MOVWF 56
0A71: MOVF 79,W
0A72: MOVWF 55
0A73: MOVF 78,W
0A74: MOVWF 54
0A75: MOVF 77,W
0A76: MOVWF 53
.................... r = r*y*y + qat[3];
0A77: MOVF 56,W
0A78: MOVWF 5F
0A79: MOVF 55,W
0A7A: MOVWF 5E
0A7B: MOVF 54,W
0A7C: MOVWF 5D
0A7D: MOVF 53,W
0A7E: MOVWF 5C
0A7F: MOVF 4E,W
0A80: MOVWF 63
0A81: MOVF 4D,W
0A82: MOVWF 62
0A83: MOVF 4C,W
0A84: MOVWF 61
0A85: MOVF 4B,W
0A86: MOVWF 60
0A87: BCF 0A.3
0A88: CALL 472
0A89: BSF 0A.3
0A8A: MOVF 77,W
0A8B: MOVWF 58
0A8C: MOVF 78,W
0A8D: MOVWF 59
0A8E: MOVF 79,W
0A8F: MOVWF 5A
0A90: MOVF 7A,W
0A91: MOVWF 5B
0A92: MOVWF 5F
0A93: MOVF 79,W
0A94: MOVWF 5E
0A95: MOVF 78,W
0A96: MOVWF 5D
0A97: MOVF 77,W
0A98: MOVWF 5C
0A99: MOVF 4E,W
0A9A: MOVWF 63
0A9B: MOVF 4D,W
0A9C: MOVWF 62
0A9D: MOVF 4C,W
0A9E: MOVWF 61
0A9F: MOVF 4B,W
0AA0: MOVWF 60
0AA1: BCF 0A.3
0AA2: CALL 472
0AA3: BSF 0A.3
0AA4: MOVF 77,W
0AA5: MOVWF 58
0AA6: MOVF 78,W
0AA7: MOVWF 59
0AA8: MOVF 79,W
0AA9: MOVWF 5A
0AAA: MOVF 7A,W
0AAB: MOVWF 5B
0AAC: BCF 03.1
0AAD: MOVF 7A,W
0AAE: MOVWF 5F
0AAF: MOVF 79,W
0AB0: MOVWF 5E
0AB1: MOVF 78,W
0AB2: MOVWF 5D
0AB3: MOVF 77,W
0AB4: MOVWF 5C
0AB5: MOVLW 33
0AB6: MOVWF 63
0AB7: MOVLW 8C
0AB8: MOVWF 62
0AB9: MOVLW 1E
0ABA: MOVWF 61
0ABB: MOVLW 83
0ABC: MOVWF 60
0ABD: BCF 0A.3
0ABE: CALL 4E7
0ABF: BSF 0A.3
0AC0: MOVF 7A,W
0AC1: MOVWF 56
0AC2: MOVF 79,W
0AC3: MOVWF 55
0AC4: MOVF 78,W
0AC5: MOVWF 54
0AC6: MOVF 77,W
0AC7: MOVWF 53
....................
.................... res = y*res/r;
0AC8: MOVF 4E,W
0AC9: MOVWF 5F
0ACA: MOVF 4D,W
0ACB: MOVWF 5E
0ACC: MOVF 4C,W
0ACD: MOVWF 5D
0ACE: MOVF 4B,W
0ACF: MOVWF 5C
0AD0: MOVF 52,W
0AD1: MOVWF 63
0AD2: MOVF 51,W
0AD3: MOVWF 62
0AD4: MOVF 50,W
0AD5: MOVWF 61
0AD6: MOVF 4F,W
0AD7: MOVWF 60
0AD8: BCF 0A.3
0AD9: CALL 472
0ADA: BSF 0A.3
0ADB: MOVF 77,W
0ADC: MOVWF 58
0ADD: MOVF 78,W
0ADE: MOVWF 59
0ADF: MOVF 79,W
0AE0: MOVWF 5A
0AE1: MOVF 7A,W
0AE2: MOVWF 5B
0AE3: MOVWF 5F
0AE4: MOVF 79,W
0AE5: MOVWF 5E
0AE6: MOVF 78,W
0AE7: MOVWF 5D
0AE8: MOVF 77,W
0AE9: MOVWF 5C
0AEA: MOVF 56,W
0AEB: MOVWF 63
0AEC: MOVF 55,W
0AED: MOVWF 62
0AEE: MOVF 54,W
0AEF: MOVWF 61
0AF0: MOVF 53,W
0AF1: MOVWF 60
0AF2: BCF 0A.3
0AF3: CALL 369
0AF4: BSF 0A.3
0AF5: MOVF 7A,W
0AF6: MOVWF 52
0AF7: MOVF 79,W
0AF8: MOVWF 51
0AF9: MOVF 78,W
0AFA: MOVWF 50
0AFB: MOVF 77,W
0AFC: MOVWF 4F
....................
....................
.................... if (flag) // for |x| > 1
0AFD: BTFSS 57.1
0AFE: GOTO 31B
.................... res = PI_DIV_BY_TWO - res;
0AFF: BSF 03.1
0B00: MOVLW DB
0B01: MOVWF 5F
0B02: MOVLW 0F
0B03: MOVWF 5E
0B04: MOVLW 49
0B05: MOVWF 5D
0B06: MOVLW 7F
0B07: MOVWF 5C
0B08: MOVF 52,W
0B09: MOVWF 63
0B0A: MOVF 51,W
0B0B: MOVWF 62
0B0C: MOVF 50,W
0B0D: MOVWF 61
0B0E: MOVF 4F,W
0B0F: MOVWF 60
0B10: BCF 0A.3
0B11: CALL 4E7
0B12: BSF 0A.3
0B13: MOVF 7A,W
0B14: MOVWF 52
0B15: MOVF 79,W
0B16: MOVWF 51
0B17: MOVF 78,W
0B18: MOVWF 50
0B19: MOVF 77,W
0B1A: MOVWF 4F
.................... if (s)
0B1B: BTFSS 57.0
0B1C: GOTO 320
.................... res = -res;
0B1D: MOVF 50,W
0B1E: XORLW 80
0B1F: MOVWF 50
....................
.................... return(res);
0B20: MOVF 4F,W
0B21: MOVWF 77
0B22: MOVF 50,W
0B23: MOVWF 78
0B24: MOVF 51,W
0B25: MOVWF 79
0B26: MOVF 52,W
0B27: MOVWF 7A
.................... }
.................... //Overloaded functions for atan() for PCD
.................... // Overloaded function atan() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 atan(float48 x)
.................... {
.................... float48 y, res, r;
.................... int1 s, flag;
....................
.................... s = 0;
.................... flag = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y > 1.0)
.................... {
.................... y = 1.0/y;
.................... flag = 1;
.................... }
....................
.................... res = pat[0]*y*y + pat[1];
.................... res = res*y*y + pat[2];
.................... res = res*y*y + pat[3];
....................
.................... r = qat[0]*y*y + qat[1];
.................... r = r*y*y + qat[2];
.................... r = r*y*y + qat[3];
....................
.................... res = y*res/r;
....................
....................
.................... if (flag) // for |x| > 1
.................... res = PI_DIV_BY_TWO - res;
.................... if (s)
.................... res = -res;
....................
.................... return(res);
.................... }
....................
.................... // Overloaded function atan() for data type - Float64
.................... float64 atan(float64 x)
.................... {
.................... float64 y, res, r;
.................... int1 s, flag;
....................
.................... s = 0;
.................... flag = 0;
.................... y = x;
....................
.................... if (x < 0)
.................... {
.................... s = 1;
.................... y = -y;
.................... }
....................
.................... if (y > 1.0)
.................... {
.................... y = 1.0/y;
.................... flag = 1;
.................... }
....................
.................... res = pat[0]*y*y + pat[1];
.................... res = res*y*y + pat[2];
.................... res = res*y*y + pat[3];
....................
.................... r = qat[0]*y*y + qat[1];
.................... r = r*y*y + qat[2];
.................... r = r*y*y + qat[3];
....................
.................... res = y*res/r;
....................
....................
.................... if (flag) // for |x| > 1
.................... res = PI_DIV_BY_TWO - res;
.................... if (s)
.................... res = -res;
....................
.................... return(res);
.................... }
.................... #endif
....................
.................... /////////////////////////////////////////////////////////////////////////////
.................... // float atan2(float y, float x)
.................... /////////////////////////////////////////////////////////////////////////////
.................... // Description :computes the principal value of arc tangent of y/x, using the
.................... // signs of both the arguments to determine the quadrant of the return value
.................... // Returns : returns the arc tangent of y/x.
.................... // Date : N/A
.................... //
....................
.................... float32 atan2(float32 y,float32 x)
.................... {
.................... float32 z;
.................... int1 sign;
.................... unsigned int8 quad;
.................... sign=0;
.................... quad=0; //quadrant
.................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
.................... if(y<0.0)
.................... {
.................... sign=1;
.................... y=-y;
.................... }
.................... if(x<0.0)
.................... {
.................... x=-x;
.................... }
.................... if (x==0.0)
.................... {
.................... if(y==0.0)
.................... {
.................... #ifdef _ERRNO
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... }
.................... else
.................... {
.................... if(sign)
.................... {
.................... return (-(PI_DIV_BY_TWO));
.................... }
.................... else
.................... {
.................... return (PI_DIV_BY_TWO);
.................... }
.................... }
.................... }
.................... else
.................... {
.................... z=y/x;
.................... switch(quad)
.................... {
.................... case 1:
.................... {
.................... return atan(z);
.................... break;
.................... }
.................... case 2:
.................... {
.................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
.................... return (PI-atan(z));
.................... break;
.................... }
.................... case 3:
.................... {
.................... return (atan(z)-PI);
.................... break;
.................... }
.................... case 4:
.................... {
.................... return (-atan(z));
.................... break;
.................... }
.................... }
.................... }
.................... }
....................
.................... //Overloaded functions for atan2() for PCD
.................... // Overloaded function atan2() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 atan2(float48 y,float48 x)
.................... {
.................... float48 z;
.................... int1 sign;
.................... unsigned int8 quad;
.................... sign=0;
.................... quad=0; //quadrant
.................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
.................... if(y<0.0)
.................... {
.................... sign=1;
.................... y=-y;
.................... }
.................... if(x<0.0)
.................... {
.................... x=-x;
.................... }
.................... if (x==0.0)
.................... {
.................... if(y==0.0)
.................... {
.................... #ifdef _ERRNO
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... }
.................... else
.................... {
.................... if(sign)
.................... {
.................... return (-(PI_DIV_BY_TWO));
.................... }
.................... else
.................... {
.................... return (PI_DIV_BY_TWO);
.................... }
.................... }
.................... }
.................... else
.................... {
.................... z=y/x;
.................... switch(quad)
.................... {
.................... case 1:
.................... {
.................... return atan(z);
.................... break;
.................... }
.................... case 2:
.................... {
.................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
.................... return (PI-atan(z));
.................... break;
.................... }
.................... case 3:
.................... {
.................... return (atan(z)-PI);
.................... break;
.................... }
.................... case 4:
.................... {
.................... return (-atan(z));
.................... break;
.................... }
.................... }
.................... }
.................... }
....................
.................... // Overloaded function atan2() for data type - Float64
.................... float64 atan2(float64 y,float64 x)
.................... {
.................... float64 z;
.................... int1 sign;
.................... unsigned int8 quad;
.................... sign=0;
.................... quad=0; //quadrant
.................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
.................... if(y<0.0)
.................... {
.................... sign=1;
.................... y=-y;
.................... }
.................... if(x<0.0)
.................... {
.................... x=-x;
.................... }
.................... if (x==0.0)
.................... {
.................... if(y==0.0)
.................... {
.................... #ifdef _ERRNO
.................... {
.................... errno=EDOM;
.................... }
.................... #endif
.................... }
.................... else
.................... {
.................... if(sign)
.................... {
.................... return (-(PI_DIV_BY_TWO));
.................... }
.................... else
.................... {
.................... return (PI_DIV_BY_TWO);
.................... }
.................... }
.................... }
.................... else
.................... {
.................... z=y/x;
.................... switch(quad)
.................... {
.................... case 1:
.................... {
.................... return atan(z);
.................... break;
.................... }
.................... case 2:
.................... {
.................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
.................... return (PI-atan(z));
.................... break;
.................... }
.................... case 3:
.................... {
.................... return (atan(z)-PI);
.................... break;
.................... }
.................... case 4:
.................... {
.................... return (-atan(z));
.................... break;
.................... }
.................... }
.................... }
.................... }
.................... #endif
....................
.................... //////////////////// Hyperbolic functions ////////////////////
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float cosh(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : Computes the hyperbolic cosine value of x
.................... // Returns : returns the hyperbolic cosine value of x
.................... // Date : N/A
.................... //
....................
.................... float32 cosh(float32 x)
.................... {
.................... return ((exp(x)+exp(-x))/2);
.................... }
.................... //Overloaded functions for cosh() for PCD
.................... // Overloaded function cosh() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 cosh(float48 x)
.................... {
.................... return ((exp(x)+exp(-x))/2);
.................... }
....................
.................... // Overloaded function cosh() for data type - Float64
.................... float64 cosh(float64 x)
.................... {
.................... return ((exp(x)+exp(-x))/2);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float sinh(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : Computes the hyperbolic sine value of x
.................... // Returns : returns the hyperbolic sine value of x
.................... // Date : N/A
.................... //
....................
.................... float32 sinh(float32 x)
.................... {
....................
.................... return ((exp(x) - exp(-x))/2);
.................... }
.................... //Overloaded functions for sinh() for PCD
.................... // Overloaded function sinh() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 sinh(float48 x)
.................... {
....................
.................... return ((exp(x) - exp(-x))/2);
.................... }
....................
.................... // Overloaded function sinh() for data type - Float48
.................... float64 sinh(float64 x)
.................... {
....................
.................... return ((exp(x) - exp(-x))/2);
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float tanh(float x)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : Computes the hyperbolic tangent value of x
.................... // Returns : returns the hyperbolic tangent value of x
.................... // Date : N/A
.................... //
....................
.................... float32 tanh(float32 x)
.................... {
.................... return(sinh(x)/cosh(x));
.................... }
.................... //Overloaded functions for tanh() for PCD
.................... // Overloaded function tanh() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 tanh(float48 x)
.................... {
.................... return(sinh(x)/cosh(x));
.................... }
....................
.................... // Overloaded function tanh() for data type - Float64
.................... float64 tanh(float64 x)
.................... {
.................... return(sinh(x)/cosh(x));
.................... }
.................... #endif
....................
.................... ////////////////////////////////////////////////////////////////////////////
.................... // float frexp(float x, signed int *exp)
.................... ////////////////////////////////////////////////////////////////////////////
.................... // Description : breaks a floating point number into a normalized fraction and an integral
.................... // power of 2. It stores the integer in the signed int object pointed to by exp.
.................... // Returns : returns the value x, such that x is a double with magnitude in the interval
.................... // [1/2,1) or zero, and value equals x times 2 raised to the power *exp.If value is zero,
.................... // both parts of the result are zero.
.................... // Date : N/A
.................... //
....................
.................... #define LOG2 .30102999566398119521
.................... float32 frexp(float32 x, signed int8 *exp)
.................... {
.................... float32 res;
.................... int1 sign = 0;
.................... if(x == 0.0)
.................... {
.................... *exp=0;
.................... return (0.0);
.................... }
.................... if(x < 0.0)
.................... {
.................... x=-x;
.................... sign=1;
.................... }
.................... if (x > 1.0)
.................... {
.................... *exp=(ceil(log10(x)/LOG2));
.................... res=x/(pow(2, *exp));
.................... if (res == 1)
.................... {
.................... *exp=*exp+1;
.................... res=.5;
.................... }
.................... }
.................... else
.................... {
.................... if(x < 0.5)
.................... {
.................... *exp=-1;
.................... res=x*2;
.................... }
.................... else
.................... {
.................... *exp=0;
.................... res=x;
.................... }
.................... }
.................... if(sign)
.................... {
.................... res=-res;
.................... }
.................... return res;
.................... }
....................
.................... //Overloaded functions for frexp() for PCD
.................... // Overloaded function frexp() for data type - Float48
.................... #if defined(__PCD__)
.................... float48 frexp(float48 x, signed int8 *exp)
.................... {
.................... float48 res;
.................... int1 sign = 0;
.................... if(x == 0.0)
.................... {
.................... *exp=0;
.................... return (0.0);
.................... }
.................... if(x < 0.0)
.................... {
.................... x=-x;
.................... sign=1;
.................... }
.................... if (x > 1.0)
.................... {
.................... *exp=(ceil(log10(x)/LOG2));
.................... res=x/(pow(2, *exp));
.................... if (res == 1)
.................... {
.................... *exp=*exp+1;
.................... res=.5;
.................... }
.................... }
.................... else
.................... {
.................... if(x < 0.5)
.................... {
.................... *exp=-1;
.................... res=x*2;
.................... }
.................... else
.................... {
.................... *exp=0;
.................... res=x;
.................... }
.................... }
.................... if(sign)
.................... {
.................... res=-res;
.................... }
.................... return res;
.................... }
....................
.................... // Overloaded function frexp() for data type - Float64
.................... float64 frexp(float64 x, signed int8 *exp)
.................... {
.................... float64 res;
.................... int1 sign = 0;
.................... if(x == 0.0)
.................... {
.................... *exp=0;
.................... return (0.0);
.................... }
.................... if(x < 0.0)
.................... {
.................... x=-x;
.................... sign=1;
.................... }
.................... if (x > 1.0)
.................... {
.................... *exp=(ceil(log10(x)/LOG2));
.................... res=x/(pow(2, *exp));
.................... if (res == 1)
.................... {
.................... *exp=*exp+1;
.................... res=.5;
.................... }
.................... }
.................... else
.................... {
.................... if(x < 0.5)
.................... {
.................... *exp=-1;
.................... res=x*2;
.................... }
.................... else
.................... {
.................... *exp=0;
.................... res=x;
.................... }
.................... }
.................... if(sign)
.................... {
.................... res=-res;
.................... }
.................... return res;
.................... }
.................... #endif
....................
.................... //////////////////////////////////////////////////////////////////////////////
.................... // float ldexp(float x, signed int *exp)
.................... //////////////////////////////////////////////////////////////////////////////
.................... // Description : multiplies a floating point number by an integral power of 2.
.................... // Returns : returns the value of x times 2 raised to the power exp.
.................... // Date : N/A
.................... //
....................
.................... float32 ldexp(float32 value, signed int8 exp)
.................... {
.................... return (value * pow(2,exp));
.................... }
.................... //Overloaded functions for ldexp() for PCD
.................... // Overloaded function ldexp() for data type - Float48
....................
.................... #if defined(__PCD__)
.................... float48 ldexp(float48 value, signed int8 exp)
.................... {
.................... return (value * pow(2,exp));
.................... }
.................... // Overloaded function ldexp() for data type - Float64
.................... float64 ldexp(float64 value, signed int8 exp)
.................... {
.................... return (value * pow(2,exp));
.................... }
.................... #endif
....................
.................... #endif
....................
....................
.................... #define AK_W 0x38 //adresa akcelerometru zápis
.................... #define AK_R 0x39 //adresa akcelerometru ètení
.................... #define AK_XH 0x01 //osa X LSB
.................... #define AK_XL 0x02 //osa X MSB
.................... #define AK_YH 0x03 //osa Y LSB
.................... #define AK_YL 0x04 //osa Y MSB
.................... #define AK_ZH 0x05 //osa Z LSB
.................... #define AK_ZL 0x06 //osa Z MSB
....................
....................
.................... //pøipojení motorù
.................... //AIN1 - pro vysku slunce
.................... #define AIN1 PIN_D0
.................... #define AIN2 PIN_D1
.................... //motor A -cerveny vodic na AOUT2
.................... //motor A -modry vodic na Aout1
....................
.................... signed int16 X, Y, Z,AX, AY, AZ;
....................
.................... void setAK (void) //nastaveni akcelerometru
.................... {
.................... i2c_start();
*
0132: BSF 03.5
0133: BSF 06.0
0134: NOP
0135: BSF 06.1
0136: NOP
0137: BCF 03.5
0138: BCF 06.0
0139: BSF 03.5
013A: BCF 06.0
013B: NOP
013C: BCF 03.5
013D: BCF 06.1
013E: BSF 03.5
013F: BCF 06.1
.................... I2C_Write(AK_W);
0140: MOVLW 38
0141: BCF 03.5
0142: MOVWF 4D
0143: CALL 0FE
.................... I2C_write(0x2A);
0144: MOVLW 2A
0145: MOVWF 4D
0146: CALL 0FE
.................... I2C_write(0x01); //nastaví aktivní stav
0147: MOVLW 01
0148: MOVWF 4D
0149: CALL 0FE
....................
.................... i2c_stop();
014A: BSF 03.5
014B: BCF 06.0
014C: NOP
014D: BSF 06.1
014E: BCF 03.5
014F: BTFSS 06.1
0150: GOTO 14F
0151: NOP
0152: GOTO 153
0153: NOP
0154: BSF 03.5
0155: BSF 06.0
0156: NOP
.................... }
0157: BCF 03.5
0158: BSF 0A.3
0159: BCF 0A.4
015A: GOTO 4DB (RETURN)
....................
.................... int16 akcele (int8 H, int8 L) //vycitani hodnot z akcelerometru
.................... {
*
018E: CLRF 49
018F: CLRF 4A
.................... unsigned int8 XL=0,XH=0;
.................... signed int16 x;
....................
.................... i2c_start();
0190: BSF 03.5
0191: BSF 06.0
0192: NOP
0193: BSF 06.1
0194: NOP
0195: BCF 03.5
0196: BCF 06.0
0197: BSF 03.5
0198: BCF 06.0
0199: NOP
019A: BCF 03.5
019B: BCF 06.1
019C: BSF 03.5
019D: BCF 06.1
.................... I2C_Write(AK_W);
019E: MOVLW 38
019F: BCF 03.5
01A0: MOVWF 4D
01A1: CALL 0FE
.................... I2C_write(H);
01A2: MOVF 47,W
01A3: MOVWF 4D
01A4: CALL 0FE
.................... i2c_start();
01A5: BSF 03.5
01A6: BSF 06.0
01A7: NOP
01A8: BSF 06.1
01A9: NOP
01AA: BCF 03.5
01AB: BTFSS 06.1
01AC: GOTO 1AB
01AD: BCF 06.0
01AE: BSF 03.5
01AF: BCF 06.0
01B0: NOP
01B1: BCF 03.5
01B2: BCF 06.1
01B3: BSF 03.5
01B4: BCF 06.1
.................... I2C_Write(AK_R);
01B5: MOVLW 39
01B6: BCF 03.5
01B7: MOVWF 4D
01B8: CALL 0FE
.................... XH=i2c_read(0);
01B9: CLRF 77
01BA: CALL 15B
01BB: MOVF 78,W
01BC: MOVWF 4A
.................... i2c_stop();
01BD: BSF 03.5
01BE: BCF 06.0
01BF: NOP
01C0: BSF 06.1
01C1: BCF 03.5
01C2: BTFSS 06.1
01C3: GOTO 1C2
01C4: NOP
01C5: GOTO 1C6
01C6: NOP
01C7: BSF 03.5
01C8: BSF 06.0
01C9: NOP
....................
.................... i2c_start();
01CA: BSF 06.0
01CB: NOP
01CC: BSF 06.1
01CD: NOP
01CE: BCF 03.5
01CF: BCF 06.0
01D0: BSF 03.5
01D1: BCF 06.0
01D2: NOP
01D3: BCF 03.5
01D4: BCF 06.1
01D5: BSF 03.5
01D6: BCF 06.1
.................... I2C_Write(AK_W);
01D7: MOVLW 38
01D8: BCF 03.5
01D9: MOVWF 4D
01DA: CALL 0FE
.................... I2C_write(L);
01DB: MOVF 48,W
01DC: MOVWF 4D
01DD: CALL 0FE
.................... i2c_start();
01DE: BSF 03.5
01DF: BSF 06.0
01E0: NOP
01E1: BSF 06.1
01E2: NOP
01E3: BCF 03.5
01E4: BTFSS 06.1
01E5: GOTO 1E4
01E6: BCF 06.0
01E7: BSF 03.5
01E8: BCF 06.0
01E9: NOP
01EA: BCF 03.5
01EB: BCF 06.1
01EC: BSF 03.5
01ED: BCF 06.1
.................... I2C_Write(AK_R);
01EE: MOVLW 39
01EF: BCF 03.5
01F0: MOVWF 4D
01F1: CALL 0FE
.................... XL=i2c_read(0);
01F2: CLRF 77
01F3: CALL 15B
01F4: MOVF 78,W
01F5: MOVWF 49
.................... i2c_stop();
01F6: BSF 03.5
01F7: BCF 06.0
01F8: NOP
01F9: BSF 06.1
01FA: BCF 03.5
01FB: BTFSS 06.1
01FC: GOTO 1FB
01FD: NOP
01FE: GOTO 1FF
01FF: NOP
0200: BSF 03.5
0201: BSF 06.0
0202: NOP
....................
.................... x = (((unsigned int16) XH << 8) + XL ); //prevod na 16bit hodnotu
0203: BCF 03.5
0204: CLRF 4E
0205: MOVF 4A,W
0206: MOVWF 4D
0207: MOVWF 4E
0208: CLRF 4D
0209: MOVF 49,W
020A: ADDWF 4D,W
020B: MOVWF 78
020C: MOVF 4E,W
020D: MOVWF 7A
020E: BTFSC 03.0
020F: INCF 7A,F
0210: MOVF 78,W
0211: MOVWF 4B
0212: MOVF 7A,W
0213: MOVWF 4C
.................... x=x/4;
0214: MOVF 4C,W
0215: MOVWF 4E
0216: MOVF 4B,W
0217: MOVWF 4D
0218: CLRF 50
0219: MOVLW 04
021A: MOVWF 4F
*
0258: MOVF 79,W
0259: MOVWF 4C
025A: MOVF 78,W
025B: MOVWF 4B
....................
.................... return x;
025C: MOVF 4B,W
025D: MOVWF 78
025E: MOVF 4C,W
025F: MOVWF 79
.................... }
0260: RETURN
....................
.................... float vyska_sl (void) //vypocet aktualni vysky panelu
.................... {
.................... X= akcele (AK_XH, AK_XL);
*
0800: MOVLW 01
0801: MOVWF 47
0802: MOVLW 02
0803: MOVWF 48
0804: BCF 0A.3
0805: CALL 18E
0806: BSF 0A.3
0807: MOVF 79,W
0808: MOVWF 21
0809: MOVF 78,W
080A: MOVWF 20
.................... Y= akcele (AK_YH, AK_YL);
080B: MOVLW 03
080C: MOVWF 47
080D: MOVLW 04
080E: MOVWF 48
080F: BCF 0A.3
0810: CALL 18E
0811: BSF 0A.3
0812: MOVF 79,W
0813: MOVWF 23
0814: MOVF 78,W
0815: MOVWF 22
.................... Z= akcele (AK_ZH, AK_ZL);
0816: MOVLW 05
0817: MOVWF 47
0818: MOVLW 06
0819: MOVWF 48
081A: BCF 0A.3
081B: CALL 18E
081C: BSF 0A.3
081D: MOVF 79,W
081E: MOVWF 25
081F: MOVF 78,W
0820: MOVWF 24
....................
.................... AX=abs(X);
0821: MOVF 21,W
0822: MOVWF 7A
0823: MOVF 20,W
0824: BTFSS 21.7
0825: GOTO 02F
0826: MOVF 20,W
0827: SUBLW 00
0828: MOVWF 77
0829: CLRF 7A
082A: MOVF 21,W
082B: BTFSS 03.0
082C: INCFSZ 21,W
082D: SUBWF 7A,F
082E: MOVF 77,W
082F: MOVWF 26
0830: MOVF 7A,W
0831: MOVWF 27
.................... AY=abs(Y)+250;
0832: MOVF 23,W
0833: MOVWF 7A
0834: MOVF 22,W
0835: BTFSS 23.7
0836: GOTO 040
0837: MOVF 22,W
0838: SUBLW 00
0839: MOVWF 77
083A: CLRF 7A
083B: MOVF 23,W
083C: BTFSS 03.0
083D: INCFSZ 23,W
083E: SUBWF 7A,F
083F: MOVF 77,W
0840: MOVWF 47
0841: MOVF 7A,W
0842: MOVWF 48
0843: MOVLW FA
0844: ADDWF 47,W
0845: MOVWF 28
0846: MOVF 48,W
0847: MOVWF 29
0848: BTFSC 03.0
0849: INCF 29,F
.................... AZ=abs(Z)+250;
084A: MOVF 25,W
084B: MOVWF 7A
084C: MOVF 24,W
084D: BTFSS 25.7
084E: GOTO 058
084F: MOVF 24,W
0850: SUBLW 00
0851: MOVWF 77
0852: CLRF 7A
0853: MOVF 25,W
0854: BTFSS 03.0
0855: INCFSZ 25,W
0856: SUBWF 7A,F
0857: MOVF 77,W
0858: MOVWF 47
0859: MOVF 7A,W
085A: MOVWF 48
085B: MOVLW FA
085C: ADDWF 47,W
085D: MOVWF 2A
085E: MOVF 48,W
085F: MOVWF 2B
0860: BTFSC 03.0
0861: INCF 2B,F
....................
.................... float a, b;
.................... a=(float)Y/Z;
0862: MOVF 23,W
0863: MOVWF 4C
0864: MOVF 22,W
0865: MOVWF 4B
0866: BCF 0A.3
0867: CALL 344
0868: BSF 0A.3
0869: MOVF 77,W
086A: MOVWF 47
086B: MOVF 78,W
086C: MOVWF 48
086D: MOVF 79,W
086E: MOVWF 49
086F: MOVF 7A,W
0870: MOVWF 4A
0871: MOVF 25,W
0872: MOVWF 4C
0873: MOVF 24,W
0874: MOVWF 4B
0875: BCF 0A.3
0876: CALL 344
0877: BSF 0A.3
0878: MOVF 4A,W
0879: MOVWF 5F
087A: MOVF 49,W
087B: MOVWF 5E
087C: MOVF 48,W
087D: MOVWF 5D
087E: MOVF 47,W
087F: MOVWF 5C
0880: MOVF 7A,W
0881: MOVWF 63
0882: MOVF 79,W
0883: MOVWF 62
0884: MOVF 78,W
0885: MOVWF 61
0886: MOVF 77,W
0887: MOVWF 60
0888: BCF 0A.3
0889: CALL 369
088A: BSF 0A.3
088B: MOVF 7A,W
088C: MOVWF 42
088D: MOVF 79,W
088E: MOVWF 41
088F: MOVF 78,W
0890: MOVWF 40
0891: MOVF 77,W
0892: MOVWF 3F
.................... b=atan(a);
0893: MOVF 42,W
0894: MOVWF 4A
0895: MOVF 41,W
0896: MOVWF 49
0897: MOVF 40,W
0898: MOVWF 48
0899: MOVF 3F,W
089A: MOVWF 47
*
0B28: MOVF 7A,W
0B29: MOVWF 46
0B2A: MOVF 79,W
0B2B: MOVWF 45
0B2C: MOVF 78,W
0B2D: MOVWF 44
0B2E: MOVF 77,W
0B2F: MOVWF 43
.................... b = (b/3.14)*180;
0B30: MOVF 46,W
0B31: MOVWF 5F
0B32: MOVF 45,W
0B33: MOVWF 5E
0B34: MOVF 44,W
0B35: MOVWF 5D
0B36: MOVF 43,W
0B37: MOVWF 5C
0B38: MOVLW C3
0B39: MOVWF 63
0B3A: MOVLW F5
0B3B: MOVWF 62
0B3C: MOVLW 48
0B3D: MOVWF 61
0B3E: MOVLW 80
0B3F: MOVWF 60
0B40: BCF 0A.3
0B41: CALL 369
0B42: BSF 0A.3
0B43: MOVF 77,W
0B44: MOVWF 47
0B45: MOVF 78,W
0B46: MOVWF 48
0B47: MOVF 79,W
0B48: MOVWF 49
0B49: MOVF 7A,W
0B4A: MOVWF 4A
0B4B: MOVWF 5F
0B4C: MOVF 49,W
0B4D: MOVWF 5E
0B4E: MOVF 48,W
0B4F: MOVWF 5D
0B50: MOVF 47,W
0B51: MOVWF 5C
0B52: CLRF 63
0B53: CLRF 62
0B54: MOVLW 34
0B55: MOVWF 61
0B56: MOVLW 86
0B57: MOVWF 60
0B58: BCF 0A.3
0B59: CALL 472
0B5A: BSF 0A.3
0B5B: MOVF 7A,W
0B5C: MOVWF 46
0B5D: MOVF 79,W
0B5E: MOVWF 45
0B5F: MOVF 78,W
0B60: MOVWF 44
0B61: MOVF 77,W
0B62: MOVWF 43
.................... b=abs(b);
0B63: MOVF 43,W
0B64: MOVWF 77
0B65: MOVF 44,W
0B66: MOVWF 78
0B67: MOVF 45,W
0B68: MOVWF 79
0B69: MOVF 46,W
0B6A: MOVWF 7A
0B6B: BCF 78.7
0B6C: MOVF 46,W
0B6D: MOVWF 46
0B6E: MOVF 45,W
0B6F: MOVWF 45
0B70: MOVF 78,W
0B71: MOVWF 44
0B72: MOVF 43,W
0B73: MOVWF 43
....................
.................... if(((AX>AY) || (AX>AZ))) //indikace prevraceni panelu
0B74: BTFSS 29.7
0B75: GOTO 379
0B76: BTFSS 27.7
0B77: GOTO 396
0B78: GOTO 37B
0B79: BTFSC 27.7
0B7A: GOTO 385
0B7B: MOVF 29,W
0B7C: SUBWF 27,W
0B7D: BTFSS 03.0
0B7E: GOTO 385
0B7F: BTFSS 03.2
0B80: GOTO 396
0B81: MOVF 26,W
0B82: SUBWF 28,W
0B83: BTFSS 03.0
0B84: GOTO 396
0B85: BTFSS 2B.7
0B86: GOTO 38A
0B87: BTFSS 27.7
0B88: GOTO 396
0B89: GOTO 38C
0B8A: BTFSC 27.7
0B8B: GOTO 3BF
0B8C: MOVF 2B,W
0B8D: SUBWF 27,W
0B8E: BTFSS 03.0
0B8F: GOTO 3BF
0B90: BTFSS 03.2
0B91: GOTO 396
0B92: MOVF 26,W
0B93: SUBWF 2A,W
0B94: BTFSC 03.0
0B95: GOTO 3BF
.................... {
.................... printf("Prevracený panel)\r\n", );
0B96: MOVLW 04
0B97: BSF 03.6
0B98: MOVWF 0D
0B99: MOVLW 00
0B9A: MOVWF 0F
.................... }
.................... else
*
0BBD: GOTO 453
0BBE: BCF 03.6
.................... {
.................... if(Z==0) //osetreni proti deleni 0
0BBF: MOVF 24,F
0BC0: BTFSS 03.2
0BC1: GOTO 3DA
0BC2: MOVF 25,F
0BC3: BTFSS 03.2
0BC4: GOTO 3DA
.................... {
.................... if(Y>0)
0BC5: BTFSC 23.7
0BC6: GOTO 3D5
0BC7: MOVF 23,F
0BC8: BTFSS 03.2
0BC9: GOTO 3CE
0BCA: MOVF 22,W
0BCB: SUBLW 00
0BCC: BTFSC 03.0
0BCD: GOTO 3D5
.................... {
.................... b=180;
0BCE: CLRF 46
0BCF: CLRF 45
0BD0: MOVLW 34
0BD1: MOVWF 44
0BD2: MOVLW 86
0BD3: MOVWF 43
.................... }
.................... else
0BD4: GOTO 3D9
.................... {
.................... b=0;
0BD5: CLRF 46
0BD6: CLRF 45
0BD7: CLRF 44
0BD8: CLRF 43
.................... }
.................... }
.................... else
0BD9: GOTO 452
.................... {
.................... if(Z>0)
0BDA: BTFSC 25.7
0BDB: GOTO 41B
0BDC: MOVF 25,F
0BDD: BTFSS 03.2
0BDE: GOTO 3E3
0BDF: MOVF 24,W
0BE0: SUBLW 00
0BE1: BTFSC 03.0
0BE2: GOTO 41B
.................... {
.................... if(Y>=0)
0BE3: BTFSC 23.7
0BE4: GOTO 400
.................... {
.................... b=90+b;
0BE5: BCF 03.1
0BE6: CLRF 5F
0BE7: CLRF 5E
0BE8: MOVLW 34
0BE9: MOVWF 5D
0BEA: MOVLW 85
0BEB: MOVWF 5C
0BEC: MOVF 46,W
0BED: MOVWF 63
0BEE: MOVF 45,W
0BEF: MOVWF 62
0BF0: MOVF 44,W
0BF1: MOVWF 61
0BF2: MOVF 43,W
0BF3: MOVWF 60
0BF4: BCF 0A.3
0BF5: CALL 4E7
0BF6: BSF 0A.3
0BF7: MOVF 7A,W
0BF8: MOVWF 46
0BF9: MOVF 79,W
0BFA: MOVWF 45
0BFB: MOVF 78,W
0BFC: MOVWF 44
0BFD: MOVF 77,W
0BFE: MOVWF 43
.................... }
.................... else
0BFF: GOTO 41A
.................... {
.................... b=90-b;
0C00: BSF 03.1
0C01: CLRF 5F
0C02: CLRF 5E
0C03: MOVLW 34
0C04: MOVWF 5D
0C05: MOVLW 85
0C06: MOVWF 5C
0C07: MOVF 46,W
0C08: MOVWF 63
0C09: MOVF 45,W
0C0A: MOVWF 62
0C0B: MOVF 44,W
0C0C: MOVWF 61
0C0D: MOVF 43,W
0C0E: MOVWF 60
0C0F: BCF 0A.3
0C10: CALL 4E7
0C11: BSF 0A.3
0C12: MOVF 7A,W
0C13: MOVWF 46
0C14: MOVF 79,W
0C15: MOVWF 45
0C16: MOVF 78,W
0C17: MOVWF 44
0C18: MOVF 77,W
0C19: MOVWF 43
.................... }
.................... }
.................... else
0C1A: GOTO 452
.................... {
.................... if(Y>=0)
0C1B: BTFSC 23.7
0C1C: GOTO 438
.................... {
.................... b=180-b;
0C1D: BSF 03.1
0C1E: CLRF 5F
0C1F: CLRF 5E
0C20: MOVLW 34
0C21: MOVWF 5D
0C22: MOVLW 86
0C23: MOVWF 5C
0C24: MOVF 46,W
0C25: MOVWF 63
0C26: MOVF 45,W
0C27: MOVWF 62
0C28: MOVF 44,W
0C29: MOVWF 61
0C2A: MOVF 43,W
0C2B: MOVWF 60
0C2C: BCF 0A.3
0C2D: CALL 4E7
0C2E: BSF 0A.3
0C2F: MOVF 7A,W
0C30: MOVWF 46
0C31: MOVF 79,W
0C32: MOVWF 45
0C33: MOVF 78,W
0C34: MOVWF 44
0C35: MOVF 77,W
0C36: MOVWF 43
.................... }
.................... else
0C37: GOTO 452
.................... {
.................... b=270+b;
0C38: BCF 03.1
0C39: CLRF 5F
0C3A: CLRF 5E
0C3B: MOVLW 07
0C3C: MOVWF 5D
0C3D: MOVLW 87
0C3E: MOVWF 5C
0C3F: MOVF 46,W
0C40: MOVWF 63
0C41: MOVF 45,W
0C42: MOVWF 62
0C43: MOVF 44,W
0C44: MOVWF 61
0C45: MOVF 43,W
0C46: MOVWF 60
0C47: BCF 0A.3
0C48: CALL 4E7
0C49: BSF 0A.3
0C4A: MOVF 7A,W
0C4B: MOVWF 46
0C4C: MOVF 79,W
0C4D: MOVWF 45
0C4E: MOVF 78,W
0C4F: MOVWF 44
0C50: MOVF 77,W
0C51: MOVWF 43
0C52: BSF 03.6
.................... }
.................... }
....................
.................... }
....................
....................
....................
.................... }
.................... //printf("uhel namìreny %10.2f \r\n", b);
.................... return b;
0C53: BCF 03.6
0C54: MOVF 43,W
0C55: MOVWF 77
0C56: MOVF 44,W
0C57: MOVWF 78
0C58: MOVF 45,W
0C59: MOVWF 79
0C5A: MOVF 46,W
0C5B: MOVWF 7A
....................
.................... }
0C5C: RETURN
....................
.................... void motorA (int8 H) //pro ovladani prvniho motoru nastaveni vysky
.................... {
.................... switch(H){
*
00DB: MOVF 3F,W
00DC: XORLW 01
00DD: BTFSC 03.2
00DE: GOTO 0E3
00DF: XORLW 03
00E0: BTFSC 03.2
00E1: GOTO 0EC
00E2: GOTO 0F5
.................... case 1: //reverzní chod
.................... output_low (AIN2);
00E3: BSF 03.5
00E4: BCF 08.1
00E5: BCF 03.5
00E6: BCF 08.1
.................... output_high (AIN1);
00E7: BSF 03.5
00E8: BCF 08.0
00E9: BCF 03.5
00EA: BSF 08.0
.................... break;
00EB: GOTO 0FD
....................
.................... case 2: //dopøedu
.................... output_low (AIN1);
00EC: BSF 03.5
00ED: BCF 08.0
00EE: BCF 03.5
00EF: BCF 08.0
.................... output_high (AIN2);
00F0: BSF 03.5
00F1: BCF 08.1
00F2: BCF 03.5
00F3: BSF 08.1
.................... break;
00F4: GOTO 0FD
....................
.................... default:
.................... output_low (AIN2);
00F5: BSF 03.5
00F6: BCF 08.1
00F7: BCF 03.5
00F8: BCF 08.1
.................... output_low (AIN1);
00F9: BSF 03.5
00FA: BCF 08.0
00FB: BCF 03.5
00FC: BCF 08.0
.................... }
.................... }
00FD: RETURN
....................
.................... void uhel (int8 H) //slouzi pro nastaveni nove vysky panelu
.................... {
.................... float a;
.................... int16 b,c;
....................
.................... a=vyska_sl();
*
0668: BSF 0A.3
0669: CALL 000
066A: BCF 0A.3
066B: MOVF 7A,W
066C: MOVWF 3A
066D: MOVF 79,W
066E: MOVWF 39
066F: MOVF 78,W
0670: MOVWF 38
0671: MOVF 77,W
0672: MOVWF 37
.................... b= (int16) a;
0673: MOVF 3A,W
0674: MOVWF 42
0675: MOVF 39,W
0676: MOVWF 41
0677: MOVF 38,W
0678: MOVWF 40
0679: MOVF 37,W
067A: MOVWF 3F
067B: CALL 628
067C: MOVF 79,W
067D: MOVWF 3C
067E: MOVF 78,W
067F: MOVWF 3B
.................... //printf("auhel pro mereni: %Ld(procenta)\r\n", b);
.................... if(b>350)
0680: MOVF 3C,W
0681: SUBLW 00
0682: BTFSC 03.0
0683: GOTO 68E
0684: XORLW FF
0685: BTFSS 03.2
0686: GOTO 68B
0687: MOVF 3B,W
0688: SUBLW 5E
0689: BTFSC 03.0
068A: GOTO 68E
.................... {
.................... b=0;
068B: CLRF 3C
068C: CLRF 3B
.................... }
.................... else
068D: GOTO 68E
.................... {
....................
.................... }
.................... c=abs(H-b);
068E: MOVF 3B,W
068F: SUBWF 36,W
0690: MOVWF 3F
0691: CLRF 40
0692: MOVF 3C,W
0693: BTFSS 03.0
0694: INCFSZ 3C,W
0695: SUBWF 40,F
0696: MOVF 40,W
0697: MOVWF 3E
0698: MOVF 3F,W
0699: MOVWF 3D
....................
.................... while(c>2) //maximalni odchylka uhlu, aby nebylo potreba panelem hybat
.................... {
069A: MOVF 3E,F
069B: BTFSS 03.2
069C: GOTO 6A1
069D: MOVF 3D,W
069E: SUBLW 02
069F: BTFSC 03.0
06A0: GOTO 6F3
.................... while(H!=b) //probiha dokud se uhel panelu nerovna zadanemu na cele stupne
.................... {
06A1: MOVF 3B,W
06A2: SUBWF 36,W
06A3: BTFSS 03.2
06A4: GOTO 6A8
06A5: MOVF 3C,F
06A6: BTFSC 03.2
06A7: GOTO 6F2
.................... //printf("aktualni uhel: %Ld(procenta)\r\n", b);
.................... //printf("zadane nastavení: %d(procenta)\r\n", H);
.................... if(H>b)
06A8: MOVF 3C,F
06A9: BTFSS 03.2
06AA: GOTO 6B3
06AB: MOVF 36,W
06AC: SUBWF 3B,W
06AD: BTFSC 03.0
06AE: GOTO 6B3
.................... {
.................... motorA(2);
06AF: MOVLW 02
06B0: MOVWF 3F
06B1: CALL 0DB
.................... //printf("zmotor2í: \r\n", );
.................... }
.................... else
06B2: GOTO 6B6
.................... {
.................... motorA(1);
06B3: MOVLW 01
06B4: MOVWF 3F
06B5: CALL 0DB
.................... }
....................
.................... delay_ms (50); //cas sepnuti motoru
06B6: MOVLW 32
06B7: MOVWF 3F
06B8: CALL 330
....................
.................... motorA(3); //vypne motor
06B9: MOVLW 03
06BA: MOVWF 3F
06BB: CALL 0DB
.................... delay_ms (50); //doma na ustaleni panelu pred merenim
06BC: MOVLW 32
06BD: MOVWF 3F
06BE: CALL 330
.................... a=vyska_sl();
06BF: BSF 0A.3
06C0: CALL 000
06C1: BCF 0A.3
06C2: MOVF 7A,W
06C3: MOVWF 3A
06C4: MOVF 79,W
06C5: MOVWF 39
06C6: MOVF 78,W
06C7: MOVWF 38
06C8: MOVF 77,W
06C9: MOVWF 37
.................... b= (int16) a;
06CA: MOVF 3A,W
06CB: MOVWF 42
06CC: MOVF 39,W
06CD: MOVWF 41
06CE: MOVF 38,W
06CF: MOVWF 40
06D0: MOVF 37,W
06D1: MOVWF 3F
06D2: CALL 628
06D3: MOVF 79,W
06D4: MOVWF 3C
06D5: MOVF 78,W
06D6: MOVWF 3B
.................... //printf("auhel pro mereni: %Ld(procenta)\r\n", b);
.................... if(b>350) //osetreni pro uhel 0. Zabezpeci ze neprejde stav z 0 na 359 kdy by se solar zacal tocit na druhou stranu
06D7: MOVF 3C,W
06D8: SUBLW 00
06D9: BTFSC 03.0
06DA: GOTO 6E5
06DB: XORLW FF
06DC: BTFSS 03.2
06DD: GOTO 6E2
06DE: MOVF 3B,W
06DF: SUBLW 5E
06E0: BTFSC 03.0
06E1: GOTO 6E5
.................... {
.................... b=0;
06E2: CLRF 3C
06E3: CLRF 3B
.................... }
.................... else
06E4: GOTO 6E5
.................... {
.................... b=b;
.................... }
.................... c=abs(H-b);
06E5: MOVF 3B,W
06E6: SUBWF 36,W
06E7: MOVWF 3F
06E8: CLRF 40
06E9: MOVF 3C,W
06EA: BTFSS 03.0
06EB: INCFSZ 3C,W
06EC: SUBWF 40,F
06ED: MOVF 40,W
06EE: MOVWF 3E
06EF: MOVF 3F,W
06F0: MOVWF 3D
.................... }
06F1: GOTO 6A1
.................... }
06F2: GOTO 69A
.................... motorA(3); //vypne motor
06F3: MOVLW 03
06F4: MOVWF 3F
06F5: CALL 0DB
.................... printf("Podaøené nastavení: %Ld\r\n", b);
06F6: MOVLW 18
06F7: BSF 03.6
06F8: MOVWF 0D
06F9: MOVLW 00
06FA: MOVWF 0F
06FB: MOVLW 14
06FC: BCF 03.6
06FD: MOVWF 3F
06FE: CALL 647
06FF: MOVLW 10
0700: MOVWF 04
0701: MOVF 3C,W
0702: MOVWF 40
0703: MOVF 3B,W
0704: MOVWF 3F
0705: CALL 2B0
0706: MOVLW 0D
0707: MOVWF 49
0708: CALL 071
0709: MOVLW 0A
070A: MOVWF 49
070B: CALL 071
.................... }
070C: BSF 0A.3
070D: BCF 0A.4
070E: GOTO 577 (RETURN)
....................
....................
....................
....................
.................... void main()
.................... {
*
0C5D: CLRF 04
0C5E: BCF 03.7
0C5F: MOVLW 1F
0C60: ANDWF 03,F
0C61: MOVLW 71
0C62: BSF 03.5
0C63: MOVWF 0F
0C64: MOVF 0F,W
0C65: BCF 06.3
0C66: BCF 03.5
0C67: BSF 06.3
0C68: BSF 03.5
0C69: BSF 03.6
0C6A: MOVF 09,W
0C6B: ANDLW C0
0C6C: MOVWF 09
0C6D: BCF 03.6
0C6E: BCF 1F.4
0C6F: BCF 1F.5
0C70: MOVLW 00
0C71: BSF 03.6
0C72: MOVWF 08
0C73: BCF 03.5
0C74: CLRF 07
0C75: CLRF 08
0C76: CLRF 09
....................
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
*
0C7A: BSF 03.5
0C7B: BSF 03.6
0C7C: MOVF 09,W
0C7D: ANDLW C0
0C7E: MOVWF 09
0C7F: BCF 03.6
0C80: BCF 1F.4
0C81: BCF 1F.5
0C82: MOVLW 00
0C83: BSF 03.6
0C84: MOVWF 08
.................... setup_adc(ADC_CLOCK_DIV_2);
0C85: BCF 03.5
0C86: BCF 03.6
0C87: BCF 1F.6
0C88: BCF 1F.7
0C89: BSF 03.5
0C8A: BCF 1F.7
0C8B: BCF 03.5
0C8C: BSF 1F.0
.................... setup_spi(SPI_SS_DISABLED);
0C8D: BCF 14.5
0C8E: BCF 2C.5
0C8F: MOVF 2C,W
0C90: BSF 03.5
0C91: MOVWF 07
0C92: BCF 03.5
0C93: BSF 2C.4
0C94: MOVF 2C,W
0C95: BSF 03.5
0C96: MOVWF 07
0C97: BCF 03.5
0C98: BCF 2C.3
0C99: MOVF 2C,W
0C9A: BSF 03.5
0C9B: MOVWF 07
0C9C: MOVLW 01
0C9D: BCF 03.5
0C9E: MOVWF 14
0C9F: MOVLW 00
0CA0: BSF 03.5
0CA1: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
0CA2: MOVF 01,W
0CA3: ANDLW C7
0CA4: IORLW 08
0CA5: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
0CA6: BCF 03.5
0CA7: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
0CA8: MOVLW 00
0CA9: MOVWF 78
0CAA: MOVWF 12
0CAB: MOVLW 00
0CAC: BSF 03.5
0CAD: MOVWF 12
.................... setup_ccp1(CCP_OFF);
0CAE: BCF 03.5
0CAF: BSF 2C.2
0CB0: MOVF 2C,W
0CB1: BSF 03.5
0CB2: MOVWF 07
0CB3: BCF 03.5
0CB4: CLRF 17
0CB5: BSF 03.5
0CB6: CLRF 1B
0CB7: CLRF 1C
0CB8: MOVLW 01
0CB9: MOVWF 1D
.................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
0CBA: BCF 03.5
0CBB: BSF 03.6
0CBC: CLRF 07
0CBD: CLRF 08
0CBE: CLRF 09
....................
.................... setup_adc_ports(PIN_A0); //piny pro A/D RA0
0CBF: BSF 03.5
0CC0: MOVF 09,W
0CC1: ANDLW C0
0CC2: MOVWF 09
0CC3: BCF 03.6
0CC4: BCF 1F.4
0CC5: BCF 1F.5
0CC6: MOVLW 28
0CC7: BSF 03.6
0CC8: MOVWF 08
....................
.................... printf("Akcelerometr: \r\n",);
0CC9: MOVLW 32
0CCA: BCF 03.5
0CCB: MOVWF 0D
0CCC: MOVLW 00
0CCD: MOVWF 0F
0CCE: BCF 0A.3
0CCF: BCF 03.6
0CD0: GOTO 093
0CD1: BSF 0A.3
....................
.................... motorA(3);
0CD2: MOVLW 03
0CD3: MOVWF 3F
0CD4: BCF 0A.3
0CD5: CALL 0DB
0CD6: BSF 0A.3
....................
.................... float a, b;
.................... unsigned int value1=10;
0CD7: MOVLW 0A
0CD8: MOVWF 35
....................
....................
.................... setAK(); //nastaveni akcelerometru
0CD9: BCF 0A.3
0CDA: GOTO 132
0CDB: BSF 0A.3
....................
.................... while(TRUE)
.................... {
....................
.................... X= akcele (AK_XH, AK_XL);
0CDC: MOVLW 01
0CDD: MOVWF 47
0CDE: MOVLW 02
0CDF: MOVWF 48
0CE0: BCF 0A.3
0CE1: CALL 18E
0CE2: BSF 0A.3
0CE3: MOVF 79,W
0CE4: MOVWF 21
0CE5: MOVF 78,W
0CE6: MOVWF 20
.................... Y= akcele (AK_YH, AK_YL);
0CE7: MOVLW 03
0CE8: MOVWF 47
0CE9: MOVLW 04
0CEA: MOVWF 48
0CEB: BCF 0A.3
0CEC: CALL 18E
0CED: BSF 0A.3
0CEE: MOVF 79,W
0CEF: MOVWF 23
0CF0: MOVF 78,W
0CF1: MOVWF 22
.................... Z= akcele (AK_ZH, AK_ZL);
0CF2: MOVLW 05
0CF3: MOVWF 47
0CF4: MOVLW 06
0CF5: MOVWF 48
0CF6: BCF 0A.3
0CF7: CALL 18E
0CF8: BSF 0A.3
0CF9: MOVF 79,W
0CFA: MOVWF 25
0CFB: MOVF 78,W
0CFC: MOVWF 24
....................
.................... printf("Stav X: %Ld(procenta)\r\n", X);
0CFD: MOVLW 3B
0CFE: BSF 03.6
0CFF: MOVWF 0D
0D00: MOVLW 00
0D01: MOVWF 0F
0D02: BCF 03.0
0D03: MOVLW 08
0D04: BCF 03.6
0D05: MOVWF 36
0D06: BCF 0A.3
0D07: CALL 261
0D08: BSF 0A.3
0D09: MOVLW 10
0D0A: MOVWF 04
0D0B: MOVF 21,W
0D0C: MOVWF 40
0D0D: MOVF 20,W
0D0E: MOVWF 3F
0D0F: BCF 0A.3
0D10: CALL 2B0
0D11: BSF 0A.3
0D12: MOVLW 40
0D13: BSF 03.6
0D14: MOVWF 0D
0D15: MOVLW 00
0D16: MOVWF 0F
0D17: BSF 03.0
0D18: MOVLW 0C
0D19: BCF 03.6
0D1A: MOVWF 36
0D1B: BCF 0A.3
0D1C: CALL 261
0D1D: BSF 0A.3
.................... printf("Stav Y: %Ld(procenta)\r\n", Y);
0D1E: MOVLW 47
0D1F: BSF 03.6
0D20: MOVWF 0D
0D21: MOVLW 00
0D22: MOVWF 0F
0D23: BCF 03.0
0D24: MOVLW 08
0D25: BCF 03.6
0D26: MOVWF 36
0D27: BCF 0A.3
0D28: CALL 261
0D29: BSF 0A.3
0D2A: MOVLW 10
0D2B: MOVWF 04
0D2C: MOVF 23,W
0D2D: MOVWF 40
0D2E: MOVF 22,W
0D2F: MOVWF 3F
0D30: BCF 0A.3
0D31: CALL 2B0
0D32: BSF 0A.3
0D33: MOVLW 4C
0D34: BSF 03.6
0D35: MOVWF 0D
0D36: MOVLW 00
0D37: MOVWF 0F
0D38: BSF 03.0
0D39: MOVLW 0C
0D3A: BCF 03.6
0D3B: MOVWF 36
0D3C: BCF 0A.3
0D3D: CALL 261
0D3E: BSF 0A.3
.................... printf("Stav Z: %Ld(procenta)\r\n", Z);
0D3F: MOVLW 53
0D40: BSF 03.6
0D41: MOVWF 0D
0D42: MOVLW 00
0D43: MOVWF 0F
0D44: BCF 03.0
0D45: MOVLW 08
0D46: BCF 03.6
0D47: MOVWF 36
0D48: BCF 0A.3
0D49: CALL 261
0D4A: BSF 0A.3
0D4B: MOVLW 10
0D4C: MOVWF 04
0D4D: MOVF 25,W
0D4E: MOVWF 40
0D4F: MOVF 24,W
0D50: MOVWF 3F
0D51: BCF 0A.3
0D52: CALL 2B0
0D53: BSF 0A.3
0D54: MOVLW 58
0D55: BSF 03.6
0D56: MOVWF 0D
0D57: MOVLW 00
0D58: MOVWF 0F
0D59: BSF 03.0
0D5A: MOVLW 0C
0D5B: BCF 03.6
0D5C: MOVWF 36
0D5D: BCF 0A.3
0D5E: CALL 261
0D5F: BSF 0A.3
....................
....................
....................
....................
....................
....................
.................... set_adc_channel(0); //nastavi AD na kanál 0 (RA0)
0D60: MOVLW 00
0D61: MOVWF 78
0D62: MOVF 1F,W
0D63: ANDLW C3
0D64: IORWF 78,W
0D65: MOVWF 1F
.................... read_adc(ADC_START_ONLY); // Spustime A/D prevod
0D66: BSF 1F.1
.................... Delay_ms(1);
0D67: MOVLW 01
0D68: MOVWF 3F
0D69: BCF 0A.3
0D6A: CALL 330
0D6B: BSF 0A.3
.................... while(!adc_done()); // Cekame na dokonceni prevodu
0D6C: BTFSC 1F.1
0D6D: GOTO 56C
.................... value1=read_adc(); // Precteme hodnotu z prevodniku
0D6E: BSF 1F.1
0D6F: BTFSC 1F.1
0D70: GOTO 56F
0D71: MOVF 1E,W
0D72: MOVWF 35
.................... uhel (value1);
0D73: MOVF 35,W
0D74: MOVWF 36
0D75: BCF 0A.3
0D76: GOTO 668
0D77: BSF 0A.3
.................... printf("zadaný uhel %d \r\n", value1);
0D78: MOVLW 5F
0D79: BSF 03.6
0D7A: MOVWF 0D
0D7B: MOVLW 00
0D7C: MOVWF 0F
0D7D: MOVLW 0C
0D7E: BCF 03.6
0D7F: MOVWF 3F
0D80: BCF 0A.3
0D81: CALL 647
0D82: BSF 0A.3
0D83: MOVF 35,W
0D84: MOVWF 36
0D85: MOVLW 1F
0D86: MOVWF 37
0D87: BCF 0A.3
0D88: GOTO 724
0D89: BSF 0A.3
0D8A: MOVLW 20
0D8B: MOVWF 49
0D8C: BCF 0A.3
0D8D: CALL 071
0D8E: BSF 0A.3
0D8F: MOVLW 0D
0D90: MOVWF 49
0D91: BCF 0A.3
0D92: CALL 071
0D93: BSF 0A.3
0D94: MOVLW 0A
0D95: MOVWF 49
0D96: BCF 0A.3
0D97: CALL 071
0D98: BSF 0A.3
....................
....................
....................
....................
....................
.................... delay_ms (2000);
0D99: MOVLW 08
0D9A: MOVWF 36
0D9B: MOVLW FA
0D9C: MOVWF 3F
0D9D: BCF 0A.3
0D9E: CALL 330
0D9F: BSF 0A.3
0DA0: DECFSZ 36,F
0DA1: GOTO 59B
....................
....................
.................... }
0DA2: GOTO 4DC
.................... }
....................
0DA3: SLEEP
Configuration Fuses:
Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
Word 2: 3FFF NOWRT BORV40