CCS PCM C Compiler, Version 4.106, 47914 16-4-13 20:38
Filename: C:\Users\Honza\Documents\pic\kompas\main.lst
ROM used: 3214 words (39%)
Largest free fragment is 2048
RAM used: 7 (2%) at main() level
71 (19%) worst case
Stack: 3 locations
*
0000: MOVLW 0C
0001: MOVWF 0A
0002: GOTO 42E
0003: NOP
.................... #include <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)
*
0108: MOVLW 30
0109: MOVWF 04
010A: BCF 03.7
010B: MOVF 00,W
010C: BTFSC 03.2
010D: GOTO 11B
010E: MOVLW 02
010F: MOVWF 78
0110: CLRF 77
0111: DECFSZ 77,F
0112: GOTO 111
0113: DECFSZ 78,F
0114: GOTO 110
0115: MOVLW 97
0116: MOVWF 77
0117: DECFSZ 77,F
0118: GOTO 117
0119: DECFSZ 00,F
011A: GOTO 10E
011B: RETURN
....................
....................
.................... #define EEPROM_SDA PIN_B0
.................... #define EEPROM_SCL PIN_B1
.................... #use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
*
00D4: MOVLW 08
00D5: MOVWF 78
00D6: NOP
00D7: BCF 06.1
00D8: BSF 03.5
00D9: BCF 06.1
00DA: NOP
00DB: BCF 03.5
00DC: RLF 42,F
00DD: BCF 06.0
00DE: BTFSS 03.0
00DF: GOTO 0E3
00E0: BSF 03.5
00E1: BSF 06.0
00E2: BCF 03.5
00E3: BTFSC 03.0
00E4: GOTO 0E8
00E5: BSF 03.5
00E6: BCF 06.0
00E7: BCF 03.5
00E8: BSF 03.5
00E9: BSF 06.1
00EA: BCF 03.5
00EB: BTFSS 06.1
00EC: GOTO 0EB
00ED: DECFSZ 78,F
00EE: GOTO 0D6
00EF: NOP
00F0: BCF 06.1
00F1: BSF 03.5
00F2: BCF 06.1
00F3: NOP
00F4: BSF 06.0
00F5: NOP
00F6: NOP
00F7: BSF 06.1
00F8: BCF 03.5
00F9: BTFSS 06.1
00FA: GOTO 0F9
00FB: CLRF 78
00FC: NOP
00FD: BTFSC 06.0
00FE: BSF 78.0
00FF: BCF 06.1
0100: BSF 03.5
0101: BCF 06.1
0102: BCF 03.5
0103: BCF 06.0
0104: BSF 03.5
0105: BCF 06.0
0106: BCF 03.5
0107: RETURN
*
01CC: MOVLW 08
01CD: MOVWF 43
01CE: MOVF 77,W
01CF: MOVWF 44
01D0: BSF 03.5
01D1: BSF 06.0
01D2: NOP
01D3: BSF 06.1
01D4: BCF 03.5
01D5: BTFSS 06.1
01D6: GOTO 1D5
01D7: BTFSC 06.0
01D8: BSF 03.0
01D9: BTFSS 06.0
01DA: BCF 03.0
01DB: RLF 78,F
01DC: NOP
01DD: BSF 03.5
01DE: BCF 06.1
01DF: BCF 03.5
01E0: BCF 06.1
01E1: DECFSZ 43,F
01E2: GOTO 1D0
01E3: BSF 03.5
01E4: BSF 06.0
01E5: NOP
01E6: BCF 03.5
01E7: BCF 06.0
01E8: MOVF 44,W
01E9: BTFSC 03.2
01EA: GOTO 1EE
01EB: BSF 03.5
01EC: BCF 06.0
01ED: BCF 03.5
01EE: NOP
01EF: BSF 03.5
01F0: BSF 06.1
01F1: BCF 03.5
01F2: BTFSS 06.1
01F3: GOTO 1F2
01F4: NOP
01F5: BCF 06.1
01F6: BSF 03.5
01F7: BCF 06.1
01F8: NOP
01F9: BCF 03.5
01FA: BCF 06.0
01FB: BSF 03.5
01FC: BCF 06.0
.................... #use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD
*
008D: BSF 03.5
008E: BCF 06.3
008F: BCF 03.5
0090: BCF 06.3
0091: MOVLW 08
0092: MOVWF 78
0093: GOTO 094
0094: NOP
0095: BSF 78.7
0096: GOTO 0A5
0097: BCF 78.7
0098: RRF 40,F
0099: BTFSC 03.0
009A: BSF 06.3
009B: BTFSS 03.0
009C: BCF 06.3
009D: BSF 78.6
009E: GOTO 0A5
009F: BCF 78.6
00A0: DECFSZ 78,F
00A1: GOTO 098
00A2: GOTO 0A3
00A3: NOP
00A4: BSF 06.3
00A5: MOVLW 3F
00A6: MOVWF 04
00A7: DECFSZ 04,F
00A8: GOTO 0A7
00A9: NOP
00AA: BTFSC 78.7
00AB: GOTO 097
00AC: BTFSC 78.6
00AD: GOTO 09F
00AE: 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;
*
089C: BCF 4D.0
.................... flag = 0;
089D: BCF 4D.1
.................... y = x;
089E: MOVF 40,W
089F: MOVWF 44
08A0: MOVF 3F,W
08A1: MOVWF 43
08A2: MOVF 3E,W
08A3: MOVWF 42
08A4: MOVF 3D,W
08A5: MOVWF 41
....................
.................... if (x < 0)
08A6: MOVF 40,W
08A7: MOVWF 51
08A8: MOVF 3F,W
08A9: MOVWF 50
08AA: MOVF 3E,W
08AB: MOVWF 4F
08AC: MOVF 3D,W
08AD: MOVWF 4E
08AE: CLRF 55
08AF: CLRF 54
08B0: CLRF 53
08B1: CLRF 52
08B2: BCF 0A.3
08B3: CALL 307
08B4: BSF 0A.3
08B5: BTFSS 03.0
08B6: GOTO 0BB
.................... {
.................... s = 1;
08B7: BSF 4D.0
.................... y = -y;
08B8: MOVF 42,W
08B9: XORLW 80
08BA: MOVWF 42
.................... }
....................
.................... if (y > 1.0)
08BB: CLRF 51
08BC: CLRF 50
08BD: CLRF 4F
08BE: MOVLW 7F
08BF: MOVWF 4E
08C0: MOVF 44,W
08C1: MOVWF 55
08C2: MOVF 43,W
08C3: MOVWF 54
08C4: MOVF 42,W
08C5: MOVWF 53
08C6: MOVF 41,W
08C7: MOVWF 52
08C8: BCF 0A.3
08C9: CALL 307
08CA: BSF 0A.3
08CB: BTFSS 03.0
08CC: GOTO 0E6
.................... {
.................... y = 1.0/y;
08CD: CLRF 55
08CE: CLRF 54
08CF: CLRF 53
08D0: MOVLW 7F
08D1: MOVWF 52
08D2: MOVF 44,W
08D3: MOVWF 59
08D4: MOVF 43,W
08D5: MOVWF 58
08D6: MOVF 42,W
08D7: MOVWF 57
08D8: MOVF 41,W
08D9: MOVWF 56
08DA: BCF 0A.3
08DB: CALL 23D
08DC: BSF 0A.3
08DD: MOVF 7A,W
08DE: MOVWF 44
08DF: MOVF 79,W
08E0: MOVWF 43
08E1: MOVF 78,W
08E2: MOVWF 42
08E3: MOVF 77,W
08E4: MOVWF 41
.................... flag = 1;
08E5: BSF 4D.1
.................... }
....................
.................... res = pat[0]*y*y + pat[1];
08E6: MOVLW 0A
08E7: MOVWF 55
08E8: MOVLW 89
08E9: MOVWF 54
08EA: MOVLW 34
08EB: MOVWF 53
08EC: MOVLW 7C
08ED: MOVWF 52
08EE: MOVF 44,W
08EF: MOVWF 59
08F0: MOVF 43,W
08F1: MOVWF 58
08F2: MOVF 42,W
08F3: MOVWF 57
08F4: MOVF 41,W
08F5: MOVWF 56
08F6: BCF 0A.3
08F7: CALL 346
08F8: BSF 0A.3
08F9: MOVF 77,W
08FA: MOVWF 4E
08FB: MOVF 78,W
08FC: MOVWF 4F
08FD: MOVF 79,W
08FE: MOVWF 50
08FF: MOVF 7A,W
0900: MOVWF 51
0901: MOVWF 55
0902: MOVF 79,W
0903: MOVWF 54
0904: MOVF 78,W
0905: MOVWF 53
0906: MOVF 77,W
0907: MOVWF 52
0908: MOVF 44,W
0909: MOVWF 59
090A: MOVF 43,W
090B: MOVWF 58
090C: MOVF 42,W
090D: MOVWF 57
090E: MOVF 41,W
090F: MOVWF 56
0910: BCF 0A.3
0911: CALL 346
0912: BSF 0A.3
0913: MOVF 77,W
0914: MOVWF 4E
0915: MOVF 78,W
0916: MOVWF 4F
0917: MOVF 79,W
0918: MOVWF 50
0919: MOVF 7A,W
091A: MOVWF 51
091B: BCF 03.1
091C: MOVF 7A,W
091D: MOVWF 55
091E: MOVF 79,W
091F: MOVWF 54
0920: MOVF 78,W
0921: MOVWF 53
0922: MOVF 77,W
0923: MOVWF 52
0924: MOVLW 7C
0925: MOVWF 59
0926: MOVLW 79
0927: MOVWF 58
0928: MOVLW 35
0929: MOVWF 57
092A: MOVLW 81
092B: MOVWF 56
092C: BCF 0A.3
092D: CALL 3BB
092E: BSF 0A.3
092F: MOVF 7A,W
0930: MOVWF 48
0931: MOVF 79,W
0932: MOVWF 47
0933: MOVF 78,W
0934: MOVWF 46
0935: MOVF 77,W
0936: MOVWF 45
.................... res = res*y*y + pat[2];
0937: MOVF 48,W
0938: MOVWF 55
0939: MOVF 47,W
093A: MOVWF 54
093B: MOVF 46,W
093C: MOVWF 53
093D: MOVF 45,W
093E: MOVWF 52
093F: MOVF 44,W
0940: MOVWF 59
0941: MOVF 43,W
0942: MOVWF 58
0943: MOVF 42,W
0944: MOVWF 57
0945: MOVF 41,W
0946: MOVWF 56
0947: BCF 0A.3
0948: CALL 346
0949: BSF 0A.3
094A: MOVF 77,W
094B: MOVWF 4E
094C: MOVF 78,W
094D: MOVWF 4F
094E: MOVF 79,W
094F: MOVWF 50
0950: MOVF 7A,W
0951: MOVWF 51
0952: MOVWF 55
0953: MOVF 79,W
0954: MOVWF 54
0955: MOVF 78,W
0956: MOVWF 53
0957: MOVF 77,W
0958: MOVWF 52
0959: MOVF 44,W
095A: MOVWF 59
095B: MOVF 43,W
095C: MOVWF 58
095D: MOVF 42,W
095E: MOVWF 57
095F: MOVF 41,W
0960: MOVWF 56
0961: BCF 0A.3
0962: CALL 346
0963: BSF 0A.3
0964: MOVF 77,W
0965: MOVWF 4E
0966: MOVF 78,W
0967: MOVWF 4F
0968: MOVF 79,W
0969: MOVWF 50
096A: MOVF 7A,W
096B: MOVWF 51
096C: BCF 03.1
096D: MOVF 7A,W
096E: MOVWF 55
096F: MOVF 79,W
0970: MOVWF 54
0971: MOVF 78,W
0972: MOVWF 53
0973: MOVF 77,W
0974: MOVWF 52
0975: MOVLW 3F
0976: MOVWF 59
0977: MOVLW 02
0978: MOVWF 58
0979: MOVLW 33
097A: MOVWF 57
097B: MOVLW 83
097C: MOVWF 56
097D: BCF 0A.3
097E: CALL 3BB
097F: BSF 0A.3
0980: MOVF 7A,W
0981: MOVWF 48
0982: MOVF 79,W
0983: MOVWF 47
0984: MOVF 78,W
0985: MOVWF 46
0986: MOVF 77,W
0987: MOVWF 45
.................... res = res*y*y + pat[3];
0988: MOVF 48,W
0989: MOVWF 55
098A: MOVF 47,W
098B: MOVWF 54
098C: MOVF 46,W
098D: MOVWF 53
098E: MOVF 45,W
098F: MOVWF 52
0990: MOVF 44,W
0991: MOVWF 59
0992: MOVF 43,W
0993: MOVWF 58
0994: MOVF 42,W
0995: MOVWF 57
0996: MOVF 41,W
0997: MOVWF 56
0998: BCF 0A.3
0999: CALL 346
099A: BSF 0A.3
099B: MOVF 77,W
099C: MOVWF 4E
099D: MOVF 78,W
099E: MOVWF 4F
099F: MOVF 79,W
09A0: MOVWF 50
09A1: MOVF 7A,W
09A2: MOVWF 51
09A3: MOVWF 55
09A4: MOVF 79,W
09A5: MOVWF 54
09A6: MOVF 78,W
09A7: MOVWF 53
09A8: MOVF 77,W
09A9: MOVWF 52
09AA: MOVF 44,W
09AB: MOVWF 59
09AC: MOVF 43,W
09AD: MOVWF 58
09AE: MOVF 42,W
09AF: MOVWF 57
09B0: MOVF 41,W
09B1: MOVWF 56
09B2: BCF 0A.3
09B3: CALL 346
09B4: BSF 0A.3
09B5: MOVF 77,W
09B6: MOVWF 4E
09B7: MOVF 78,W
09B8: MOVWF 4F
09B9: MOVF 79,W
09BA: MOVWF 50
09BB: MOVF 7A,W
09BC: MOVWF 51
09BD: BCF 03.1
09BE: MOVF 7A,W
09BF: MOVWF 55
09C0: MOVF 79,W
09C1: MOVWF 54
09C2: MOVF 78,W
09C3: MOVWF 53
09C4: MOVF 77,W
09C5: MOVWF 52
09C6: MOVLW 33
09C7: MOVWF 59
09C8: MOVLW 8C
09C9: MOVWF 58
09CA: MOVLW 1E
09CB: MOVWF 57
09CC: MOVLW 83
09CD: MOVWF 56
09CE: BCF 0A.3
09CF: CALL 3BB
09D0: BSF 0A.3
09D1: MOVF 7A,W
09D2: MOVWF 48
09D3: MOVF 79,W
09D4: MOVWF 47
09D5: MOVF 78,W
09D6: MOVWF 46
09D7: MOVF 77,W
09D8: MOVWF 45
....................
.................... r = qat[0]*y*y + qat[1];
09D9: CLRF 55
09DA: CLRF 54
09DB: CLRF 53
09DC: MOVLW 7F
09DD: MOVWF 52
09DE: MOVF 44,W
09DF: MOVWF 59
09E0: MOVF 43,W
09E1: MOVWF 58
09E2: MOVF 42,W
09E3: MOVWF 57
09E4: MOVF 41,W
09E5: MOVWF 56
09E6: BCF 0A.3
09E7: CALL 346
09E8: BSF 0A.3
09E9: MOVF 77,W
09EA: MOVWF 4E
09EB: MOVF 78,W
09EC: MOVWF 4F
09ED: MOVF 79,W
09EE: MOVWF 50
09EF: MOVF 7A,W
09F0: MOVWF 51
09F1: MOVWF 55
09F2: MOVF 79,W
09F3: MOVWF 54
09F4: MOVF 78,W
09F5: MOVWF 53
09F6: MOVF 77,W
09F7: MOVWF 52
09F8: MOVF 44,W
09F9: MOVWF 59
09FA: MOVF 43,W
09FB: MOVWF 58
09FC: MOVF 42,W
09FD: MOVWF 57
09FE: MOVF 41,W
09FF: MOVWF 56
0A00: BCF 0A.3
0A01: CALL 346
0A02: BSF 0A.3
0A03: MOVF 77,W
0A04: MOVWF 4E
0A05: MOVF 78,W
0A06: MOVWF 4F
0A07: MOVF 79,W
0A08: MOVWF 50
0A09: MOVF 7A,W
0A0A: MOVWF 51
0A0B: BCF 03.1
0A0C: MOVF 7A,W
0A0D: MOVWF 55
0A0E: MOVF 79,W
0A0F: MOVWF 54
0A10: MOVF 78,W
0A11: MOVWF 53
0A12: MOVF 77,W
0A13: MOVWF 52
0A14: MOVLW 1B
0A15: MOVWF 59
0A16: MOVLW E4
0A17: MOVWF 58
0A18: MOVLW 35
0A19: MOVWF 57
0A1A: MOVLW 82
0A1B: MOVWF 56
0A1C: BCF 0A.3
0A1D: CALL 3BB
0A1E: BSF 0A.3
0A1F: MOVF 7A,W
0A20: MOVWF 4C
0A21: MOVF 79,W
0A22: MOVWF 4B
0A23: MOVF 78,W
0A24: MOVWF 4A
0A25: MOVF 77,W
0A26: MOVWF 49
.................... r = r*y*y + qat[2];
0A27: MOVF 4C,W
0A28: MOVWF 55
0A29: MOVF 4B,W
0A2A: MOVWF 54
0A2B: MOVF 4A,W
0A2C: MOVWF 53
0A2D: MOVF 49,W
0A2E: MOVWF 52
0A2F: MOVF 44,W
0A30: MOVWF 59
0A31: MOVF 43,W
0A32: MOVWF 58
0A33: MOVF 42,W
0A34: MOVWF 57
0A35: MOVF 41,W
0A36: MOVWF 56
0A37: BCF 0A.3
0A38: CALL 346
0A39: BSF 0A.3
0A3A: MOVF 77,W
0A3B: MOVWF 4E
0A3C: MOVF 78,W
0A3D: MOVWF 4F
0A3E: MOVF 79,W
0A3F: MOVWF 50
0A40: MOVF 7A,W
0A41: MOVWF 51
0A42: MOVWF 55
0A43: MOVF 79,W
0A44: MOVWF 54
0A45: MOVF 78,W
0A46: MOVWF 53
0A47: MOVF 77,W
0A48: MOVWF 52
0A49: MOVF 44,W
0A4A: MOVWF 59
0A4B: MOVF 43,W
0A4C: MOVWF 58
0A4D: MOVF 42,W
0A4E: MOVWF 57
0A4F: MOVF 41,W
0A50: MOVWF 56
0A51: BCF 0A.3
0A52: CALL 346
0A53: BSF 0A.3
0A54: MOVF 77,W
0A55: MOVWF 4E
0A56: MOVF 78,W
0A57: MOVWF 4F
0A58: MOVF 79,W
0A59: MOVWF 50
0A5A: MOVF 7A,W
0A5B: MOVWF 51
0A5C: BCF 03.1
0A5D: MOVF 7A,W
0A5E: MOVWF 55
0A5F: MOVF 79,W
0A60: MOVWF 54
0A61: MOVF 78,W
0A62: MOVWF 53
0A63: MOVF 77,W
0A64: MOVWF 52
0A65: MOVLW A4
0A66: MOVWF 59
0A67: MOVLW DB
0A68: MOVWF 58
0A69: MOVLW 67
0A6A: MOVWF 57
0A6B: MOVLW 83
0A6C: MOVWF 56
0A6D: BCF 0A.3
0A6E: CALL 3BB
0A6F: BSF 0A.3
0A70: MOVF 7A,W
0A71: MOVWF 4C
0A72: MOVF 79,W
0A73: MOVWF 4B
0A74: MOVF 78,W
0A75: MOVWF 4A
0A76: MOVF 77,W
0A77: MOVWF 49
.................... r = r*y*y + qat[3];
0A78: MOVF 4C,W
0A79: MOVWF 55
0A7A: MOVF 4B,W
0A7B: MOVWF 54
0A7C: MOVF 4A,W
0A7D: MOVWF 53
0A7E: MOVF 49,W
0A7F: MOVWF 52
0A80: MOVF 44,W
0A81: MOVWF 59
0A82: MOVF 43,W
0A83: MOVWF 58
0A84: MOVF 42,W
0A85: MOVWF 57
0A86: MOVF 41,W
0A87: MOVWF 56
0A88: BCF 0A.3
0A89: CALL 346
0A8A: BSF 0A.3
0A8B: MOVF 77,W
0A8C: MOVWF 4E
0A8D: MOVF 78,W
0A8E: MOVWF 4F
0A8F: MOVF 79,W
0A90: MOVWF 50
0A91: MOVF 7A,W
0A92: MOVWF 51
0A93: MOVWF 55
0A94: MOVF 79,W
0A95: MOVWF 54
0A96: MOVF 78,W
0A97: MOVWF 53
0A98: MOVF 77,W
0A99: MOVWF 52
0A9A: MOVF 44,W
0A9B: MOVWF 59
0A9C: MOVF 43,W
0A9D: MOVWF 58
0A9E: MOVF 42,W
0A9F: MOVWF 57
0AA0: MOVF 41,W
0AA1: MOVWF 56
0AA2: BCF 0A.3
0AA3: CALL 346
0AA4: BSF 0A.3
0AA5: MOVF 77,W
0AA6: MOVWF 4E
0AA7: MOVF 78,W
0AA8: MOVWF 4F
0AA9: MOVF 79,W
0AAA: MOVWF 50
0AAB: MOVF 7A,W
0AAC: MOVWF 51
0AAD: BCF 03.1
0AAE: MOVF 7A,W
0AAF: MOVWF 55
0AB0: MOVF 79,W
0AB1: MOVWF 54
0AB2: MOVF 78,W
0AB3: MOVWF 53
0AB4: MOVF 77,W
0AB5: MOVWF 52
0AB6: MOVLW 33
0AB7: MOVWF 59
0AB8: MOVLW 8C
0AB9: MOVWF 58
0ABA: MOVLW 1E
0ABB: MOVWF 57
0ABC: MOVLW 83
0ABD: MOVWF 56
0ABE: BCF 0A.3
0ABF: CALL 3BB
0AC0: BSF 0A.3
0AC1: MOVF 7A,W
0AC2: MOVWF 4C
0AC3: MOVF 79,W
0AC4: MOVWF 4B
0AC5: MOVF 78,W
0AC6: MOVWF 4A
0AC7: MOVF 77,W
0AC8: MOVWF 49
....................
.................... res = y*res/r;
0AC9: MOVF 44,W
0ACA: MOVWF 55
0ACB: MOVF 43,W
0ACC: MOVWF 54
0ACD: MOVF 42,W
0ACE: MOVWF 53
0ACF: MOVF 41,W
0AD0: MOVWF 52
0AD1: MOVF 48,W
0AD2: MOVWF 59
0AD3: MOVF 47,W
0AD4: MOVWF 58
0AD5: MOVF 46,W
0AD6: MOVWF 57
0AD7: MOVF 45,W
0AD8: MOVWF 56
0AD9: BCF 0A.3
0ADA: CALL 346
0ADB: BSF 0A.3
0ADC: MOVF 77,W
0ADD: MOVWF 4E
0ADE: MOVF 78,W
0ADF: MOVWF 4F
0AE0: MOVF 79,W
0AE1: MOVWF 50
0AE2: MOVF 7A,W
0AE3: MOVWF 51
0AE4: MOVWF 55
0AE5: MOVF 79,W
0AE6: MOVWF 54
0AE7: MOVF 78,W
0AE8: MOVWF 53
0AE9: MOVF 77,W
0AEA: MOVWF 52
0AEB: MOVF 4C,W
0AEC: MOVWF 59
0AED: MOVF 4B,W
0AEE: MOVWF 58
0AEF: MOVF 4A,W
0AF0: MOVWF 57
0AF1: MOVF 49,W
0AF2: MOVWF 56
0AF3: BCF 0A.3
0AF4: CALL 23D
0AF5: BSF 0A.3
0AF6: MOVF 7A,W
0AF7: MOVWF 48
0AF8: MOVF 79,W
0AF9: MOVWF 47
0AFA: MOVF 78,W
0AFB: MOVWF 46
0AFC: MOVF 77,W
0AFD: MOVWF 45
....................
....................
.................... if (flag) // for |x| > 1
0AFE: BTFSS 4D.1
0AFF: GOTO 31C
.................... res = PI_DIV_BY_TWO - res;
0B00: BSF 03.1
0B01: MOVLW DB
0B02: MOVWF 55
0B03: MOVLW 0F
0B04: MOVWF 54
0B05: MOVLW 49
0B06: MOVWF 53
0B07: MOVLW 7F
0B08: MOVWF 52
0B09: MOVF 48,W
0B0A: MOVWF 59
0B0B: MOVF 47,W
0B0C: MOVWF 58
0B0D: MOVF 46,W
0B0E: MOVWF 57
0B0F: MOVF 45,W
0B10: MOVWF 56
0B11: BCF 0A.3
0B12: CALL 3BB
0B13: BSF 0A.3
0B14: MOVF 7A,W
0B15: MOVWF 48
0B16: MOVF 79,W
0B17: MOVWF 47
0B18: MOVF 78,W
0B19: MOVWF 46
0B1A: MOVF 77,W
0B1B: MOVWF 45
.................... if (s)
0B1C: BTFSS 4D.0
0B1D: GOTO 321
.................... res = -res;
0B1E: MOVF 46,W
0B1F: XORLW 80
0B20: MOVWF 46
....................
.................... return(res);
0B21: MOVF 45,W
0B22: MOVWF 77
0B23: MOVF 46,W
0B24: MOVWF 78
0B25: MOVF 47,W
0B26: MOVWF 79
0B27: MOVF 48,W
0B28: 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
....................
.................... #include <HMC5883L.h>
.................... #define MAG_ADDR_R 0x3D //addresa pro cteni
.................... #define MAG_ADDR_W 0x3C
....................
....................
.................... //Konstanty nastavujici rozsah
.................... //pro void set_mag_roz (unsigned int8 h)
.................... #define MAG_ROZ088 0x00
.................... #define MAG_ROZ130 0x20
.................... #define MAG_ROZ190 0x40
.................... #define MAG_ROZ250 0x60
.................... #define MAG_ROZ400 0x80
.................... #define MAG_ROZ470 0xA0
.................... #define MAG_ROZ560 0xC0
.................... #define MAG_ROZ810 0xE0
....................
....................
.................... #include "HMC5883L.c"
.................... void set_mag (void) //uvodni nastaveni na kontinualni mereni, rozsah ± 8.1 Ga, frekvence mereni 15HZ
.................... {
.................... i2c_start(); //nastavení Configuration Register A
*
011C: BSF 03.5
011D: BSF 06.0
011E: NOP
011F: BSF 06.1
0120: NOP
0121: BCF 03.5
0122: BCF 06.0
0123: BSF 03.5
0124: BCF 06.0
0125: NOP
0126: BCF 03.5
0127: BCF 06.1
0128: BSF 03.5
0129: BCF 06.1
.................... I2C_Write(MAG_ADDR_W);
012A: MOVLW 3C
012B: BCF 03.5
012C: MOVWF 42
012D: CALL 0D4
.................... I2C_Write(0x00);
012E: CLRF 42
012F: CALL 0D4
.................... I2C_Write(0x70);
0130: MOVLW 70
0131: MOVWF 42
0132: CALL 0D4
.................... i2c_stop();
0133: BSF 03.5
0134: BCF 06.0
0135: NOP
0136: BSF 06.1
0137: BCF 03.5
0138: BTFSS 06.1
0139: GOTO 138
013A: NOP
013B: GOTO 13C
013C: NOP
013D: BSF 03.5
013E: BSF 06.0
013F: NOP
.................... Delay_ms(6);
0140: MOVLW 06
0141: BCF 03.5
0142: MOVWF 30
0143: CALL 108
....................
.................... i2c_start(); //nastavení Configuration Register B
0144: BSF 03.5
0145: BSF 06.0
0146: NOP
0147: BSF 06.1
0148: NOP
0149: BCF 03.5
014A: BCF 06.0
014B: BSF 03.5
014C: BCF 06.0
014D: NOP
014E: BCF 03.5
014F: BCF 06.1
0150: BSF 03.5
0151: BCF 06.1
.................... I2C_Write(MAG_ADDR_W);
0152: MOVLW 3C
0153: BCF 03.5
0154: MOVWF 42
0155: CALL 0D4
.................... I2C_Write(0x01);
0156: MOVLW 01
0157: MOVWF 42
0158: CALL 0D4
.................... I2C_Write(MAG_ROZ810);
0159: MOVLW E0
015A: MOVWF 42
015B: CALL 0D4
.................... i2c_stop();
015C: BSF 03.5
015D: BCF 06.0
015E: NOP
015F: BSF 06.1
0160: BCF 03.5
0161: BTFSS 06.1
0162: GOTO 161
0163: NOP
0164: GOTO 165
0165: NOP
0166: BSF 03.5
0167: BSF 06.0
0168: NOP
....................
.................... Delay_ms(6);
0169: MOVLW 06
016A: BCF 03.5
016B: MOVWF 30
016C: CALL 108
....................
.................... i2c_start(); //nastveni Mode Register
016D: BSF 03.5
016E: BSF 06.0
016F: NOP
0170: BSF 06.1
0171: NOP
0172: BCF 03.5
0173: BCF 06.0
0174: BSF 03.5
0175: BCF 06.0
0176: NOP
0177: BCF 03.5
0178: BCF 06.1
0179: BSF 03.5
017A: BCF 06.1
.................... I2C_Write(MAG_ADDR_W);
017B: MOVLW 3C
017C: BCF 03.5
017D: MOVWF 42
017E: CALL 0D4
.................... I2C_Write(0x02);
017F: MOVLW 02
0180: MOVWF 42
0181: CALL 0D4
.................... I2C_Write(0x00);
0182: CLRF 42
0183: CALL 0D4
.................... i2c_stop();
0184: BSF 03.5
0185: BCF 06.0
0186: NOP
0187: BSF 06.1
0188: BCF 03.5
0189: BTFSS 06.1
018A: GOTO 189
018B: NOP
018C: GOTO 18D
018D: NOP
018E: BSF 03.5
018F: BSF 06.0
0190: NOP
.................... Delay_ms(6);
0191: MOVLW 06
0192: BCF 03.5
0193: MOVWF 30
0194: CALL 108
.................... }
0195: BSF 0A.3
0196: BCF 0A.4
0197: GOTO 49E (RETURN)
....................
.................... void set_mag_roz (unsigned int8 h) //nastavy rozsah
.................... {
....................
.................... //
....................
....................
.................... i2c_start();
.................... I2C_Write(MAG_ADDR_W);
.................... I2C_Write(0x01);
.................... I2C_Write(h);
.................... i2c_stop();
....................
.................... Delay_ms(6);
....................
....................
.................... }
....................
....................
.................... byte mag_read(byte reg) //pro cteni reg
.................... {
....................
.................... i2c_start();
0198: BSF 03.5
0199: BSF 06.0
019A: NOP
019B: BSF 06.1
019C: NOP
019D: BCF 03.5
019E: BCF 06.0
019F: BSF 03.5
01A0: BCF 06.0
01A1: NOP
01A2: BCF 03.5
01A3: BCF 06.1
01A4: BSF 03.5
01A5: BCF 06.1
.................... I2C_Write(MAG_ADDR_W);
01A6: MOVLW 3C
01A7: BCF 03.5
01A8: MOVWF 42
01A9: CALL 0D4
.................... I2C_write(reg);
01AA: MOVF 41,W
01AB: MOVWF 42
01AC: CALL 0D4
.................... i2c_stop();
01AD: BSF 03.5
01AE: BCF 06.0
01AF: NOP
01B0: BSF 06.1
01B1: BCF 03.5
01B2: BTFSS 06.1
01B3: GOTO 1B2
01B4: NOP
01B5: GOTO 1B6
01B6: NOP
01B7: BSF 03.5
01B8: BSF 06.0
01B9: NOP
.................... i2c_start();
01BA: BSF 06.0
01BB: NOP
01BC: BSF 06.1
01BD: NOP
01BE: BCF 03.5
01BF: BCF 06.0
01C0: BSF 03.5
01C1: BCF 06.0
01C2: NOP
01C3: BCF 03.5
01C4: BCF 06.1
01C5: BSF 03.5
01C6: BCF 06.1
.................... I2C_Write(MAG_ADDR_R);
01C7: MOVLW 3D
01C8: BCF 03.5
01C9: MOVWF 42
01CA: CALL 0D4
.................... reg=i2c_read(0);
01CB: CLRF 77
*
01FD: MOVF 78,W
01FE: BCF 03.5
01FF: MOVWF 41
.................... return reg;
0200: MOVF 41,W
0201: MOVWF 78
.................... }
0202: RETURN
....................
....................
.................... signed int16 mag_vypocet(unsigned int8 h, unsigned int8 l) //prepocet na 16bit cislo
.................... {
.................... signed int16 x;
.................... x = (((unsigned int16) h << 8) + l );
0203: CLRF 46
0204: MOVF 41,W
0205: MOVWF 45
0206: MOVWF 46
0207: CLRF 45
0208: MOVF 42,W
0209: ADDWF 45,W
020A: MOVWF 78
020B: MOVF 46,W
020C: MOVWF 7A
020D: BTFSC 03.0
020E: INCF 7A,F
020F: MOVF 78,W
0210: MOVWF 43
0211: MOVF 7A,W
0212: MOVWF 44
.................... return x;
0213: MOVF 43,W
0214: MOVWF 78
0215: MOVF 44,W
0216: MOVWF 79
.................... }
0217: RETURN
....................
....................
.................... signed int16 mag_readX(void) //nacteni osy x
.................... {
.................... unsigned int8 h,l;
.................... signed int16 x;
.................... h=mag_read(0x03);
*
0800: MOVLW 03
0801: MOVWF 41
0802: BCF 0A.3
0803: CALL 198
0804: BSF 0A.3
0805: MOVF 78,W
0806: MOVWF 3D
.................... l=mag_read(0x04);
0807: MOVLW 04
0808: MOVWF 41
0809: BCF 0A.3
080A: CALL 198
080B: BSF 0A.3
080C: MOVF 78,W
080D: MOVWF 3E
.................... x=mag_vypocet(h,l);
080E: MOVF 3D,W
080F: MOVWF 41
0810: MOVF 3E,W
0811: MOVWF 42
0812: BCF 0A.3
0813: CALL 203
0814: BSF 0A.3
0815: MOVF 79,W
0816: MOVWF 40
0817: MOVF 78,W
0818: MOVWF 3F
.................... return x;
0819: MOVF 3F,W
081A: MOVWF 78
081B: MOVF 40,W
081C: MOVWF 79
....................
.................... }
....................
....................
.................... signed int16 mag_readY(void) //nacteni osy x
.................... {
.................... unsigned int8 h,l;
.................... signed int16 x;
.................... h=mag_read(0x07);
*
0821: MOVLW 07
0822: MOVWF 41
0823: BCF 0A.3
0824: CALL 198
0825: BSF 0A.3
0826: MOVF 78,W
0827: MOVWF 3D
.................... l=mag_read(0x08);
0828: MOVLW 08
0829: MOVWF 41
082A: BCF 0A.3
082B: CALL 198
082C: BSF 0A.3
082D: MOVF 78,W
082E: MOVWF 3E
.................... x=mag_vypocet(h,l);
082F: MOVF 3D,W
0830: MOVWF 41
0831: MOVF 3E,W
0832: MOVWF 42
0833: BCF 0A.3
0834: CALL 203
0835: BSF 0A.3
0836: MOVF 79,W
0837: MOVWF 40
0838: MOVF 78,W
0839: MOVWF 3F
.................... return x;
083A: MOVF 3F,W
083B: MOVWF 78
083C: MOVF 40,W
083D: MOVWF 79
....................
.................... }
....................
....................
.................... signed int16 mag_readZ(void) //nacteni osy x
.................... {
.................... unsigned int8 h,l;
.................... signed int16 x;
.................... h=mag_read(0x05);
*
0842: MOVLW 05
0843: MOVWF 41
0844: BCF 0A.3
0845: CALL 198
0846: BSF 0A.3
0847: MOVF 78,W
0848: MOVWF 3D
.................... l=mag_read(0x06);
0849: MOVLW 06
084A: MOVWF 41
084B: BCF 0A.3
084C: CALL 198
084D: BSF 0A.3
084E: MOVF 78,W
084F: MOVWF 3E
.................... x=mag_vypocet(h,l);
0850: MOVF 3D,W
0851: MOVWF 41
0852: MOVF 3E,W
0853: MOVWF 42
0854: BCF 0A.3
0855: CALL 203
0856: BSF 0A.3
0857: MOVF 79,W
0858: MOVWF 40
0859: MOVF 78,W
085A: MOVWF 3F
.................... return x;
085B: MOVF 3F,W
085C: MOVWF 78
085D: MOVF 40,W
085E: MOVWF 79
....................
.................... }
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.................... float azimut (void) //vypocet aktualni vysky panelu
.................... {
.................... signed int16 x,y,z;
....................
.................... x= mag_readX();
*
081D: MOVF 79,W
081E: MOVWF 30
081F: MOVF 78,W
0820: MOVWF 2F
.................... y= mag_readY();
*
083E: MOVF 79,W
083F: MOVWF 32
0840: MOVF 78,W
0841: MOVWF 31
.................... z= mag_readZ();
*
085F: MOVF 79,W
0860: MOVWF 34
0861: MOVF 78,W
0862: MOVWF 33
....................
....................
.................... float a, b;
.................... a=(float)y/x;
0863: MOVF 32,W
0864: MOVWF 42
0865: MOVF 31,W
0866: MOVWF 41
0867: BCF 0A.3
0868: CALL 218
0869: BSF 0A.3
086A: MOVF 77,W
086B: MOVWF 3D
086C: MOVF 78,W
086D: MOVWF 3E
086E: MOVF 79,W
086F: MOVWF 3F
0870: MOVF 7A,W
0871: MOVWF 40
0872: MOVF 30,W
0873: MOVWF 42
0874: MOVF 2F,W
0875: MOVWF 41
0876: BCF 0A.3
0877: CALL 218
0878: BSF 0A.3
0879: MOVF 40,W
087A: MOVWF 55
087B: MOVF 3F,W
087C: MOVWF 54
087D: MOVF 3E,W
087E: MOVWF 53
087F: MOVF 3D,W
0880: MOVWF 52
0881: MOVF 7A,W
0882: MOVWF 59
0883: MOVF 79,W
0884: MOVWF 58
0885: MOVF 78,W
0886: MOVWF 57
0887: MOVF 77,W
0888: MOVWF 56
0889: BCF 0A.3
088A: CALL 23D
088B: BSF 0A.3
088C: MOVF 7A,W
088D: MOVWF 38
088E: MOVF 79,W
088F: MOVWF 37
0890: MOVF 78,W
0891: MOVWF 36
0892: MOVF 77,W
0893: MOVWF 35
.................... b=atan(a);
0894: MOVF 38,W
0895: MOVWF 40
0896: MOVF 37,W
0897: MOVWF 3F
0898: MOVF 36,W
0899: MOVWF 3E
089A: MOVF 35,W
089B: MOVWF 3D
*
0B29: MOVF 7A,W
0B2A: MOVWF 3C
0B2B: MOVF 79,W
0B2C: MOVWF 3B
0B2D: MOVF 78,W
0B2E: MOVWF 3A
0B2F: MOVF 77,W
0B30: MOVWF 39
.................... b = (b/3.14)*180;
0B31: MOVF 3C,W
0B32: MOVWF 55
0B33: MOVF 3B,W
0B34: MOVWF 54
0B35: MOVF 3A,W
0B36: MOVWF 53
0B37: MOVF 39,W
0B38: MOVWF 52
0B39: MOVLW C3
0B3A: MOVWF 59
0B3B: MOVLW F5
0B3C: MOVWF 58
0B3D: MOVLW 48
0B3E: MOVWF 57
0B3F: MOVLW 80
0B40: MOVWF 56
0B41: BCF 0A.3
0B42: CALL 23D
0B43: BSF 0A.3
0B44: MOVF 77,W
0B45: MOVWF 3D
0B46: MOVF 78,W
0B47: MOVWF 3E
0B48: MOVF 79,W
0B49: MOVWF 3F
0B4A: MOVF 7A,W
0B4B: MOVWF 40
0B4C: MOVWF 55
0B4D: MOVF 3F,W
0B4E: MOVWF 54
0B4F: MOVF 3E,W
0B50: MOVWF 53
0B51: MOVF 3D,W
0B52: MOVWF 52
0B53: CLRF 59
0B54: CLRF 58
0B55: MOVLW 34
0B56: MOVWF 57
0B57: MOVLW 86
0B58: MOVWF 56
0B59: BCF 0A.3
0B5A: CALL 346
0B5B: BSF 0A.3
0B5C: MOVF 7A,W
0B5D: MOVWF 3C
0B5E: MOVF 79,W
0B5F: MOVWF 3B
0B60: MOVF 78,W
0B61: MOVWF 3A
0B62: MOVF 77,W
0B63: MOVWF 39
.................... b=abs(b);
0B64: MOVF 39,W
0B65: MOVWF 77
0B66: MOVF 3A,W
0B67: MOVWF 78
0B68: MOVF 3B,W
0B69: MOVWF 79
0B6A: MOVF 3C,W
0B6B: MOVWF 7A
0B6C: BCF 78.7
0B6D: MOVF 3C,W
0B6E: MOVWF 3C
0B6F: MOVF 3B,W
0B70: MOVWF 3B
0B71: MOVF 78,W
0B72: MOVWF 3A
0B73: MOVF 39,W
0B74: MOVWF 39
....................
....................
....................
....................
.................... if(x==0) //osetreni proti deleni 0
0B75: MOVF 2F,F
0B76: BTFSS 03.2
0B77: GOTO 39B
0B78: MOVF 30,F
0B79: BTFSS 03.2
0B7A: GOTO 39B
.................... {
.................... printf("Elektronický kompas0\r\n",);
0B7B: MOVLW 04
0B7C: BSF 03.6
0B7D: MOVWF 0D
0B7E: MOVLW 00
0B7F: MOVWF 0F
0B80: BCF 0A.3
0B81: BCF 03.6
0B82: CALL 0AF
0B83: BSF 0A.3
.................... if(y>0)
0B84: BTFSC 32.7
0B85: GOTO 394
0B86: MOVF 32,F
0B87: BTFSS 03.2
0B88: GOTO 38D
0B89: MOVF 31,W
0B8A: SUBLW 00
0B8B: BTFSC 03.0
0B8C: GOTO 394
.................... {
.................... b=90;
0B8D: CLRF 3C
0B8E: CLRF 3B
0B8F: MOVLW 34
0B90: MOVWF 3A
0B91: MOVLW 85
0B92: MOVWF 39
.................... }
.................... else
0B93: GOTO 39A
.................... {
.................... b=270;
0B94: CLRF 3C
0B95: CLRF 3B
0B96: MOVLW 07
0B97: MOVWF 3A
0B98: MOVLW 87
0B99: MOVWF 39
.................... }
.................... }
.................... else
0B9A: GOTO 423
.................... {
.................... if(x>0)
0B9B: BTFSC 30.7
0B9C: GOTO 3EE
0B9D: MOVF 30,F
0B9E: BTFSS 03.2
0B9F: GOTO 3A4
0BA0: MOVF 2F,W
0BA1: SUBLW 00
0BA2: BTFSC 03.0
0BA3: GOTO 3EE
.................... {
.................... if(y>=0)
0BA4: BTFSC 32.7
0BA5: GOTO 3CA
.................... {
.................... b=180+b;
0BA6: BCF 03.1
0BA7: CLRF 55
0BA8: CLRF 54
0BA9: MOVLW 34
0BAA: MOVWF 53
0BAB: MOVLW 86
0BAC: MOVWF 52
0BAD: MOVF 3C,W
0BAE: MOVWF 59
0BAF: MOVF 3B,W
0BB0: MOVWF 58
0BB1: MOVF 3A,W
0BB2: MOVWF 57
0BB3: MOVF 39,W
0BB4: MOVWF 56
0BB5: BCF 0A.3
0BB6: CALL 3BB
0BB7: BSF 0A.3
0BB8: MOVF 7A,W
0BB9: MOVWF 3C
0BBA: MOVF 79,W
0BBB: MOVWF 3B
0BBC: MOVF 78,W
0BBD: MOVWF 3A
0BBE: MOVF 77,W
0BBF: MOVWF 39
.................... printf("180+b\r\n",);
0BC0: MOVLW 1B
0BC1: BSF 03.6
0BC2: MOVWF 0D
0BC3: MOVLW 00
0BC4: MOVWF 0F
0BC5: BCF 0A.3
0BC6: BCF 03.6
0BC7: CALL 4FC
0BC8: BSF 0A.3
.................... }
.................... else
0BC9: GOTO 3ED
.................... {
.................... b=180-b;
0BCA: BSF 03.1
0BCB: CLRF 55
0BCC: CLRF 54
0BCD: MOVLW 34
0BCE: MOVWF 53
0BCF: MOVLW 86
0BD0: MOVWF 52
0BD1: MOVF 3C,W
0BD2: MOVWF 59
0BD3: MOVF 3B,W
0BD4: MOVWF 58
0BD5: MOVF 3A,W
0BD6: MOVWF 57
0BD7: MOVF 39,W
0BD8: MOVWF 56
0BD9: BCF 0A.3
0BDA: CALL 3BB
0BDB: BSF 0A.3
0BDC: MOVF 7A,W
0BDD: MOVWF 3C
0BDE: MOVF 79,W
0BDF: MOVWF 3B
0BE0: MOVF 78,W
0BE1: MOVWF 3A
0BE2: MOVF 77,W
0BE3: MOVWF 39
.................... printf("180-b\r\n",);
0BE4: MOVLW 1F
0BE5: BSF 03.6
0BE6: MOVWF 0D
0BE7: MOVLW 00
0BE8: MOVWF 0F
0BE9: BCF 0A.3
0BEA: BCF 03.6
0BEB: CALL 4FC
0BEC: BSF 0A.3
.................... }
.................... }
.................... else
0BED: GOTO 423
.................... {
.................... if(y>=0)
0BEE: BTFSC 32.7
0BEF: GOTO 414
.................... {
.................... b=360-b;
0BF0: BSF 03.1
0BF1: CLRF 55
0BF2: CLRF 54
0BF3: MOVLW 34
0BF4: MOVWF 53
0BF5: MOVLW 87
0BF6: MOVWF 52
0BF7: MOVF 3C,W
0BF8: MOVWF 59
0BF9: MOVF 3B,W
0BFA: MOVWF 58
0BFB: MOVF 3A,W
0BFC: MOVWF 57
0BFD: MOVF 39,W
0BFE: MOVWF 56
0BFF: BCF 0A.3
0C00: CALL 3BB
0C01: BSF 0A.3
0C02: MOVF 7A,W
0C03: MOVWF 3C
0C04: MOVF 79,W
0C05: MOVWF 3B
0C06: MOVF 78,W
0C07: MOVWF 3A
0C08: MOVF 77,W
0C09: MOVWF 39
.................... printf("360-b\r\n",);
0C0A: MOVLW 23
0C0B: BSF 03.6
0C0C: MOVWF 0D
0C0D: MOVLW 00
0C0E: MOVWF 0F
0C0F: BCF 0A.3
0C10: BCF 03.6
0C11: CALL 4FC
0C12: BSF 0A.3
.................... }
.................... else
0C13: GOTO 423
.................... {
.................... b=b;
.................... printf("b\r\n",);
0C14: MOVLW 62
0C15: MOVWF 40
0C16: BCF 0A.3
0C17: CALL 08D
0C18: BSF 0A.3
0C19: MOVLW 0D
0C1A: MOVWF 40
0C1B: BCF 0A.3
0C1C: CALL 08D
0C1D: BSF 0A.3
0C1E: MOVLW 0A
0C1F: MOVWF 40
0C20: BCF 0A.3
0C21: CALL 08D
0C22: BSF 0A.3
.................... }
.................... }
....................
.................... }
....................
.................... return b;
0C23: MOVF 39,W
0C24: MOVWF 77
0C25: MOVF 3A,W
0C26: MOVWF 78
0C27: MOVF 3B,W
0C28: MOVWF 79
0C29: MOVF 3C,W
0C2A: MOVWF 7A
....................
.................... }
0C2B: BSF 0A.3
0C2C: BCF 0A.4
0C2D: GOTO 4A0 (RETURN)
....................
.................... void main()
.................... {
0C2E: CLRF 04
0C2F: BCF 03.7
0C30: MOVLW 1F
0C31: ANDWF 03,F
0C32: MOVLW 71
0C33: BSF 03.5
0C34: MOVWF 0F
0C35: MOVF 0F,W
0C36: BCF 06.3
0C37: BCF 03.5
0C38: BSF 06.3
0C39: BSF 03.5
0C3A: BSF 03.6
0C3B: MOVF 09,W
0C3C: ANDLW C0
0C3D: MOVWF 09
0C3E: BCF 03.6
0C3F: BCF 1F.4
0C40: BCF 1F.5
0C41: MOVLW 00
0C42: BSF 03.6
0C43: MOVWF 08
0C44: BCF 03.5
0C45: CLRF 07
0C46: CLRF 08
0C47: CLRF 09
....................
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
*
0C4B: BSF 03.5
0C4C: BSF 03.6
0C4D: MOVF 09,W
0C4E: ANDLW C0
0C4F: MOVWF 09
0C50: BCF 03.6
0C51: BCF 1F.4
0C52: BCF 1F.5
0C53: MOVLW 00
0C54: BSF 03.6
0C55: MOVWF 08
.................... setup_adc(ADC_CLOCK_DIV_2);
0C56: BCF 03.5
0C57: BCF 03.6
0C58: BCF 1F.6
0C59: BCF 1F.7
0C5A: BSF 03.5
0C5B: BCF 1F.7
0C5C: BCF 03.5
0C5D: BSF 1F.0
.................... setup_spi(SPI_SS_DISABLED);
0C5E: BCF 14.5
0C5F: BCF 20.5
0C60: MOVF 20,W
0C61: BSF 03.5
0C62: MOVWF 07
0C63: BCF 03.5
0C64: BSF 20.4
0C65: MOVF 20,W
0C66: BSF 03.5
0C67: MOVWF 07
0C68: BCF 03.5
0C69: BCF 20.3
0C6A: MOVF 20,W
0C6B: BSF 03.5
0C6C: MOVWF 07
0C6D: MOVLW 01
0C6E: BCF 03.5
0C6F: MOVWF 14
0C70: MOVLW 00
0C71: BSF 03.5
0C72: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
0C73: MOVF 01,W
0C74: ANDLW C7
0C75: IORLW 08
0C76: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
0C77: BCF 03.5
0C78: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
0C79: MOVLW 00
0C7A: MOVWF 78
0C7B: MOVWF 12
0C7C: MOVLW 00
0C7D: BSF 03.5
0C7E: MOVWF 12
.................... setup_ccp1(CCP_OFF);
0C7F: BCF 03.5
0C80: BSF 20.2
0C81: MOVF 20,W
0C82: BSF 03.5
0C83: MOVWF 07
0C84: BCF 03.5
0C85: CLRF 17
0C86: BSF 03.5
0C87: CLRF 1B
0C88: CLRF 1C
0C89: MOVLW 01
0C8A: MOVWF 1D
.................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
0C8B: BCF 03.5
0C8C: BSF 03.6
0C8D: CLRF 07
0C8E: CLRF 08
0C8F: CLRF 09
....................
.................... printf("Elektronický kompas\r\n",);
0C90: MOVLW 27
0C91: MOVWF 0D
0C92: MOVLW 00
0C93: MOVWF 0F
0C94: BCF 0A.3
0C95: BCF 03.6
0C96: CALL 0AF
0C97: BSF 0A.3
.................... float az,k=0;
0C98: CLRF 28
0C99: CLRF 27
0C9A: CLRF 26
0C9B: CLRF 25
.................... set_mag();
0C9C: BCF 0A.3
0C9D: GOTO 11C
0C9E: BSF 0A.3
.................... signed int16 X,Y,Z;
.................... while(true)
.................... {
.................... az=azimut();
0C9F: GOTO 000
0CA0: MOVF 7A,W
0CA1: MOVWF 24
0CA2: MOVF 79,W
0CA3: MOVWF 23
0CA4: MOVF 78,W
0CA5: MOVWF 22
0CA6: MOVF 77,W
0CA7: MOVWF 21
....................
....................
....................
....................
.................... printf("Elektronický kompas \r\n",);
0CA8: MOVLW 3D
0CA9: BSF 03.6
0CAA: MOVWF 0D
0CAB: MOVLW 00
0CAC: MOVWF 0F
0CAD: BCF 0A.3
0CAE: BCF 03.6
0CAF: CALL 0AF
0CB0: BSF 0A.3
.................... printf("Simple Thermomether %10.2f \r\n", az);
0CB1: MOVLW 54
0CB2: BSF 03.6
0CB3: MOVWF 0D
0CB4: MOVLW 00
0CB5: MOVWF 0F
0CB6: BCF 03.0
0CB7: MOVLW 14
0CB8: BCF 03.6
0CB9: MOVWF 2F
0CBA: BCF 0A.3
0CBB: CALL 542
0CBC: BSF 0A.3
0CBD: MOVLW 09
0CBE: MOVWF 04
0CBF: MOVF 24,W
0CC0: MOVWF 32
0CC1: MOVF 23,W
0CC2: MOVWF 31
0CC3: MOVF 22,W
0CC4: MOVWF 30
0CC5: MOVF 21,W
0CC6: MOVWF 2F
0CC7: MOVLW 02
0CC8: MOVWF 33
0CC9: BCF 0A.3
0CCA: GOTO 5D3
0CCB: BSF 0A.3
0CCC: MOVLW 20
0CCD: MOVWF 40
0CCE: BCF 0A.3
0CCF: CALL 08D
0CD0: BSF 0A.3
0CD1: MOVLW 0D
0CD2: MOVWF 40
0CD3: BCF 0A.3
0CD4: CALL 08D
0CD5: BSF 0A.3
0CD6: MOVLW 0A
0CD7: MOVWF 40
0CD8: BCF 0A.3
0CD9: CALL 08D
0CDA: BSF 0A.3
....................
.................... //X=mag_readX();
.................... //Y=mag_readY();
.................... //Z=mag_readZ();
.................... printf("Simple Thermometherx %Ld \r\n", X);
0CDB: MOVLW 63
0CDC: BSF 03.6
0CDD: MOVWF 0D
0CDE: MOVLW 00
0CDF: MOVWF 0F
0CE0: BCF 03.0
0CE1: MOVLW 15
0CE2: BCF 03.6
0CE3: MOVWF 2F
0CE4: BCF 0A.3
0CE5: CALL 542
0CE6: BSF 0A.3
0CE7: MOVLW 10
0CE8: MOVWF 04
0CE9: MOVF 2A,W
0CEA: MOVWF 30
0CEB: MOVF 29,W
0CEC: MOVWF 2F
0CED: BCF 0A.3
0CEE: CALL 6BC
0CEF: BSF 0A.3
0CF0: MOVLW 20
0CF1: MOVWF 40
0CF2: BCF 0A.3
0CF3: CALL 08D
0CF4: BSF 0A.3
0CF5: MOVLW 0D
0CF6: MOVWF 40
0CF7: BCF 0A.3
0CF8: CALL 08D
0CF9: BSF 0A.3
0CFA: MOVLW 0A
0CFB: MOVWF 40
0CFC: BCF 0A.3
0CFD: CALL 08D
0CFE: BSF 0A.3
.................... printf("Simple Thermomethery %Ld \r\n", Y);
0CFF: MOVLW 71
0D00: BSF 03.6
0D01: MOVWF 0D
0D02: MOVLW 00
0D03: MOVWF 0F
0D04: BCF 03.0
0D05: MOVLW 15
0D06: BCF 03.6
0D07: MOVWF 2F
0D08: BCF 0A.3
0D09: CALL 542
0D0A: BSF 0A.3
0D0B: MOVLW 10
0D0C: MOVWF 04
0D0D: MOVF 2C,W
0D0E: MOVWF 30
0D0F: MOVF 2B,W
0D10: MOVWF 2F
0D11: BCF 0A.3
0D12: CALL 6BC
0D13: BSF 0A.3
0D14: MOVLW 20
0D15: MOVWF 40
0D16: BCF 0A.3
0D17: CALL 08D
0D18: BSF 0A.3
0D19: MOVLW 0D
0D1A: MOVWF 40
0D1B: BCF 0A.3
0D1C: CALL 08D
0D1D: BSF 0A.3
0D1E: MOVLW 0A
0D1F: MOVWF 40
0D20: BCF 0A.3
0D21: CALL 08D
0D22: BSF 0A.3
.................... printf("Simple Thermometherz %Ld \r\n", Z);
0D23: MOVLW 7F
0D24: BSF 03.6
0D25: MOVWF 0D
0D26: MOVLW 00
0D27: MOVWF 0F
0D28: BCF 03.0
0D29: MOVLW 15
0D2A: BCF 03.6
0D2B: MOVWF 2F
0D2C: BCF 0A.3
0D2D: CALL 542
0D2E: BSF 0A.3
0D2F: MOVLW 10
0D30: MOVWF 04
0D31: MOVF 2E,W
0D32: MOVWF 30
0D33: MOVF 2D,W
0D34: MOVWF 2F
0D35: BCF 0A.3
0D36: CALL 6BC
0D37: BSF 0A.3
0D38: MOVLW 20
0D39: MOVWF 40
0D3A: BCF 0A.3
0D3B: CALL 08D
0D3C: BSF 0A.3
0D3D: MOVLW 0D
0D3E: MOVWF 40
0D3F: BCF 0A.3
0D40: CALL 08D
0D41: BSF 0A.3
0D42: MOVLW 0A
0D43: MOVWF 40
0D44: BCF 0A.3
0D45: CALL 08D
0D46: BSF 0A.3
.................... Delay_ms(2000);
0D47: MOVLW 08
0D48: MOVWF 2F
0D49: MOVLW FA
0D4A: MOVWF 30
0D4B: BCF 0A.3
0D4C: CALL 108
0D4D: BSF 0A.3
0D4E: DECFSZ 2F,F
0D4F: GOTO 549
....................
.................... }
0D50: GOTO 49F
.................... }
0D51: SLEEP
Configuration Fuses:
Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
Word 2: 3FFF NOWRT BORV40