CCS PCM C Compiler, Version 4.106, 47914 05-5-13 12:54Filename: C:\Users\Honza\Documents\pic\azimut\main.lstROM used: 4548 words (56%)Largest free fragment is 2048RAM used: 32 (9%) at main() level97 (26%) worst caseStack: 4 locations*0000: MOVLW 100001: MOVWF 0A0002: GOTO 0AD0003: NOP.................... #include "C:\Users\Honza\Documents\pic\azimut\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)*015D: MOVLW 4F015E: MOVWF 04015F: BCF 03.70160: MOVF 00,W0161: BTFSC 03.20162: GOTO 1700163: MOVLW 020164: MOVWF 780165: CLRF 770166: DECFSZ 77,F0167: GOTO 1660168: DECFSZ 78,F0169: GOTO 165016A: MOVLW 97016B: MOVWF 77016C: DECFSZ 77,F016D: GOTO 16C016E: DECFSZ 00,F016F: GOTO 1630170: RETURN................................................................................ #define PIN_SDA PIN_C4.................... #define PIN_SCL PIN_C3.................... #use i2c(master, sda=PIN_SDA, scl=PIN_SCL)*00D8: MOVLW 0800D9: MOVWF 7800DA: NOP00DB: BCF 07.300DC: BCF 20.300DD: MOVF 20,W00DE: BSF 03.500DF: MOVWF 0700E0: NOP00E1: BCF 03.500E2: RLF 5D,F00E3: BCF 07.400E4: BTFSS 03.000E5: GOTO 0EC00E6: BSF 20.400E7: MOVF 20,W00E8: BSF 03.500E9: MOVWF 0700EA: GOTO 0F000EB: BCF 03.500EC: BCF 20.400ED: MOVF 20,W00EE: BSF 03.500EF: MOVWF 0700F0: NOP00F1: BCF 03.500F2: BSF 20.300F3: MOVF 20,W00F4: BSF 03.500F5: MOVWF 0700F6: BCF 03.500F7: BTFSS 07.300F8: GOTO 0F700F9: DECFSZ 78,F00FA: GOTO 0DA00FB: NOP00FC: BCF 07.300FD: BCF 20.300FE: MOVF 20,W00FF: BSF 03.50100: MOVWF 070101: NOP0102: BCF 03.50103: BSF 20.40104: MOVF 20,W0105: BSF 03.50106: MOVWF 070107: NOP0108: NOP0109: BCF 03.5010A: BSF 20.3010B: MOVF 20,W010C: BSF 03.5010D: MOVWF 07010E: BCF 03.5010F: BTFSS 07.30110: GOTO 10F0111: CLRF 780112: NOP0113: BTFSC 07.40114: BSF 78.00115: BCF 07.30116: BCF 20.30117: MOVF 20,W0118: BSF 03.50119: MOVWF 07011A: BCF 03.5011B: BCF 07.4011C: BCF 20.4011D: MOVF 20,W011E: BSF 03.5011F: MOVWF 070120: BCF 03.50121: RETURN*038F: MOVLW 080390: MOVWF 5E0391: MOVF 77,W0392: MOVWF 5F0393: BSF 20.40394: MOVF 20,W0395: BSF 03.50396: MOVWF 070397: NOP0398: BCF 03.50399: BSF 20.3039A: MOVF 20,W039B: BSF 03.5039C: MOVWF 07039D: BCF 03.5039E: BTFSS 07.3039F: GOTO 39E03A0: BTFSC 07.403A1: BSF 03.003A2: BTFSS 07.403A3: BCF 03.003A4: RLF 78,F03A5: NOP03A6: BCF 20.303A7: MOVF 20,W03A8: BSF 03.503A9: MOVWF 0703AA: BCF 03.503AB: BCF 07.303AC: DECFSZ 5E,F03AD: GOTO 39303AE: BSF 20.403AF: MOVF 20,W03B0: BSF 03.503B1: MOVWF 0703B2: NOP03B3: BCF 03.503B4: BCF 07.403B5: MOVF 5F,W03B6: BTFSC 03.203B7: GOTO 3BD03B8: BCF 20.403B9: MOVF 20,W03BA: BSF 03.503BB: MOVWF 0703BC: BCF 03.503BD: NOP03BE: BSF 20.303BF: MOVF 20,W03C0: BSF 03.503C1: MOVWF 0703C2: BCF 03.503C3: BTFSS 07.303C4: GOTO 3C303C5: NOP03C6: BCF 07.303C7: BCF 20.303C8: MOVF 20,W03C9: BSF 03.503CA: MOVWF 0703CB: NOP03CC: BCF 03.503CD: BCF 07.403CE: BCF 20.403CF: MOVF 20,W03D0: BSF 03.503D1: MOVWF 0703D2: BCF 03.503D3: RETURN.................... #use rs232(baud=9600,parity=N,xmit=PIN_C7,rcv=PIN_C6,bits=8) //rcv TXD xmit RXD*0222: BCF 20.70223: MOVF 20,W0224: BSF 03.50225: MOVWF 070226: BCF 03.50227: BCF 07.70228: MOVLW 080229: MOVWF 78022A: GOTO 22B022B: NOP022C: BSF 78.7022D: GOTO 23C022E: BCF 78.7022F: RRF 59,F0230: BTFSC 03.00231: BSF 07.70232: BTFSS 03.00233: BCF 07.70234: BSF 78.60235: GOTO 23C0236: BCF 78.60237: DECFSZ 78,F0238: GOTO 22F0239: GOTO 23A023A: NOP023B: BSF 07.7023C: MOVLW 3F023D: MOVWF 04023E: DECFSZ 04,F023F: GOTO 23E0240: NOP0241: BTFSC 78.70242: GOTO 22E0243: BTFSC 78.60244: GOTO 2360245: RETURN*028E: BSF 20.6028F: MOVF 20,W0290: BSF 03.50291: MOVWF 070292: BCF 03.50293: BTFSC 07.60294: GOTO 2930295: MOVLW 080296: MOVWF 770297: CLRF 490298: BSF 77.70299: GOTO 2A8029A: BCF 77.7029B: GOTO 2A8029C: BCF 03.0029D: BTFSC 07.6029E: BSF 03.0029F: RRF 49,F02A0: BSF 77.602A1: GOTO 2A802A2: BCF 77.602A3: DECFSZ 77,F02A4: GOTO 29C02A5: MOVF 49,W02A6: MOVWF 7802A7: GOTO 2B302A8: MOVLW 3F02A9: BTFSC 77.702AA: MOVLW 1102AB: MOVWF 7802AC: DECFSZ 78,F02AD: GOTO 2AC02AE: BTFSC 77.702AF: GOTO 29A02B0: BTFSC 77.602B1: GOTO 2A202B2: GOTO 29C02B3: 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;*095D: BCF 67.0.................... flag = 0;095E: BCF 67.1.................... y = x;095F: MOVF 5A,W0960: MOVWF 5E0961: MOVF 59,W0962: MOVWF 5D0963: MOVF 58,W0964: MOVWF 5C0965: MOVF 57,W0966: MOVWF 5B........................................ if (x < 0)0967: MOVF 5A,W0968: MOVWF 6B0969: MOVF 59,W096A: MOVWF 6A096B: MOVF 58,W096C: MOVWF 69096D: MOVF 57,W096E: MOVWF 68096F: CLRF 6F0970: CLRF 6E0971: CLRF 6D0972: CLRF 6C0973: BCF 0A.30974: CALL 5E70975: BSF 0A.30976: BTFSS 03.00977: GOTO 17C.................... {.................... s = 1;0978: BSF 67.0.................... y = -y;0979: MOVF 5C,W097A: XORLW 80097B: MOVWF 5C.................... }........................................ if (y > 1.0)097C: CLRF 6B097D: CLRF 6A097E: CLRF 69097F: MOVLW 7F0980: MOVWF 680981: MOVF 5E,W0982: MOVWF 6F0983: MOVF 5D,W0984: MOVWF 6E0985: MOVF 5C,W0986: MOVWF 6D0987: MOVF 5B,W0988: MOVWF 6C0989: BCF 0A.3098A: CALL 5E7098B: BSF 0A.3098C: BTFSS 03.0098D: GOTO 1A7.................... {.................... y = 1.0/y;098E: CLRF 6F098F: CLRF 6E0990: CLRF 6D0991: MOVLW 7F0992: MOVWF 6C0993: MOVF 5E,W0994: MOVWF 730995: MOVF 5D,W0996: MOVWF 720997: MOVF 5C,W0998: MOVWF 710999: MOVF 5B,W099A: MOVWF 70099B: BCF 0A.3099C: CALL 506099D: BSF 0A.3099E: MOVF 7A,W099F: MOVWF 5E09A0: MOVF 79,W09A1: MOVWF 5D09A2: MOVF 78,W09A3: MOVWF 5C09A4: MOVF 77,W09A5: MOVWF 5B.................... flag = 1;09A6: BSF 67.1.................... }........................................ res = pat[0]*y*y + pat[1];09A7: MOVLW 0A09A8: MOVWF 6F09A9: MOVLW 8909AA: MOVWF 6E09AB: MOVLW 3409AC: MOVWF 6D09AD: MOVLW 7C09AE: MOVWF 6C09AF: MOVF 5E,W09B0: MOVWF 7309B1: MOVF 5D,W09B2: MOVWF 7209B3: MOVF 5C,W09B4: MOVWF 7109B5: MOVF 5B,W09B6: MOVWF 7009B7: BCF 0A.309B8: CALL 62609B9: BSF 0A.309BA: MOVF 77,W09BB: MOVWF 6809BC: MOVF 78,W09BD: MOVWF 6909BE: MOVF 79,W09BF: MOVWF 6A09C0: MOVF 7A,W09C1: MOVWF 6B09C2: MOVWF 6F09C3: MOVF 79,W09C4: MOVWF 6E09C5: MOVF 78,W09C6: MOVWF 6D09C7: MOVF 77,W09C8: MOVWF 6C09C9: MOVF 5E,W09CA: MOVWF 7309CB: MOVF 5D,W09CC: MOVWF 7209CD: MOVF 5C,W09CE: MOVWF 7109CF: MOVF 5B,W09D0: MOVWF 7009D1: BCF 0A.309D2: CALL 62609D3: BSF 0A.309D4: MOVF 77,W09D5: MOVWF 6809D6: MOVF 78,W09D7: MOVWF 6909D8: MOVF 79,W09D9: MOVWF 6A09DA: MOVF 7A,W09DB: MOVWF 6B09DC: BCF 03.109DD: MOVF 7A,W09DE: MOVWF 6F09DF: MOVF 79,W09E0: MOVWF 6E09E1: MOVF 78,W09E2: MOVWF 6D09E3: MOVF 77,W09E4: MOVWF 6C09E5: MOVLW 7C09E6: MOVWF 7309E7: MOVLW 7909E8: MOVWF 7209E9: MOVLW 3509EA: MOVWF 7109EB: MOVLW 8109EC: MOVWF 7009ED: CALL 00009EE: MOVF 7A,W09EF: MOVWF 6209F0: MOVF 79,W09F1: MOVWF 6109F2: MOVF 78,W09F3: MOVWF 6009F4: MOVF 77,W09F5: MOVWF 5F.................... res = res*y*y + pat[2];09F6: MOVF 62,W09F7: MOVWF 6F09F8: MOVF 61,W09F9: MOVWF 6E09FA: MOVF 60,W09FB: MOVWF 6D09FC: MOVF 5F,W09FD: MOVWF 6C09FE: MOVF 5E,W09FF: MOVWF 730A00: MOVF 5D,W0A01: MOVWF 720A02: MOVF 5C,W0A03: MOVWF 710A04: MOVF 5B,W0A05: MOVWF 700A06: BCF 0A.30A07: CALL 6260A08: BSF 0A.30A09: MOVF 77,W0A0A: MOVWF 680A0B: MOVF 78,W0A0C: MOVWF 690A0D: MOVF 79,W0A0E: MOVWF 6A0A0F: MOVF 7A,W0A10: MOVWF 6B0A11: MOVWF 6F0A12: MOVF 79,W0A13: MOVWF 6E0A14: MOVF 78,W0A15: MOVWF 6D0A16: MOVF 77,W0A17: MOVWF 6C0A18: MOVF 5E,W0A19: MOVWF 730A1A: MOVF 5D,W0A1B: MOVWF 720A1C: MOVF 5C,W0A1D: MOVWF 710A1E: MOVF 5B,W0A1F: MOVWF 700A20: BCF 0A.30A21: CALL 6260A22: BSF 0A.30A23: MOVF 77,W0A24: MOVWF 680A25: MOVF 78,W0A26: MOVWF 690A27: MOVF 79,W0A28: MOVWF 6A0A29: MOVF 7A,W0A2A: MOVWF 6B0A2B: BCF 03.10A2C: MOVF 7A,W0A2D: MOVWF 6F0A2E: MOVF 79,W0A2F: MOVWF 6E0A30: MOVF 78,W0A31: MOVWF 6D0A32: MOVF 77,W0A33: MOVWF 6C0A34: MOVLW 3F0A35: MOVWF 730A36: MOVLW 020A37: MOVWF 720A38: MOVLW 330A39: MOVWF 710A3A: MOVLW 830A3B: MOVWF 700A3C: CALL 0000A3D: MOVF 7A,W0A3E: MOVWF 620A3F: MOVF 79,W0A40: MOVWF 610A41: MOVF 78,W0A42: MOVWF 600A43: MOVF 77,W0A44: MOVWF 5F.................... res = res*y*y + pat[3];0A45: MOVF 62,W0A46: MOVWF 6F0A47: MOVF 61,W0A48: MOVWF 6E0A49: MOVF 60,W0A4A: MOVWF 6D0A4B: MOVF 5F,W0A4C: MOVWF 6C0A4D: MOVF 5E,W0A4E: MOVWF 730A4F: MOVF 5D,W0A50: MOVWF 720A51: MOVF 5C,W0A52: MOVWF 710A53: MOVF 5B,W0A54: MOVWF 700A55: BCF 0A.30A56: CALL 6260A57: BSF 0A.30A58: MOVF 77,W0A59: MOVWF 680A5A: MOVF 78,W0A5B: MOVWF 690A5C: MOVF 79,W0A5D: MOVWF 6A0A5E: MOVF 7A,W0A5F: MOVWF 6B0A60: MOVWF 6F0A61: MOVF 79,W0A62: MOVWF 6E0A63: MOVF 78,W0A64: MOVWF 6D0A65: MOVF 77,W0A66: MOVWF 6C0A67: MOVF 5E,W0A68: MOVWF 730A69: MOVF 5D,W0A6A: MOVWF 720A6B: MOVF 5C,W0A6C: MOVWF 710A6D: MOVF 5B,W0A6E: MOVWF 700A6F: BCF 0A.30A70: CALL 6260A71: BSF 0A.30A72: MOVF 77,W0A73: MOVWF 680A74: MOVF 78,W0A75: MOVWF 690A76: MOVF 79,W0A77: MOVWF 6A0A78: MOVF 7A,W0A79: MOVWF 6B0A7A: BCF 03.10A7B: MOVF 7A,W0A7C: MOVWF 6F0A7D: MOVF 79,W0A7E: MOVWF 6E0A7F: MOVF 78,W0A80: MOVWF 6D0A81: MOVF 77,W0A82: MOVWF 6C0A83: MOVLW 330A84: MOVWF 730A85: MOVLW 8C0A86: MOVWF 720A87: MOVLW 1E0A88: MOVWF 710A89: MOVLW 830A8A: MOVWF 700A8B: CALL 0000A8C: MOVF 7A,W0A8D: MOVWF 620A8E: MOVF 79,W0A8F: MOVWF 610A90: MOVF 78,W0A91: MOVWF 600A92: MOVF 77,W0A93: MOVWF 5F........................................ r = qat[0]*y*y + qat[1];0A94: CLRF 6F0A95: CLRF 6E0A96: CLRF 6D0A97: MOVLW 7F0A98: MOVWF 6C0A99: MOVF 5E,W0A9A: MOVWF 730A9B: MOVF 5D,W0A9C: MOVWF 720A9D: MOVF 5C,W0A9E: MOVWF 710A9F: MOVF 5B,W0AA0: MOVWF 700AA1: BCF 0A.30AA2: CALL 6260AA3: BSF 0A.30AA4: MOVF 77,W0AA5: MOVWF 680AA6: MOVF 78,W0AA7: MOVWF 690AA8: MOVF 79,W0AA9: MOVWF 6A0AAA: MOVF 7A,W0AAB: MOVWF 6B0AAC: MOVWF 6F0AAD: MOVF 79,W0AAE: MOVWF 6E0AAF: MOVF 78,W0AB0: MOVWF 6D0AB1: MOVF 77,W0AB2: MOVWF 6C0AB3: MOVF 5E,W0AB4: MOVWF 730AB5: MOVF 5D,W0AB6: MOVWF 720AB7: MOVF 5C,W0AB8: MOVWF 710AB9: MOVF 5B,W0ABA: MOVWF 700ABB: BCF 0A.30ABC: CALL 6260ABD: BSF 0A.30ABE: MOVF 77,W0ABF: MOVWF 680AC0: MOVF 78,W0AC1: MOVWF 690AC2: MOVF 79,W0AC3: MOVWF 6A0AC4: MOVF 7A,W0AC5: MOVWF 6B0AC6: BCF 03.10AC7: MOVF 7A,W0AC8: MOVWF 6F0AC9: MOVF 79,W0ACA: MOVWF 6E0ACB: MOVF 78,W0ACC: MOVWF 6D0ACD: MOVF 77,W0ACE: MOVWF 6C0ACF: MOVLW 1B0AD0: MOVWF 730AD1: MOVLW E40AD2: MOVWF 720AD3: MOVLW 350AD4: MOVWF 710AD5: MOVLW 820AD6: MOVWF 700AD7: CALL 0000AD8: MOVF 7A,W0AD9: MOVWF 660ADA: MOVF 79,W0ADB: MOVWF 650ADC: MOVF 78,W0ADD: MOVWF 640ADE: MOVF 77,W0ADF: MOVWF 63.................... r = r*y*y + qat[2];0AE0: MOVF 66,W0AE1: MOVWF 6F0AE2: MOVF 65,W0AE3: MOVWF 6E0AE4: MOVF 64,W0AE5: MOVWF 6D0AE6: MOVF 63,W0AE7: MOVWF 6C0AE8: MOVF 5E,W0AE9: MOVWF 730AEA: MOVF 5D,W0AEB: MOVWF 720AEC: MOVF 5C,W0AED: MOVWF 710AEE: MOVF 5B,W0AEF: MOVWF 700AF0: BCF 0A.30AF1: CALL 6260AF2: BSF 0A.30AF3: MOVF 77,W0AF4: MOVWF 680AF5: MOVF 78,W0AF6: MOVWF 690AF7: MOVF 79,W0AF8: MOVWF 6A0AF9: MOVF 7A,W0AFA: MOVWF 6B0AFB: MOVWF 6F0AFC: MOVF 79,W0AFD: MOVWF 6E0AFE: MOVF 78,W0AFF: MOVWF 6D0B00: MOVF 77,W0B01: MOVWF 6C0B02: MOVF 5E,W0B03: MOVWF 730B04: MOVF 5D,W0B05: MOVWF 720B06: MOVF 5C,W0B07: MOVWF 710B08: MOVF 5B,W0B09: MOVWF 700B0A: BCF 0A.30B0B: CALL 6260B0C: BSF 0A.30B0D: MOVF 77,W0B0E: MOVWF 680B0F: MOVF 78,W0B10: MOVWF 690B11: MOVF 79,W0B12: MOVWF 6A0B13: MOVF 7A,W0B14: MOVWF 6B0B15: BCF 03.10B16: MOVF 7A,W0B17: MOVWF 6F0B18: MOVF 79,W0B19: MOVWF 6E0B1A: MOVF 78,W0B1B: MOVWF 6D0B1C: MOVF 77,W0B1D: MOVWF 6C0B1E: MOVLW A40B1F: MOVWF 730B20: MOVLW DB0B21: MOVWF 720B22: MOVLW 670B23: MOVWF 710B24: MOVLW 830B25: MOVWF 700B26: CALL 0000B27: MOVF 7A,W0B28: MOVWF 660B29: MOVF 79,W0B2A: MOVWF 650B2B: MOVF 78,W0B2C: MOVWF 640B2D: MOVF 77,W0B2E: MOVWF 63.................... r = r*y*y + qat[3];0B2F: MOVF 66,W0B30: MOVWF 6F0B31: MOVF 65,W0B32: MOVWF 6E0B33: MOVF 64,W0B34: MOVWF 6D0B35: MOVF 63,W0B36: MOVWF 6C0B37: MOVF 5E,W0B38: MOVWF 730B39: MOVF 5D,W0B3A: MOVWF 720B3B: MOVF 5C,W0B3C: MOVWF 710B3D: MOVF 5B,W0B3E: MOVWF 700B3F: BCF 0A.30B40: CALL 6260B41: BSF 0A.30B42: MOVF 77,W0B43: MOVWF 680B44: MOVF 78,W0B45: MOVWF 690B46: MOVF 79,W0B47: MOVWF 6A0B48: MOVF 7A,W0B49: MOVWF 6B0B4A: MOVWF 6F0B4B: MOVF 79,W0B4C: MOVWF 6E0B4D: MOVF 78,W0B4E: MOVWF 6D0B4F: MOVF 77,W0B50: MOVWF 6C0B51: MOVF 5E,W0B52: MOVWF 730B53: MOVF 5D,W0B54: MOVWF 720B55: MOVF 5C,W0B56: MOVWF 710B57: MOVF 5B,W0B58: MOVWF 700B59: BCF 0A.30B5A: CALL 6260B5B: BSF 0A.30B5C: MOVF 77,W0B5D: MOVWF 680B5E: MOVF 78,W0B5F: MOVWF 690B60: MOVF 79,W0B61: MOVWF 6A0B62: MOVF 7A,W0B63: MOVWF 6B0B64: BCF 03.10B65: MOVF 7A,W0B66: MOVWF 6F0B67: MOVF 79,W0B68: MOVWF 6E0B69: MOVF 78,W0B6A: MOVWF 6D0B6B: MOVF 77,W0B6C: MOVWF 6C0B6D: MOVLW 330B6E: MOVWF 730B6F: MOVLW 8C0B70: MOVWF 720B71: MOVLW 1E0B72: MOVWF 710B73: MOVLW 830B74: MOVWF 700B75: CALL 0000B76: MOVF 7A,W0B77: MOVWF 660B78: MOVF 79,W0B79: MOVWF 650B7A: MOVF 78,W0B7B: MOVWF 640B7C: MOVF 77,W0B7D: MOVWF 63........................................ res = y*res/r;0B7E: MOVF 5E,W0B7F: MOVWF 6F0B80: MOVF 5D,W0B81: MOVWF 6E0B82: MOVF 5C,W0B83: MOVWF 6D0B84: MOVF 5B,W0B85: MOVWF 6C0B86: MOVF 62,W0B87: MOVWF 730B88: MOVF 61,W0B89: MOVWF 720B8A: MOVF 60,W0B8B: MOVWF 710B8C: MOVF 5F,W0B8D: MOVWF 700B8E: BCF 0A.30B8F: CALL 6260B90: BSF 0A.30B91: MOVF 77,W0B92: MOVWF 680B93: MOVF 78,W0B94: MOVWF 690B95: MOVF 79,W0B96: MOVWF 6A0B97: MOVF 7A,W0B98: MOVWF 6B0B99: MOVWF 6F0B9A: MOVF 79,W0B9B: MOVWF 6E0B9C: MOVF 78,W0B9D: MOVWF 6D0B9E: MOVF 77,W0B9F: MOVWF 6C0BA0: MOVF 66,W0BA1: MOVWF 730BA2: MOVF 65,W0BA3: MOVWF 720BA4: MOVF 64,W0BA5: MOVWF 710BA6: MOVF 63,W0BA7: MOVWF 700BA8: BCF 0A.30BA9: CALL 5060BAA: BSF 0A.30BAB: MOVF 7A,W0BAC: MOVWF 620BAD: MOVF 79,W0BAE: MOVWF 610BAF: MOVF 78,W0BB0: MOVWF 600BB1: MOVF 77,W0BB2: MOVWF 5F............................................................ if (flag) // for |x| > 10BB3: BTFSS 67.10BB4: GOTO 3CF.................... res = PI_DIV_BY_TWO - res;0BB5: BSF 03.10BB6: MOVLW DB0BB7: MOVWF 6F0BB8: MOVLW 0F0BB9: MOVWF 6E0BBA: MOVLW 490BBB: MOVWF 6D0BBC: MOVLW 7F0BBD: MOVWF 6C0BBE: MOVF 62,W0BBF: MOVWF 730BC0: MOVF 61,W0BC1: MOVWF 720BC2: MOVF 60,W0BC3: MOVWF 710BC4: MOVF 5F,W0BC5: MOVWF 700BC6: CALL 0000BC7: MOVF 7A,W0BC8: MOVWF 620BC9: MOVF 79,W0BCA: MOVWF 610BCB: MOVF 78,W0BCC: MOVWF 600BCD: MOVF 77,W0BCE: MOVWF 5F.................... if (s)0BCF: BTFSS 67.00BD0: GOTO 3D4.................... res = -res;0BD1: MOVF 60,W0BD2: XORLW 800BD3: MOVWF 60........................................ return(res);0BD4: MOVF 5F,W0BD5: MOVWF 770BD6: MOVF 60,W0BD7: MOVWF 780BD8: MOVF 61,W0BD9: MOVWF 790BDA: MOVF 62,W0BDB: MOVWF 7A.................... }0BDC: RETURN.................... //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 <stdio.h>.................... ///////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2003 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ///////////////////////////////////////////////////////////////////////////........................................ #ifndef _STDIO.................... #define _STDIO.................... #include <string.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. ////.................... ////////////////////////////////////////////////////////////////////////////........................................ #ifndef _STRING.................... #define _STRING.................... #include <stddef.h>.................... ///////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2003 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ///////////////////////////////////////////////////////////////////////////........................................ #ifndef _STDDEF........................................ #define _STDDEF........................................ #if sizeof(unsigned int8 *)==1.................... #define ptrdiff_t unsigned int8.................... #else.................... #define ptrdiff_t unsigned int16.................... #endif........................................ #define size_t unsigned int8.................... #define wchar_t char.................... #define NULL 0........................................ #define offsetof(s,f) (offsetofbit(s,f)/8)........................................ #endif........................................ #include <ctype.h>.................... ////////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2003 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ////////////////////////////////////////////////////////////////////////////........................................ #ifndef _CTYPE.................... #define _CTYPE........................................ #define islower(x) isamong(x,"abcdefghijklmnopqrstuvwxyz").................... #define isupper(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZ").................... #define isalnum(x) isamong(x,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").................... #define isalpha(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").................... #define isdigit(x) isamong(x,"0123456789").................... #define isspace(x) ((x)==' ').................... #define isxdigit(x) isamong(x,"0123456789ABCDEFabcdef").................... #define iscntrl(x) ((x)<' ').................... #define isprint(x) ((x)>=' ').................... #define isgraph(x) ((x)>' ').................... #define ispunct(x) (((x)>' ')&&!isalnum(x))........................................ #endif........................................................................................................................ //////////////////////////////////////////////.................... //// Uncomment the following define to ////.................... //// allow some functions to use a ////.................... //// quicker algorithm, but use more ROM ////.................... //// ////.................... //// #define FASTER_BUT_MORE_ROM ////.................... //////////////////////////////////////////////................................................................................ /*Copying functions*/.................... /* standard template:.................... void *memmove(void *s1, void *s2, size_t n)..................... Copies max of n characters safely (not following ending '\0').................... from s2 in s1; if s2 has less than n characters, appends 0 */........................................ char *memmove(void *s1,char *s2,size_t n).................... {.................... char *sc1;.................... char *sc2;.................... sc1=s1;.................... sc2=s2;.................... if(sc2<sc1 && sc1 <sc2 +n).................... for(sc1+=n,sc2+=n;0<n;--n).................... *--sc1=*--sc2;.................... else.................... for(;0<n;--n).................... *sc1++=*sc2++;.................... return s1;.................... }........................................ /* Standard template: char *strcpy(char *s1, const char *s2).................... copies the string s2 including the null character to s1..................... This is a compiler built in to handle the different address.................... spaces */........................................ #define strcopy strcpy........................................ /* standard template:.................... char *strncpy(char *s1, const char *s2, size_t n)..................... Copies max of n characters (not following ending '\0').................... from s2 in s1; if s2 has less than n characters, appends 0 */........................................ char *strncpy(char *s1, char *s2, size_t n).................... {.................... char *s;........................................ for (s = s1; n > 0 && *s2 != '\0'; n--).................... *s++ = *s2++;.................... for (; n > 0; n--).................... *s++ = '\0';........................................ return(s1);.................... }.................... /***********************************************************/........................................ /*concatenation functions*/.................... /* standard template: char *strcat(char *s1, const char *s2).................... appends s2 to s1*/........................................ char *strcat(char *s1, char *s2).................... {.................... char *s;........................................ for (s = s1; *s != '\0'; ++s);.................... while(*s2 != '\0').................... {.................... *s = *s2;.................... ++s;.................... ++s2;.................... }........................................ *s = '\0';.................... return(s1);.................... }.................... /* standard template: char *strncat(char *s1, char *s2,size_t n).................... appends not more than n characters from s2 to s1*/........................................ char *strncat(char *s1, char *s2, size_t n).................... {.................... char *s;........................................ for (s = s1; *s != '\0'; ++s);.................... while(*s2 != '\0' && 0<n).................... {.................... *s = *s2;.................... ++s;.................... ++s2;.................... --n;.................... }........................................ *s = '\0';.................... return(s1);.................... }........................................ /***********************************************************/............................................................ /*comparison functions*/.................... /* standard template: signed int memcmp(void *s1, void *s2)..................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */........................................ signed int8 memcmp(void * s1,char *s2,size_t n).................... {.................... char *su1, *su2;.................... for(su1=s1, su2=s2; 0<n; ++su1, ++su2, --n).................... {.................... if(*su1!=*su2).................... return ((*su1<*su2)?-1:+1);.................... }.................... return 0;.................... }........................................ /* standard template: int strcmp(const char *s1, const char *s2)..................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */........................................ signed int8 strcmp(char *s1, char *s2).................... {.................... for (; *s1 == *s2; s1++, s2++).................... if (*s1 == '\0').................... return(0);.................... return((*s1 < *s2) ? -1: 1);.................... }.................... /* standard template: int strcoll(const char *s1, const char *s2)..................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */........................................ signed int8 strcoll(char *s1, char *s2).................... {.................... for (; *s1 == *s2; s1++, s2++).................... if (*s1 == '\0').................... return(0);.................... return((*s1 < *s2) ? -1: 1);.................... }........................................ /* standard template:.................... int strncmp(const char *s1, const char *s2, size_t n)..................... Compares max of n characters (not following 0) from s1 to s2;.................... returns same as strcmp */........................................ signed int8 strncmp(char *s1, char *s2, size_t n).................... {.................... for (; n > 0; s1++, s2++, n--).................... if (*s1 != *s2).................... return((*s1 <*s2) ? -1: 1);.................... else if (*s1 == '\0').................... return(0);.................... return(0);.................... }.................... /* standard template:.................... int strxfrm(const char *s1, const char *s2, size_t n)..................... transforms maximum of n characters from s2 and places them into s1*/.................... size_t strxfrm(char *s1, char *s2, size_t n).................... {.................... char *s;.................... unsigned int8 n1;.................... n1=n;.................... for (s = s1; n > 0 && *s2 != '\0'; n--).................... *s++ = *s2++;.................... for (; n > 0; n--).................... *s++ = '\0';........................................ return(n1);.................... }........................................................................................................................ /***********************************************************/.................... /*Search functions*/.................... /* standard template: void *memchr(const char *s, int c)..................... Finds first occurrence of c in n characters of s */........................................ char *memchr(void *s,unsigned int8 c,size_t n).................... {.................... char uc;.................... char *su;.................... uc=c;.................... for(su=s;0<n;++su,--n).................... if(*su==uc).................... return su;.................... return NULL;.................... }........................................ /* standard template: char *strchr(const char *s, int c)..................... Finds first occurrence of c in s */........................................ char *strchr(char *s, unsigned int8 c).................... {.................... for (; *s != c; s++).................... if (*s == '\0').................... return(0);.................... return(s);.................... }.................... /* standard template:.................... size_t strcspn(const char *s1, const char *s2)..................... Computes length of max initial segment of s1 that.................... consists entirely of characters NOT from s2*/........................................ unsigned int8 strcspn(char *s1, char *s2).................... {.................... char *sc1, *sc2;........................................ for (sc1 = s1; *sc1 != 0; sc1++).................... for (sc2 = s2; *sc2 != 0; sc2++).................... if (*sc1 == *sc2).................... return(sc1 - s1);.................... return(sc1 - s1);.................... }.................... /* standard template:.................... char *strpbrk(const char *s1, const char *s2)..................... Locates first occurence of any character from s2 in s1;.................... returns s1 if s2 is empty string */........................................ char *strpbrk(char *s1, char *s2).................... {.................... char *sc1, *sc2;........................................ for (sc1 = s1; *sc1 != 0; sc1++).................... for (sc2 = s2; *sc2 != 0; sc2++).................... if (*sc1 == *sc2).................... return(sc1);.................... return(0);.................... }............................................................ /* standard template: char *strrchr(const char *s, int c)..................... Finds last occurrence of c in s */........................................ char *strrchr(char *s, unsigned int8 c).................... {.................... char *p;........................................ for (p = 0; ; s++).................... {.................... if (*s == c).................... p = s;.................... if (*s == '\0').................... return(p);.................... }.................... }.................... /* computes length of max initial segment of s1 consisting.................... entirely of characters from s2 */........................................ unsigned int8 strspn(char *s1, char *s2).................... {.................... char *sc1, *sc2;........................................ for (sc1 = s1; *sc1 != 0; sc1++).................... for (sc2 = s2; ; sc2++).................... if (*sc2 == '\0').................... return(sc1 - s1);.................... else if (*sc1 == *sc2).................... break;.................... return(sc1 - s1);.................... }.................... /* standard template:.................... char *strstr(const char *s1, const char *s2);.................... Locates first occurence of character sequence s2 in s1;.................... returns 0 if s2 is empty string........................................ Uncomment #define FASTER_BUT_MORE_ROM at the top of the.................... file to use the faster algorithm */.................... char *strstr(char *s1, char *s2).................... {.................... char *s, *t;........................................ #ifdef FASTER_BUT_MORE_ROM.................... if (*s2 == '\0').................... return(s1);.................... #endif........................................ while (*s1).................... {.................... for(s = s1, t = s2; *t && (*s == *t); ++s, ++t);........................................ if (*t == '\0').................... return s1;.................... ++s1;.................... #ifdef FASTER_BUT_MORE_ROM.................... while(*s1 != '\0' && *s1 != *s2).................... ++s1;.................... #endif.................... }.................... return 0;.................... }........................................ /* standard template: char *strtok(char *s1, const char *s2)......................................... Finds next token in s1 delimited by a character from separator.................... string s2 (which can be different from call to call). First call.................... starts at beginning of s1 searching for first character NOT.................... contained in s2; returns 0 if none is found..................... If one is found, it is the start of first token (return value)..................... Function then searches from there for a character contained in s2..................... If none is found, current token extends to end of s1, and subsequent.................... searches for a token will return 0. If one is found, it is.................... overwritten by '\0', which terminates current token. Function saves.................... pointer to following character from which next search will start..................... Each subsequent call, with 0 as first argument, starts searching.................... from saved pointer */........................................ char *strtok(char *s1, char *s2).................... {.................... char *beg, *end;.................... static char *save;*10CE: CLRF 2110CF: CLRF 22........................................ beg = (s1)? s1: save;.................... beg += strspn(beg, s2);.................... if (*beg == '\0').................... {.................... *save = ' ';.................... return(0);.................... }.................... end = strpbrk(beg, s2);.................... if (*end != '\0').................... {.................... *end = '\0';.................... end++;.................... }.................... save = end;.................... return(beg);.................... }........................................ /*****************************************************************/.................... /*Miscellaneous functions*/.................... /* standard template.................... maps error number in errnum to an error message string.................... Returns: Pointer to string.................... */.................... #ifdef _ERRNO.................... char * strerror(unsigned int8 errnum).................... {.................... char s[15];.................... switch( errnum).................... {.................... case 0:.................... strcpy(s,"no errors");.................... return s;.................... case EDOM :.................... strcpy(s,"domain error");.................... return s;.................... case ERANGE:.................... strcpy(s,"range error");.................... return s;.................... }.................... }.................... #ENDIF.................... /* standard template: size_t strlen(const char *s)..................... Computes length of s1 (preceding terminating 0) */........................................ unsigned int8 strlen(char *s).................... {.................... char *sc;........................................ for (sc = s; *sc != 0; sc++);.................... return(sc - s);.................... }........................................ /* standard template: size_t stricmp(const char *s1, const char *s2)..................... Compares s1 to s2 ignoring case (upper vs. lower) */........................................ signed int8 stricmp(char *s1, char *s2).................... {.................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32));.................... s1++, s2++).................... if (*s1 == '\0').................... return(0);.................... return((*s1 < *s2) ? -1: 1);.................... }............................................................ /* standard template: char *strlwr(char *s)..................... Replaces uppercase letters by lowercase;.................... returns pointer to new string s */........................................ char *strlwr(char *s).................... {.................... char *p;........................................ for (p = s; *p != '\0'; p++).................... if (*p >= 'A' && *p <='Z').................... *p += 'a' - 'A';.................... return(s);.................... }............................................................ /************************************************************/............................................................ #endif........................................ #ifndef getc.................... #define getc getch.................... #define getchar getch.................... #define puts(s) {printf(s); putchar(13); putchar(10);}.................... #define putc putchar.................... #endif.................... /* maps error number to an error message. Writes a sequence of characters to.................... stderr stream thus: if s is not null then string pointed to by s follwed by.................... a colon (:) and a space and the appropriate error message returned by strerror.................... function with argument errno........................................ Returns: no value.................... */........................................ #ifdef _ERRNO.................... void perror(char *s).................... {.................... if(s).................... fprintf(STDERR,"%s: ",s);.................... fprintf(STDERR,"%s\r\n",strerror(errno));.................... }.................... #endif.................... #endif............................................................ #include <stdlib.h>.................... ///////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2007 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. ////.................... ///////////////////////////////////////////////////////////////////////////........................................ #ifndef _STDLIB.................... #define _STDLIB........................................ //---------------------------------------------------------------------------.................... // Definitions and types.................... //---------------------------------------------------------------------------........................................ #ifndef RAND_MAX.................... #define RAND_MAX 32767 // The value of which is the maximum value.................... // ... returned by the rand function.................... #endif............................................................ #IF (sizeof(int16*)>1).................... #DEFINE LONG_POINTERS 1.................... #ELSE.................... #DEFINE LONG_POINTERS 0.................... #ENDIF........................................ typedef struct {.................... signed int quot;.................... signed int rem;.................... } div_t;........................................ typedef struct {.................... signed long quot;.................... signed long rem;.................... } ldiv_t;........................................ #include <stddef.h>.................... ///////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2003 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ///////////////////////////////////////////////////////////////////////////........................................ #ifndef _STDDEF........................................ #define _STDDEF........................................ #if sizeof(unsigned int8 *)==1.................... #define ptrdiff_t unsigned int8.................... #else.................... #define ptrdiff_t unsigned int16.................... #endif........................................ #define size_t unsigned int8.................... #define wchar_t char.................... #define NULL 0........................................ #define offsetof(s,f) (offsetofbit(s,f)/8)........................................ #endif............................................................ //---------------------------------------------------------------------------.................... // String conversion functions.................... //---------------------------------------------------------------------------........................................ /* Standard template: signed int atoi(char * s).................... * converts the initial portion of the string s to a signed int.................... * returns the converted value if any, 0 otherwise.................... */.................... signed int atoi(char *s);........................................ /* Syntax: signed int32 atoi32(char * s).................... converts the initial portion of the string s to a signed int32.................... returns the converted value if any, 0 otherwise*/.................... #if (sizeof(long)==4).................... #define atoi32(s) atol(s).................... #else.................... signed int32 atoi32(char *s);.................... #endif........................................ #if defined(__PCD__).................... // The following functions only work on the 24 bit compiler.................... // for the 30F, 33F, 24F and 24H parts.................... /* Syntax: signed int48 atoi48(char * s).................... converts the initial portion of the string s to a signed int48.................... returns the converted value if any, 0 otherwise*/........................................ signed int48 atoi48(char *s);........................................ /* Syntax: signed int64 atoi64(char * s).................... converts the initial portion of the string s to a signed int64.................... returns the converted value if any, 0 otherwise*/.................... signed int64 atoi64(char *s);.................... #endif........................................ /* Syntax: char * itoa(signed int32 num, int8 base, char * s).................... converts the signed int32 to a string and.................... returns the converted value if any, 0 otherwise*/.................... char * itoa(signed int32 num, unsigned int base, char * s);........................................ /* Standard template: signed int16 atol(char * s).................... * converts the initial portion of the string s to a signed int16.................... * returns the converted value if any, 0 otherwise.................... */.................... signed long atol(char *s);........................................ /* Standard template: int16 strtoul(char * s,char *endptr,signed int base).................... * converts the initial portion of the string s, represented as an.................... * integral value of radix base to a signed long..................... * Returns the converted value if any, 0 otherwise.................... * the final string is returned in the endptr, if endptr is not null.................... */.................... signed long strtol(char *s,char *endptr, signed int base);........................................ /* Standard template: int16 strtoul(char * s,char *endptr,signed int base).................... * converts the initial portion of the string s, represented as an.................... * integral value of radix base to a unsigned long..................... * returns the converted value if any, 0 otherwise.................... * the final string is returned in the endptr, if endptr is not null.................... */.................... unsigned long strtoul(char *s,char *endptr, signed int base);........................................ /* Standart template: float strtof(char * s,char *endptr).................... float48 strtof48(char *s,char *endptr);.................... float64 strtod(char *s,char *endptr);.................... * converts the initial portion of the string s to a float32, float48 or float64,.................... * returns the converted value if any, 0 otherwise.................... * the final string is returned in the endptr, if endptr is not null.................... */.................... float strtof(char *s,char *endptr);.................... #if defined(__PCD__).................... float48 strtof48(char *s,char *endptr);.................... float64 strtod(char *s,char *endptr);.................... #else.................... //provided for compatibility.................... #define strtof48(s, e) strtof(s, e).................... #define strtod(s, e) strtof(s, e).................... #endif........................................ /* Standard template: float32 atof(char * s).................... * converts the initial portion of the string s to a float..................... * returns the converted value if any, 0 otherwise.................... */.................... #define atof(s) strtof(s, 0)........................................ #if defined(__PCD__).................... // The following functions only work on the 24 bit compiler.................... // for the 30F, 33F, 24F and 24H parts........................................ /* Standard template: float48 atof48(char * s).................... * converts the initial portion of the string s to a float..................... * returns the converted value if any, 0 otherwise.................... */.................... #define atof48(s) strtof48(s, 0)........................................ /* Standard template: float64 atof64(char * s).................... * converts the initial portion of the string s to a float..................... * returns the converted value if any, 0 otherwise.................... */.................... #define atof64(s) strtod(s, 0).................... #endif........................................ /* Standard template: float32 atoe(char * s).................... * converts the initial portion of the string s to a float..................... * returns the converted value if any, 0 otherwise.................... * also handles E format numbers.................... */.................... #if !defined(__PCD__).................... float atoe(char * s);.................... #endif........................................ #if defined(__PCD__).................... float32 atoe(char * s);.................... #endif........................................ //---------------------------------------------------------------------------.................... // Pseudo-random sequence generation functions.................... //---------------------------------------------------------------------------........................................ /* The rand function computes a sequence of pseudo-random integers in.................... * the range 0 to RAND_MAX.................... *.................... * Parameters:.................... * (none).................... *.................... * Returns:.................... * The pseudo-random integer.................... */.................... unsigned int16 rand(void);........................................ /* The srand function uses the argument as a seed for a new sequence of.................... * pseudo-random numbers to be returned by subsequent calls to rand..................... *.................... * Parameters:.................... * [in] seed: The seed value to start from. You might need to pass.................... *.................... * Returns:.................... * (none).................... *.................... * Remarks.................... * The srand function sets the starting point for generating.................... * a series of pseudorandom integers. To reinitialize the.................... * generator, use 1 as the seed argument. Any other value for.................... * seed sets the generator to a random starting point. rand.................... * retrieves the pseudorandom numbers that are generated..................... * Calling rand before any call to srand generates the same.................... * sequence as calling srand with seed passed as 1..................... * Usually, you need to pass a time here from outer source.................... * so that the numbers will be different every time you run..................... */.................... void srand(unsigned int32 seed);........................................ //---------------------------------------------------------------------------.................... // Memory management functions.................... //---------------------------------------------------------------------------........................................ // Comming soon........................................ //---------------------------------------------------------------------------.................... // Communication with the environment.................... //---------------------------------------------------------------------------........................................ /* The function returns 0 always.................... */.................... signed int8 system(char *string);........................................ //---------------------------------------------------------------------------.................... // Searching and sorting utilities.................... //---------------------------------------------------------------------------........................................ /* Performs a binary search of a sorted array...................... *.................... * Parameters:.................... * [in] key: Object to search for.................... * [in] base: Pointer to base of search data.................... * [in] num: Number of elements.................... * [in] width: Width of elements.................... * [in] compare: Function that compares two elements.................... *.................... * Returns:.................... * bsearch returns a pointer to an occurrence of key in the array pointed.................... * to by base. If key is not found, the function returns NULL. If the.................... * array is not in order or contains duplicate records with identical keys,.................... * the result is unpredictable..................... */.................... //void *bsearch(const void *key, const void *base, size_t num, size_t width,.................... // int (*compare)(const void *, const void *));........................................ /* Performs the shell-metzner sort (not the quick sort algorithm). The contents.................... * of the array are sorted into ascending order according to a comparison.................... * function pointed to by compar..................... *.................... * Parameters:.................... * [in] base: Pointer to base of search data.................... * [in] num: Number of elements.................... * [in] width: Width of elements.................... * [in] compare: Function that compares two elements.................... *.................... * Returns:.................... * (none).................... */.................... //void *qsort(const void *base, size_t num, size_t width,.................... // int (*compare)(const void *, const void *));........................................ //---------------------------------------------------------------------------.................... // Integer arithmetic functions.................... //---------------------------------------------------------------------------........................................ #define labs abs........................................ div_t div(signed int numer, signed int denom);.................... ldiv_t ldiv(signed long numer, signed long denom);........................................ //---------------------------------------------------------------------------.................... // Multibyte character functions.................... //---------------------------------------------------------------------------........................................ // Not supported........................................ //---------------------------------------------------------------------------.................... // Multibyte string functions.................... //---------------------------------------------------------------------------........................................ // Not supported............................................................ //---------------------------------------------------------------------------.................... // Internal implementation.................... //---------------------------------------------------------------------------........................................ #include <stddef.h>.................... ///////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2003 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ///////////////////////////////////////////////////////////////////////////........................................ #ifndef _STDDEF........................................ #define _STDDEF........................................ #if sizeof(unsigned int8 *)==1.................... #define ptrdiff_t unsigned int8.................... #else.................... #define ptrdiff_t unsigned int16.................... #endif........................................ #define size_t unsigned int8.................... #define wchar_t char.................... #define NULL 0........................................ #define offsetof(s,f) (offsetofbit(s,f)/8)........................................ #endif........................................ #include <string.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. ////.................... ////////////////////////////////////////////////////////////////////////////........................................ #ifndef _STRING.................... #define _STRING.................... #include <stddef.h>.................... #include <ctype.h>................................................................................ //////////////////////////////////////////////.................... //// Uncomment the following define to ////.................... //// allow some functions to use a ////.................... //// quicker algorithm, but use more ROM ////.................... //// ////.................... //// #define FASTER_BUT_MORE_ROM ////.................... //////////////////////////////////////////////................................................................................ /*Copying functions*/.................... /* standard template:.................... void *memmove(void *s1, void *s2, size_t n)..................... Copies max of n characters safely (not following ending '\0').................... from s2 in s1; if s2 has less than n characters, appends 0 */........................................ char *memmove(void *s1,char *s2,size_t n).................... {.................... char *sc1;.................... char *sc2;.................... sc1=s1;.................... sc2=s2;.................... if(sc2<sc1 && sc1 <sc2 +n).................... for(sc1+=n,sc2+=n;0<n;--n).................... *--sc1=*--sc2;.................... else.................... for(;0<n;--n).................... *sc1++=*sc2++;.................... return s1;.................... }........................................ /* Standard template: char *strcpy(char *s1, const char *s2).................... copies the string s2 including the null character to s1..................... This is a compiler built in to handle the different address.................... spaces */........................................ #define strcopy strcpy........................................ /* standard template:.................... char *strncpy(char *s1, const char *s2, size_t n)..................... Copies max of n characters (not following ending '\0').................... from s2 in s1; if s2 has less than n characters, appends 0 */........................................ char *strncpy(char *s1, char *s2, size_t n).................... {.................... char *s;........................................ for (s = s1; n > 0 && *s2 != '\0'; n--).................... *s++ = *s2++;.................... for (; n > 0; n--).................... *s++ = '\0';........................................ return(s1);.................... }.................... /***********************************************************/........................................ /*concatenation functions*/.................... /* standard template: char *strcat(char *s1, const char *s2).................... appends s2 to s1*/........................................ char *strcat(char *s1, char *s2).................... {.................... char *s;........................................ for (s = s1; *s != '\0'; ++s);.................... while(*s2 != '\0').................... {.................... *s = *s2;.................... ++s;.................... ++s2;.................... }........................................ *s = '\0';.................... return(s1);.................... }.................... /* standard template: char *strncat(char *s1, char *s2,size_t n).................... appends not more than n characters from s2 to s1*/........................................ char *strncat(char *s1, char *s2, size_t n).................... {.................... char *s;........................................ for (s = s1; *s != '\0'; ++s);.................... while(*s2 != '\0' && 0<n).................... {.................... *s = *s2;.................... ++s;.................... ++s2;.................... --n;.................... }........................................ *s = '\0';.................... return(s1);.................... }........................................ /***********************************************************/............................................................ /*comparison functions*/.................... /* standard template: signed int memcmp(void *s1, void *s2)..................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */........................................ signed int8 memcmp(void * s1,char *s2,size_t n).................... {.................... char *su1, *su2;.................... for(su1=s1, su2=s2; 0<n; ++su1, ++su2, --n).................... {.................... if(*su1!=*su2).................... return ((*su1<*su2)?-1:+1);.................... }.................... return 0;.................... }........................................ /* standard template: int strcmp(const char *s1, const char *s2)..................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */........................................ signed int8 strcmp(char *s1, char *s2).................... {.................... for (; *s1 == *s2; s1++, s2++).................... if (*s1 == '\0').................... return(0);.................... return((*s1 < *s2) ? -1: 1);.................... }.................... /* standard template: int strcoll(const char *s1, const char *s2)..................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */........................................ signed int8 strcoll(char *s1, char *s2).................... {.................... for (; *s1 == *s2; s1++, s2++).................... if (*s1 == '\0').................... return(0);.................... return((*s1 < *s2) ? -1: 1);.................... }........................................ /* standard template:.................... int strncmp(const char *s1, const char *s2, size_t n)..................... Compares max of n characters (not following 0) from s1 to s2;.................... returns same as strcmp */........................................ signed int8 strncmp(char *s1, char *s2, size_t n).................... {.................... for (; n > 0; s1++, s2++, n--).................... if (*s1 != *s2).................... return((*s1 <*s2) ? -1: 1);.................... else if (*s1 == '\0').................... return(0);.................... return(0);.................... }.................... /* standard template:.................... int strxfrm(const char *s1, const char *s2, size_t n)..................... transforms maximum of n characters from s2 and places them into s1*/.................... size_t strxfrm(char *s1, char *s2, size_t n).................... {.................... char *s;.................... unsigned int8 n1;.................... n1=n;.................... for (s = s1; n > 0 && *s2 != '\0'; n--).................... *s++ = *s2++;.................... for (; n > 0; n--).................... *s++ = '\0';........................................ return(n1);.................... }........................................................................................................................ /***********************************************************/.................... /*Search functions*/.................... /* standard template: void *memchr(const char *s, int c)..................... Finds first occurrence of c in n characters of s */........................................ char *memchr(void *s,unsigned int8 c,size_t n).................... {.................... char uc;.................... char *su;.................... uc=c;.................... for(su=s;0<n;++su,--n).................... if(*su==uc).................... return su;.................... return NULL;.................... }........................................ /* standard template: char *strchr(const char *s, int c)..................... Finds first occurrence of c in s */........................................ char *strchr(char *s, unsigned int8 c).................... {.................... for (; *s != c; s++).................... if (*s == '\0').................... return(0);.................... return(s);.................... }.................... /* standard template:.................... size_t strcspn(const char *s1, const char *s2)..................... Computes length of max initial segment of s1 that.................... consists entirely of characters NOT from s2*/........................................ unsigned int8 strcspn(char *s1, char *s2).................... {.................... char *sc1, *sc2;........................................ for (sc1 = s1; *sc1 != 0; sc1++).................... for (sc2 = s2; *sc2 != 0; sc2++).................... if (*sc1 == *sc2).................... return(sc1 - s1);.................... return(sc1 - s1);.................... }.................... /* standard template:.................... char *strpbrk(const char *s1, const char *s2)..................... Locates first occurence of any character from s2 in s1;.................... returns s1 if s2 is empty string */........................................ char *strpbrk(char *s1, char *s2).................... {.................... char *sc1, *sc2;........................................ for (sc1 = s1; *sc1 != 0; sc1++).................... for (sc2 = s2; *sc2 != 0; sc2++).................... if (*sc1 == *sc2).................... return(sc1);.................... return(0);.................... }............................................................ /* standard template: char *strrchr(const char *s, int c)..................... Finds last occurrence of c in s */........................................ char *strrchr(char *s, unsigned int8 c).................... {.................... char *p;........................................ for (p = 0; ; s++).................... {.................... if (*s == c).................... p = s;.................... if (*s == '\0').................... return(p);.................... }.................... }.................... /* computes length of max initial segment of s1 consisting.................... entirely of characters from s2 */........................................ unsigned int8 strspn(char *s1, char *s2).................... {.................... char *sc1, *sc2;........................................ for (sc1 = s1; *sc1 != 0; sc1++).................... for (sc2 = s2; ; sc2++).................... if (*sc2 == '\0').................... return(sc1 - s1);.................... else if (*sc1 == *sc2).................... break;.................... return(sc1 - s1);.................... }.................... /* standard template:.................... char *strstr(const char *s1, const char *s2);.................... Locates first occurence of character sequence s2 in s1;.................... returns 0 if s2 is empty string........................................ Uncomment #define FASTER_BUT_MORE_ROM at the top of the.................... file to use the faster algorithm */.................... char *strstr(char *s1, char *s2).................... {.................... char *s, *t;........................................ #ifdef FASTER_BUT_MORE_ROM.................... if (*s2 == '\0').................... return(s1);.................... #endif........................................ while (*s1).................... {.................... for(s = s1, t = s2; *t && (*s == *t); ++s, ++t);........................................ if (*t == '\0').................... return s1;.................... ++s1;.................... #ifdef FASTER_BUT_MORE_ROM.................... while(*s1 != '\0' && *s1 != *s2).................... ++s1;.................... #endif.................... }.................... return 0;.................... }........................................ /* standard template: char *strtok(char *s1, const char *s2)......................................... Finds next token in s1 delimited by a character from separator.................... string s2 (which can be different from call to call). First call.................... starts at beginning of s1 searching for first character NOT.................... contained in s2; returns 0 if none is found..................... If one is found, it is the start of first token (return value)..................... Function then searches from there for a character contained in s2..................... If none is found, current token extends to end of s1, and subsequent.................... searches for a token will return 0. If one is found, it is.................... overwritten by '\0', which terminates current token. Function saves.................... pointer to following character from which next search will start..................... Each subsequent call, with 0 as first argument, starts searching.................... from saved pointer */........................................ char *strtok(char *s1, char *s2).................... {.................... char *beg, *end;.................... static char *save;........................................ beg = (s1)? s1: save;.................... beg += strspn(beg, s2);.................... if (*beg == '\0').................... {.................... *save = ' ';.................... return(0);.................... }.................... end = strpbrk(beg, s2);.................... if (*end != '\0').................... {.................... *end = '\0';.................... end++;.................... }.................... save = end;.................... return(beg);.................... }........................................ /*****************************************************************/.................... /*Miscellaneous functions*/.................... /* standard template.................... maps error number in errnum to an error message string.................... Returns: Pointer to string.................... */.................... #ifdef _ERRNO.................... char * strerror(unsigned int8 errnum).................... {.................... char s[15];.................... switch( errnum).................... {.................... case 0:.................... strcpy(s,"no errors");.................... return s;.................... case EDOM :.................... strcpy(s,"domain error");.................... return s;.................... case ERANGE:.................... strcpy(s,"range error");.................... return s;.................... }.................... }.................... #ENDIF.................... /* standard template: size_t strlen(const char *s)..................... Computes length of s1 (preceding terminating 0) */........................................ unsigned int8 strlen(char *s).................... {.................... char *sc;........................................ for (sc = s; *sc != 0; sc++);.................... return(sc - s);.................... }........................................ /* standard template: size_t stricmp(const char *s1, const char *s2)..................... Compares s1 to s2 ignoring case (upper vs. lower) */........................................ signed int8 stricmp(char *s1, char *s2).................... {.................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32));.................... s1++, s2++).................... if (*s1 == '\0').................... return(0);.................... return((*s1 < *s2) ? -1: 1);.................... }............................................................ /* standard template: char *strlwr(char *s)..................... Replaces uppercase letters by lowercase;.................... returns pointer to new string s */........................................ char *strlwr(char *s).................... {.................... char *p;........................................ for (p = s; *p != '\0'; p++).................... if (*p >= 'A' && *p <='Z').................... *p += 'a' - 'A';.................... return(s);.................... }............................................................ /************************************************************/............................................................ #endif............................................................ div_t div(signed int numer, signed int denom).................... {.................... div_t val;.................... val.quot = numer / denom;.................... val.rem = numer - (denom * val.quot);.................... return (val);.................... }........................................ ldiv_t ldiv(signed long numer, signed long denom).................... {.................... ldiv_t val;........................................ val.quot = numer / denom;.................... val.rem = numer - (denom * val.quot);.................... return (val);.................... }........................................ #if defined(__PCD__).................... float32 atoe(char * s).................... {.................... float32 pow10 = 1.0;.................... float32 result = 0.0;.................... unsigned int8 sign = 0;.................... unsigned int8 expsign = 0;.................... char c;.................... unsigned int8 ptr = 0;.................... unsigned int8 i;.................... float32 exp = 1.0;.................... unsigned int8 expcnt = 0;........................................ c = s[ptr++];........................................ if ((c>='0' && c<='9') || c=='+' || c=='-' || c=='.' || c=='E' || c=='e') {.................... if(c == '-') {.................... sign = 1;.................... c = s[ptr++];.................... }.................... if(c == '+').................... c = s[ptr++];........................................ while((c >= '0' && c <= '9')) {.................... result = 10*result + c - '0';.................... c = s[ptr++];.................... }........................................ if (c == '.') {.................... c = s[ptr++];.................... while((c >= '0' && c <= '9')) {.................... pow10 = pow10*10;.................... result += (c - '0')/pow10;.................... c = s[ptr++];.................... }.................... }........................................ // Handling the exponent.................... if (c=='e' || c=='E') {.................... c = s[ptr++];........................................ if(c == '-') {.................... expsign = 1;.................... c = s[ptr++];.................... }.................... if(c == '+').................... c = s[ptr++];........................................ while((c >= '0' && c <= '9')) {.................... expcnt = 10*expcnt + c - '0';.................... c = s[ptr++];.................... }........................................ for(i=0;i<expcnt;i++).................... exp*=10;........................................ if(expsign==1).................... result/=exp;.................... else.................... result*=exp;.................... }.................... }........................................ if (sign == 1).................... result = -1*result;.................... return(result);.................... }.................... #endif........................................ #if !defined(__PCD__).................... float atoe(char * s).................... {.................... float pow10 = 1.0;.................... float result = 0.0;.................... unsigned int8 sign = 0;.................... unsigned int8 expsign = 0;.................... char c;.................... unsigned int8 ptr = 0;.................... unsigned int8 i;.................... float exp = 1.0;.................... unsigned int8 expcnt = 0;........................................ c = s[ptr++];........................................ if ((c>='0' && c<='9') || c=='+' || c=='-' || c=='.' || c=='E' || c=='e') {.................... if(c == '-') {.................... sign = 1;.................... c = s[ptr++];.................... }.................... if(c == '+').................... c = s[ptr++];........................................ while((c >= '0' && c <= '9')) {.................... result = 10*result + c - '0';.................... c = s[ptr++];.................... }........................................ if (c == '.') {.................... c = s[ptr++];.................... while((c >= '0' && c <= '9')) {.................... pow10 = pow10*10;.................... result += (c - '0')/pow10;.................... c = s[ptr++];.................... }.................... }........................................ // Handling the exponent.................... if (c=='e' || c=='E') {.................... c = s[ptr++];........................................ if(c == '-') {.................... expsign = 1;.................... c = s[ptr++];.................... }.................... if(c == '+').................... c = s[ptr++];........................................ while((c >= '0' && c <= '9')) {.................... expcnt = 10*expcnt + c - '0';.................... c = s[ptr++];.................... }........................................ for(i=0;i<expcnt;i++).................... exp*=10;........................................ if(expsign==1).................... result/=exp;.................... else.................... result*=exp;.................... }.................... }........................................ if (sign == 1).................... result = -1*result;.................... return(result);.................... }.................... #endif........................................ signed int atoi(char *s).................... {.................... signed int result;.................... unsigned int sign, base, index;.................... char c;........................................ index = 0;.................... sign = 0;.................... base = 10;.................... result = 0;........................................ if (!s).................... return 0;.................... // Omit all preceeding alpha characters.................... c = s[index++];........................................ // increase index if either positive or negative sign is detected.................... if (c == '-').................... {.................... sign = 1; // Set the sign to negative.................... c = s[index++];.................... }.................... else if (c == '+').................... {.................... c = s[index++];.................... }........................................ if (c >= '0' && c <= '9').................... {........................................ // Check for hexa number.................... if (c == '0' && (s[index] == 'x' || s[index] == 'X')).................... {.................... base = 16;.................... index++;.................... c = s[index++];.................... }........................................ // The number is a decimal number.................... if (base == 10).................... {.................... while (c >= '0' && c <= '9').................... {.................... result = 10*result + (c - '0');.................... c = s[index++];.................... }.................... }.................... else if (base == 16) // The number is a hexa number.................... {.................... c = toupper(c);.................... while ( (c >= '0' && c <= '9') || (c >= 'A' && c<='F')).................... {.................... if (c >= '0' && c <= '9').................... result = (result << 4) + (c - '0');.................... else.................... result = (result << 4) + (c - 'A' + 10);........................................ c = s[index++];.................... c = toupper(c);.................... }.................... }.................... }........................................ if (sign == 1 && base == 10).................... result = -result;........................................ return(result);.................... }........................................ signed long atol(char *s).................... {.................... signed long result;.................... unsigned int sign, base, index;.................... char c;........................................ index = 0;.................... sign = 0;.................... base = 10;.................... result = 0;........................................ if (!s).................... return 0;.................... c = s[index++];........................................ // increase index if either positive or negative sign is detected.................... if (c == '-').................... {.................... sign = 1; // Set the sign to negative.................... c = s[index++];.................... }.................... else if (c == '+').................... {.................... c = s[index++];.................... }........................................ if (c >= '0' && c <= '9').................... {.................... if (c == '0' && (s[index] == 'x' || s[index] == 'X')).................... {.................... base = 16;.................... index++;.................... c = s[index++];.................... }........................................ // The number is a decimal number.................... if (base == 10).................... {.................... while (c >= '0' && c <= '9').................... {.................... result = 10*result + (c - '0');.................... c = s[index++];.................... }.................... }.................... else if (base == 16) // The number is a hexa number.................... {.................... c = toupper(c);.................... while ( (c >= '0' && c <= '9') || (c >= 'A' && c <='F')).................... {.................... if (c >= '0' && c <= '9').................... result = (result << 4) + (c - '0');.................... else.................... result = (result << 4) + (c - 'A' + 10);........................................ c = s[index++];c = toupper(c);.................... }.................... }.................... }........................................ if (base == 10 && sign == 1).................... result = -result;........................................ return(result);.................... }........................................ /* A fast routine to multiply by 10.................... */.................... signed int32 mult_with10(int32 num).................... {.................... return ( (num << 1) + (num << 3) );.................... }........................................ #if sizeof(long)==2.................... signed int32 atoi32(char *s).................... {.................... signed int32 result;.................... int8 sign, base, index;.................... char c;........................................ index = 0;.................... sign = 0;.................... base = 10;.................... result = 0;........................................ if (!s).................... return 0;.................... c = s[index++];........................................ // increase index if either positive or negative sign is detected.................... if (c == '-').................... {.................... sign = 1; // Set the sign to negative.................... c = s[index++];.................... }.................... else if (c == '+').................... {.................... c = s[index++];.................... }........................................ if (c >= '0' && c <= '9').................... {.................... if (c == '0' && (s[index] == 'x' || s[index] == 'X')).................... {.................... base = 16;.................... index++;.................... c = s[index++];.................... }........................................ // The number is a decimal number.................... if (base == 10).................... {.................... while (c >= '0' && c <= '9') {.................... result = (result << 1) + (result << 3); // result *= 10;.................... result += (c - '0');.................... c = s[index++];.................... }.................... }.................... else if (base == 16) // The number is a hexa number.................... {.................... c = toupper(c);.................... while ((c >= '0' && c <= '9') || (c >= 'A' && c <='F')).................... {.................... if (c >= '0' && c <= '9').................... result = (result << 4) + (c - '0');.................... else.................... result = (result << 4) + (c - 'A' + 10);........................................ c = s[index++];c = toupper(c);.................... }.................... }.................... }........................................ if (base == 10 && sign == 1).................... result = -result;........................................ return(result);.................... }.................... #endif........................................ #if defined(__PCD__)........................................ signed int48 atoi48(char *s).................... {.................... signed int48 result;.................... int8 sign, base, index;.................... char c;........................................ index = 0;.................... sign = 0;.................... base = 10;.................... result = 0;........................................ if (!s).................... return 0;.................... c = s[index++];........................................ // increase index if either positive or negative sign is detected.................... if (c == '-').................... {.................... sign = 1; // Set the sign to negative.................... c = s[index++];.................... }.................... else if (c == '+').................... {.................... c = s[index++];.................... }........................................ if (c >= '0' && c <= '9').................... {.................... if (c == '0' && (s[index] == 'x' || s[index] == 'X')).................... {.................... base = 16;.................... index++;.................... c = s[index++];.................... }........................................ // The number is a decimal number.................... if (base == 10).................... {.................... while (c >= '0' && c <= '9') {.................... result = (result << 1) + (result << 3); // result *= 10;.................... result += (c - '0');.................... c = s[index++];.................... }.................... }.................... else if (base == 16) // The number is a hexa number.................... {.................... c = toupper(c);.................... while ((c >= '0' && c <= '9') || (c >= 'A' && c <='F')).................... {.................... if (c >= '0' && c <= '9').................... result = (result << 4) + (c - '0');.................... else.................... result = (result << 4) + (c - 'A' + 10);........................................ c = s[index++];c = toupper(c);.................... }.................... }.................... }........................................ if (base == 10 && sign == 1).................... result = -result;........................................ return(result);.................... }........................................ signed int64 atoi64(char *s).................... {.................... signed int64 result;.................... int8 sign, base, index;.................... char c;........................................ index = 0;.................... sign = 0;.................... base = 10;.................... result = 0;........................................ if (!s).................... return 0;.................... c = s[index++];........................................ // increase index if either positive or negative sign is detected.................... if (c == '-').................... {.................... sign = 1; // Set the sign to negative.................... c = s[index++];.................... }.................... else if (c == '+').................... {.................... c = s[index++];.................... }........................................ if (c >= '0' && c <= '9').................... {.................... if (c == '0' && (s[index] == 'x' || s[index] == 'X')).................... {.................... base = 16;.................... index++;.................... c = s[index++];.................... }........................................ // The number is a decimal number.................... if (base == 10).................... {.................... while (c >= '0' && c <= '9') {.................... result = (result << 1) + (result << 3); // result *= 10;.................... result += (c - '0');.................... c = s[index++];.................... }.................... }.................... else if (base == 16) // The number is a hexa number.................... {.................... c = toupper(c);.................... while ((c >= '0' && c <= '9') || (c >= 'A' && c <='F')).................... {.................... if (c >= '0' && c <= '9').................... result = (result << 4) + (c - '0');.................... else.................... result = (result << 4) + (c - 'A' + 10);........................................ c = s[index++];c = toupper(c);.................... }.................... }.................... }........................................ if (base == 10 && sign == 1).................... result = -result;........................................ return(result);.................... }.................... #endif........................................ char * itoa(signed int32 num, unsigned int base, char * s).................... {.................... unsigned int32 temp=1;.................... unsigned int8 i,sign=0,cnt=0;.................... char c;........................................ if(num<0) {.................... sign=1; // Check for negative number.................... num*=-1;.................... }........................................ while(temp>0) {.................... temp=(num/base);.................... s[cnt]=(num%base)+'0'; // Conversion........................................ if(s[cnt]>0x39).................... s[cnt]+=0x7;........................................ cnt++;.................... num=temp;.................... }........................................ if(sign==1) {.................... s[cnt]=0x2D; // Negative sign.................... cnt++;.................... }........................................ for(i = 0;i<(int8)(cnt/2);i++) {........................................ c=s[i];.................... s[i]=s[cnt-i-1]; // Reverse the number.................... s[cnt-i-1]=c;.................... }.................... s[cnt]='\0'; // End the string.................... return s;.................... }........................................ float strtof(char *s, char *endptr).................... {.................... float pow10 = 1.0;.................... float result = 0.0;.................... int1 skip = 1, sign = 0, point = 0;.................... char c;.................... unsigned int8 ptr = 0;........................................ if (!s).................... return 0;........................................ for(c=s[ptr++]; c!=0; c=s[ptr++]).................... {.................... if (skip && !isspace(c)).................... {.................... skip = 0;.................... if (c == '+').................... {.................... sign = 0;.................... continue;.................... }.................... else if (c == '-').................... {.................... sign = 1;.................... continue;.................... }.................... }.................... if (!skip && (c == '.') && !point).................... point = 1;.................... else if (!skip && isdigit(c)).................... {.................... c -= '0';.................... if (point).................... {.................... pow10 = pow10 * 10.0;.................... result += (float)c / pow10;.................... }.................... else.................... {.................... result = 10.0 * result + (float)c;.................... }.................... }.................... else if (!skip).................... break;.................... }........................................ if (sign).................... result = -1*result;........................................ if(endptr).................... {.................... if (ptr) {.................... ptr--;.................... #IF LONG_POINTERS.................... *((long *)endptr)= s+ptr;.................... #ELSE.................... *((char *)endptr)=s+ptr;.................... #ENDIF.................... }.................... else.................... {.................... #IF LONG_POINTERS.................... *((long *)endptr)= s;.................... #ELSE.................... *((char *)endptr)=s;.................... #ENDIF.................... }.................... }........................................ return(result);.................... }........................................ #if defined(__PCD__).................... float48 strtof48(char *s, char *endptr).................... {.................... float48 pow10 = 1.0;.................... float48 result = 0.0;.................... int1 skip = 1, sign = 0, point = 0;.................... char c;.................... unsigned int8 ptr = 0;........................................ if (!s).................... return 0;........................................ for(c=s[ptr++]; c!=0; c=s[ptr++]).................... {.................... if (skip && !isspace(c)).................... {.................... skip = 0;.................... if (c == '+').................... {.................... sign = 0;.................... continue;.................... }.................... else if (c == '-').................... {.................... sign = 1;.................... continue;.................... }.................... }.................... if (!skip && (c == '.') && !point).................... point = 1;.................... else if (!skip && isdigit(c)).................... {.................... c -= '0';.................... if (point).................... {.................... pow10 = pow10 * 10.0;.................... result += (float48)c / pow10;.................... }.................... else.................... {.................... result = 10.0 * result + (float48)c;.................... }.................... }.................... else if (!skip).................... break;.................... }........................................ if (sign).................... result = -1*result;........................................ if(endptr).................... {.................... if (ptr) {.................... ptr--;.................... #IF LONG_POINTERS.................... *((long *)endptr)= s+ptr;.................... #ELSE.................... *((char *)endptr)=s+ptr;.................... #ENDIF.................... }.................... else.................... {.................... #IF LONG_POINTERS.................... *((long *)endptr)= s;.................... #ELSE.................... *((char *)endptr)=s;.................... #ENDIF.................... }.................... }........................................ return(result);.................... }........................................ float64 strtod(char *s, char *endptr).................... {.................... float64 pow10 = 1.0;.................... float64 result = 0.0;.................... int1 skip = 1, sign = 0, point = 0;.................... char c;.................... unsigned int8 ptr = 0;........................................ if (!s).................... return 0;........................................ for(c=s[ptr++]; c!=0; c=s[ptr++]).................... {.................... if (skip && !isspace(c)).................... {.................... skip = 0;.................... if (c == '+').................... {.................... sign = 0;.................... continue;.................... }.................... else if (c == '-').................... {.................... sign = 1;.................... continue;.................... }.................... }.................... if (!skip && (c == '.') && !point).................... point = 1;.................... else if (!skip && isdigit(c)).................... {.................... c -= '0';.................... if (point).................... {.................... pow10 = pow10 * 10.0;.................... result += (float64)c / pow10;.................... }.................... else.................... {.................... result = 10.0 * result + (float64)c;.................... }.................... }.................... else if (!skip).................... break;.................... }........................................ if (sign).................... result = -1*result;........................................ if(endptr).................... {.................... if (ptr) {.................... ptr--;.................... #IF LONG_POINTERS.................... *((long *)endptr)= s+ptr;.................... #ELSE.................... *((char *)endptr)=s+ptr;.................... #ENDIF.................... }.................... else.................... {.................... #IF LONG_POINTERS.................... *((long *)endptr)= s;.................... #ELSE.................... *((char *)endptr)=s;.................... #ENDIF.................... }.................... }........................................ return(result);.................... }.................... #endif........................................ unsigned long strtoul(char *s, char *endptr, signed int base).................... {.................... char *sc,*s1,*sd;.................... unsigned long x=0;.................... char sign;.................... char digits[]="0123456789abcdefghijklmnopqstuvwxyz";.................... for(sc=s;isspace(*sc);++sc);.................... sign=*sc=='-'||*sc=='+'?*sc++:'+';.................... if(sign=='-' || base <0 || base ==1|| base >36) // invalid base.................... goto StrtoulGO;........................................ else if (base).................... {.................... if(base==16 && *sc =='0'&&(sc[1]=='x' || sc[1]=='X')).................... sc+=2;.................... if(base==8 && *sc =='0').................... sc+=1;.................... if(base==2 && *sc =='0'&&sc[1]=='b').................... sc+=2;........................................ }.................... else if(*sc!='0') // base is 0, find base.................... base=10;.................... else if (sc[1]=='x' || sc[1]=='X').................... base =16,sc+=2;.................... else if(sc[1]=='b').................... base=2,sc+=2;.................... else.................... base=8;.................... for (s1=sc;*sc=='0';++sc);// skip leading zeroes.................... sd=memchr(digits,tolower(*sc),base);.................... for(; sd!=0; ).................... {.................... x=x*base+(int16)(sd-digits);.................... ++sc;.................... sd=memchr(digits,tolower(*sc),base);.................... }.................... if(s1==sc).................... {.................... StrtoulGO:.................... if (endptr).................... {.................... #IF LONG_POINTERS.................... *((long *)endptr)= s;.................... #ELSE.................... *((char *)endptr)=s;.................... #ENDIF.................... }.................... return 0;.................... }.................... if (endptr).................... {.................... #IF LONG_POINTERS.................... *((long *)endptr)= sc;.................... #ELSE.................... *((char *)endptr)=sc;.................... #ENDIF.................... }.................... return x;.................... }............................................................ signed long strtol(char *s,char *endptr, signed int base).................... {.................... char *sc,*s1,*sd;.................... signed long x=0;.................... char sign;.................... char digits[]="0123456789abcdefghijklmnopqstuvwxyz";.................... for(sc=s;isspace(*sc);++sc);.................... sign=*sc=='-'||*sc=='+'?*sc++:'+';.................... if (base <0 || base ==1|| base >36) // invalid base.................... goto StrtolGO;.................... else if (base).................... {.................... if(base==16 && *sc =='0'&&(sc[1]=='x' || sc[1]=='X')).................... sc+=2;.................... if(base==8 && *sc =='0').................... sc+=1;.................... if(base==2 && *sc =='0'&&sc[1]=='b').................... sc+=2;........................................ }.................... else if(*sc!='0') // base is 0, find base.................... base=10;.................... else if (sc[1]=='x' || sc[1]=='X').................... base =16,sc+=2;.................... else if(sc[1]=='b').................... base=2,sc+=2;.................... else.................... base=8;.................... for (s1=sc;*sc=='0';++sc);// skip leading zeroes........................................ sd=memchr(digits,tolower(*sc),base);.................... for(;sd!=0;).................... {.................... x=x*base+(int16)(sd-digits);.................... ++sc;.................... sd=memchr(digits,tolower(*sc),base);.................... }.................... if(s1==sc).................... {.................... StrtolGO:.................... if (endptr).................... {.................... #IF LONG_POINTERS.................... *((long *)endptr)= s;.................... #ELSE.................... *((char *)endptr)=s;.................... #ENDIF.................... }.................... return 0;.................... }.................... if(sign=='-').................... x =-x;.................... if (endptr).................... {.................... #IF LONG_POINTERS.................... *((long *)endptr)= sc;.................... #ELSE.................... *((char *)endptr)=sc;.................... #ENDIF.................... }.................... return x;.................... }........................................ signed int8 system(char *string).................... {.................... return 0;.................... }........................................ int8 mblen(char *s,size_t n).................... {.................... return strlen(s);.................... }........................................ int8 mbtowc(wchar_t *pwc,char *s,size_t n).................... {.................... *pwc=*s;.................... return 1;.................... }........................................ int8 wctomb(char *s,wchar_t wchar).................... {.................... *s=wchar;.................... return 1;.................... }........................................ size_t mbstowcs(wchar_t *pwcs,char *s,size_t n).................... {.................... strncpy(pwcs,s,n);.................... return strlen(pwcs);.................... }........................................ size_t wcstombs(char *s,wchar_t *pwcs,size_t n).................... {.................... strncpy(s,pwcs,n);.................... return strlen(s);.................... }........................................ //---------------------------------------------------------------------------.................... // The random number implementation.................... //---------------------------------------------------------------------------........................................ unsigned int32 _Randseed;........................................ unsigned int16 rand(void).................... {.................... _Randseed = _Randseed * 1103515245 + 12345;.................... return ((unsigned int16)(_Randseed >> 16) % RAND_MAX);.................... }........................................ void srand(unsigned int32 seed).................... {.................... _Randseed = seed;.................... }........................................ //---------------------------------------------------------------------------.................... // Searching and sorting utilities implementation.................... //---------------------------------------------------------------------------........................................ #if !defined(__PCD__).................... typedef signed int8 (*_Cmpfun)(char * p1,char * p2);.................... #else.................... typedef signed int16 (*_Cmpfun)(char * p1,char * p2);.................... #endif................................................................................ void qsort(char * qdata, unsigned int qitems, unsigned int qsize, _Cmpfun cmp) {.................... unsigned int m,j,i,l;.................... int1 done;.................... unsigned int8 t[16];........................................ m = qitems/2;.................... while( m > 0 ) {.................... for(j=0; j<(qitems-m); ++j) {.................... i = j;.................... do.................... {.................... done=1;.................... l = i+m;.................... if( (*cmp)(qdata+i*qsize, qdata+l*qsize) > 0 ) {.................... memcpy(t, qdata+i*qsize, qsize);.................... memcpy(qdata+i*qsize, qdata+l*qsize, qsize);.................... memcpy(qdata+l*qsize, t, qsize);.................... if(m <= i).................... i -= m;.................... done = 0;.................... }.................... } while(!done);.................... }.................... m = m/2;.................... }.................... }............................................................ char *bsearch(char *key, char *base, size_t num, size_t width,_Cmpfun cmp).................... {.................... char *p, *q;.................... size_t n;.................... size_t pivot;.................... signed int val;........................................ p = base;.................... n = num;........................................ while (n > 0).................... {.................... pivot = n >> 1;.................... q = p + width * pivot;........................................ val = (*cmp)(key, q);........................................ if (val < 0).................... n = pivot;.................... else if (val == 0).................... return ((char *)q);.................... else {.................... p = q + width;.................... n -= pivot + 1;.................... }.................... }........................................ return NULL; // There's no match.................... }............................................................ #endif........................................ #include <input.c>.................... ///////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2003 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ///////////////////////////////////////////////////////////////////////////............................................................ #include <ctype.h>.................... ////////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2003 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ////////////////////////////////////////////////////////////////////////////........................................ #ifndef _CTYPE.................... #define _CTYPE........................................ #define islower(x) isamong(x,"abcdefghijklmnopqrstuvwxyz").................... #define isupper(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZ").................... #define isalnum(x) isamong(x,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").................... #define isalpha(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").................... #define isdigit(x) isamong(x,"0123456789").................... #define isspace(x) ((x)==' ').................... #define isxdigit(x) isamong(x,"0123456789ABCDEFabcdef").................... #define iscntrl(x) ((x)<' ').................... #define isprint(x) ((x)>=' ').................... #define isgraph(x) ((x)>' ').................... #define ispunct(x) (((x)>' ')&&!isalnum(x))........................................ #endif................................................................................ BYTE gethex1() {.................... char digit;........................................ digit = getc();........................................ putc(digit);........................................ if(digit<='9').................... return(digit-'0');.................... else.................... return((toupper(digit)-'A')+10);.................... }........................................ BYTE gethex() {.................... unsigned int8 lo,hi;........................................ hi = gethex1();.................... lo = gethex1();.................... if(lo==0xdd).................... return(hi);.................... else.................... return( hi*16+lo );.................... }........................................ void get_string(char* s, unsigned int8 max) {.................... unsigned int8 len;.................... char c;........................................ --max;.................... len=0;.................... do {.................... c=getc();.................... if(c==8) { // Backspace.................... if(len>0) {.................... len--;.................... putc(c);.................... putc(' ');.................... putc(c);.................... }.................... } else if ((c>=' ')&&(c<='~')).................... if(len<=max) {.................... s[len++]=c;.................... putc(c);.................... }.................... } while(c!=13);.................... s[len]=0;.................... }........................................ // stdlib.h is required for the ato_ conversions.................... // in the following functions.................... #ifdef _STDLIB.................... #if !defined(__PCD__).................... signed int8 get_int() {.................... char s[5];.................... signed int8 i;........................................ get_string(s, 5);........................................ i=atoi(s);.................... return(i);.................... }.................... #endif........................................ #if defined(__PCD__).................... signed int16 get_int() {.................... char s[5];.................... signed int16 i;........................................ get_string(s, 7);........................................ i=atoi(s);.................... return(i);.................... }.................... #endif........................................ #if !defined(__PCD__).................... signed int16 get_long() {.................... char s[7];.................... signed int16 l;........................................ get_string(s, 7);.................... l=atol(s);.................... return(l);.................... }.................... #endif........................................ #if defined(__PCD__).................... signed int32 get_long() {.................... char s[7];.................... signed int32 l;........................................ get_string(s, 10);.................... l=atoi32(s);.................... return(l);.................... }.................... #endif........................................ float get_float() {.................... char s[20];.................... float f;........................................ get_string(s, 20);.................... f = atof(s);.................... return(f);.................... }........................................ #endif........................................ #include <string.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. ////.................... ////////////////////////////////////////////////////////////////////////////........................................ #ifndef _STRING.................... #define _STRING.................... #include <stddef.h>.................... #include <ctype.h>................................................................................ //////////////////////////////////////////////.................... //// Uncomment the following define to ////.................... //// allow some functions to use a ////.................... //// quicker algorithm, but use more ROM ////.................... //// ////.................... //// #define FASTER_BUT_MORE_ROM ////.................... //////////////////////////////////////////////................................................................................ /*Copying functions*/.................... /* standard template:.................... void *memmove(void *s1, void *s2, size_t n)..................... Copies max of n characters safely (not following ending '\0').................... from s2 in s1; if s2 has less than n characters, appends 0 */........................................ char *memmove(void *s1,char *s2,size_t n).................... {.................... char *sc1;.................... char *sc2;.................... sc1=s1;.................... sc2=s2;.................... if(sc2<sc1 && sc1 <sc2 +n).................... for(sc1+=n,sc2+=n;0<n;--n).................... *--sc1=*--sc2;.................... else.................... for(;0<n;--n).................... *sc1++=*sc2++;.................... return s1;.................... }........................................ /* Standard template: char *strcpy(char *s1, const char *s2).................... copies the string s2 including the null character to s1..................... This is a compiler built in to handle the different address.................... spaces */........................................ #define strcopy strcpy........................................ /* standard template:.................... char *strncpy(char *s1, const char *s2, size_t n)..................... Copies max of n characters (not following ending '\0').................... from s2 in s1; if s2 has less than n characters, appends 0 */........................................ char *strncpy(char *s1, char *s2, size_t n).................... {.................... char *s;........................................ for (s = s1; n > 0 && *s2 != '\0'; n--).................... *s++ = *s2++;.................... for (; n > 0; n--).................... *s++ = '\0';........................................ return(s1);.................... }.................... /***********************************************************/........................................ /*concatenation functions*/.................... /* standard template: char *strcat(char *s1, const char *s2).................... appends s2 to s1*/........................................ char *strcat(char *s1, char *s2).................... {.................... char *s;........................................ for (s = s1; *s != '\0'; ++s);.................... while(*s2 != '\0').................... {.................... *s = *s2;.................... ++s;.................... ++s2;.................... }........................................ *s = '\0';.................... return(s1);.................... }.................... /* standard template: char *strncat(char *s1, char *s2,size_t n).................... appends not more than n characters from s2 to s1*/........................................ char *strncat(char *s1, char *s2, size_t n).................... {.................... char *s;........................................ for (s = s1; *s != '\0'; ++s);.................... while(*s2 != '\0' && 0<n).................... {.................... *s = *s2;.................... ++s;.................... ++s2;.................... --n;.................... }........................................ *s = '\0';.................... return(s1);.................... }........................................ /***********************************************************/............................................................ /*comparison functions*/.................... /* standard template: signed int memcmp(void *s1, void *s2)..................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */........................................ signed int8 memcmp(void * s1,char *s2,size_t n).................... {.................... char *su1, *su2;.................... for(su1=s1, su2=s2; 0<n; ++su1, ++su2, --n).................... {.................... if(*su1!=*su2).................... return ((*su1<*su2)?-1:+1);.................... }.................... return 0;.................... }........................................ /* standard template: int strcmp(const char *s1, const char *s2)..................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */........................................ signed int8 strcmp(char *s1, char *s2).................... {.................... for (; *s1 == *s2; s1++, s2++).................... if (*s1 == '\0').................... return(0);.................... return((*s1 < *s2) ? -1: 1);.................... }.................... /* standard template: int strcoll(const char *s1, const char *s2)..................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */........................................ signed int8 strcoll(char *s1, char *s2).................... {.................... for (; *s1 == *s2; s1++, s2++).................... if (*s1 == '\0').................... return(0);.................... return((*s1 < *s2) ? -1: 1);.................... }........................................ /* standard template:.................... int strncmp(const char *s1, const char *s2, size_t n)..................... Compares max of n characters (not following 0) from s1 to s2;.................... returns same as strcmp */........................................ signed int8 strncmp(char *s1, char *s2, size_t n).................... {.................... for (; n > 0; s1++, s2++, n--).................... if (*s1 != *s2).................... return((*s1 <*s2) ? -1: 1);.................... else if (*s1 == '\0').................... return(0);.................... return(0);.................... }.................... /* standard template:.................... int strxfrm(const char *s1, const char *s2, size_t n)..................... transforms maximum of n characters from s2 and places them into s1*/.................... size_t strxfrm(char *s1, char *s2, size_t n).................... {.................... char *s;.................... unsigned int8 n1;.................... n1=n;.................... for (s = s1; n > 0 && *s2 != '\0'; n--).................... *s++ = *s2++;.................... for (; n > 0; n--).................... *s++ = '\0';........................................ return(n1);.................... }........................................................................................................................ /***********************************************************/.................... /*Search functions*/.................... /* standard template: void *memchr(const char *s, int c)..................... Finds first occurrence of c in n characters of s */........................................ char *memchr(void *s,unsigned int8 c,size_t n).................... {.................... char uc;.................... char *su;.................... uc=c;.................... for(su=s;0<n;++su,--n).................... if(*su==uc).................... return su;.................... return NULL;.................... }........................................ /* standard template: char *strchr(const char *s, int c)..................... Finds first occurrence of c in s */........................................ char *strchr(char *s, unsigned int8 c).................... {.................... for (; *s != c; s++).................... if (*s == '\0').................... return(0);.................... return(s);.................... }.................... /* standard template:.................... size_t strcspn(const char *s1, const char *s2)..................... Computes length of max initial segment of s1 that.................... consists entirely of characters NOT from s2*/........................................ unsigned int8 strcspn(char *s1, char *s2).................... {.................... char *sc1, *sc2;........................................ for (sc1 = s1; *sc1 != 0; sc1++).................... for (sc2 = s2; *sc2 != 0; sc2++).................... if (*sc1 == *sc2).................... return(sc1 - s1);.................... return(sc1 - s1);.................... }.................... /* standard template:.................... char *strpbrk(const char *s1, const char *s2)..................... Locates first occurence of any character from s2 in s1;.................... returns s1 if s2 is empty string */........................................ char *strpbrk(char *s1, char *s2).................... {.................... char *sc1, *sc2;........................................ for (sc1 = s1; *sc1 != 0; sc1++).................... for (sc2 = s2; *sc2 != 0; sc2++).................... if (*sc1 == *sc2).................... return(sc1);.................... return(0);.................... }............................................................ /* standard template: char *strrchr(const char *s, int c)..................... Finds last occurrence of c in s */........................................ char *strrchr(char *s, unsigned int8 c).................... {.................... char *p;........................................ for (p = 0; ; s++).................... {.................... if (*s == c).................... p = s;.................... if (*s == '\0').................... return(p);.................... }.................... }.................... /* computes length of max initial segment of s1 consisting.................... entirely of characters from s2 */........................................ unsigned int8 strspn(char *s1, char *s2).................... {.................... char *sc1, *sc2;........................................ for (sc1 = s1; *sc1 != 0; sc1++).................... for (sc2 = s2; ; sc2++).................... if (*sc2 == '\0').................... return(sc1 - s1);.................... else if (*sc1 == *sc2).................... break;.................... return(sc1 - s1);.................... }.................... /* standard template:.................... char *strstr(const char *s1, const char *s2);.................... Locates first occurence of character sequence s2 in s1;.................... returns 0 if s2 is empty string........................................ Uncomment #define FASTER_BUT_MORE_ROM at the top of the.................... file to use the faster algorithm */.................... char *strstr(char *s1, char *s2).................... {.................... char *s, *t;........................................ #ifdef FASTER_BUT_MORE_ROM.................... if (*s2 == '\0').................... return(s1);.................... #endif........................................ while (*s1).................... {.................... for(s = s1, t = s2; *t && (*s == *t); ++s, ++t);........................................ if (*t == '\0').................... return s1;.................... ++s1;.................... #ifdef FASTER_BUT_MORE_ROM.................... while(*s1 != '\0' && *s1 != *s2).................... ++s1;.................... #endif.................... }.................... return 0;.................... }........................................ /* standard template: char *strtok(char *s1, const char *s2)......................................... Finds next token in s1 delimited by a character from separator.................... string s2 (which can be different from call to call). First call.................... starts at beginning of s1 searching for first character NOT.................... contained in s2; returns 0 if none is found..................... If one is found, it is the start of first token (return value)..................... Function then searches from there for a character contained in s2..................... If none is found, current token extends to end of s1, and subsequent.................... searches for a token will return 0. If one is found, it is.................... overwritten by '\0', which terminates current token. Function saves.................... pointer to following character from which next search will start..................... Each subsequent call, with 0 as first argument, starts searching.................... from saved pointer */........................................ char *strtok(char *s1, char *s2).................... {.................... char *beg, *end;.................... static char *save;........................................ beg = (s1)? s1: save;.................... beg += strspn(beg, s2);.................... if (*beg == '\0').................... {.................... *save = ' ';.................... return(0);.................... }.................... end = strpbrk(beg, s2);.................... if (*end != '\0').................... {.................... *end = '\0';.................... end++;.................... }.................... save = end;.................... return(beg);.................... }........................................ /*****************************************************************/.................... /*Miscellaneous functions*/.................... /* standard template.................... maps error number in errnum to an error message string.................... Returns: Pointer to string.................... */.................... #ifdef _ERRNO.................... char * strerror(unsigned int8 errnum).................... {.................... char s[15];.................... switch( errnum).................... {.................... case 0:.................... strcpy(s,"no errors");.................... return s;.................... case EDOM :.................... strcpy(s,"domain error");.................... return s;.................... case ERANGE:.................... strcpy(s,"range error");.................... return s;.................... }.................... }.................... #ENDIF.................... /* standard template: size_t strlen(const char *s)..................... Computes length of s1 (preceding terminating 0) */........................................ unsigned int8 strlen(char *s).................... {.................... char *sc;........................................ for (sc = s; *sc != 0; sc++);.................... return(sc - s);.................... }........................................ /* standard template: size_t stricmp(const char *s1, const char *s2)..................... Compares s1 to s2 ignoring case (upper vs. lower) */........................................ signed int8 stricmp(char *s1, char *s2).................... {.................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32));.................... s1++, s2++).................... if (*s1 == '\0').................... return(0);.................... return((*s1 < *s2) ? -1: 1);.................... }............................................................ /* standard template: char *strlwr(char *s)..................... Replaces uppercase letters by lowercase;.................... returns pointer to new string s */........................................ char *strlwr(char *s).................... {.................... char *p;........................................ for (p = s; *p != '\0'; p++).................... if (*p >= 'A' && *p <='Z').................... *p += 'a' - 'A';.................... return(s);.................... }............................................................ /************************************************************/............................................................ #endif............................................................ //Akcelerometr.................... #define AK_W 0x38 //adresa akcelerometru zápis.................... #define AK_R 0x39 //adresa akcelerometru ètení.................... #define AK_XH 0x01 //osa X LSB.................... #define AK_XL 0x02 //osa X MSB.................... #define AK_YH 0x03 //osa Y LSB.................... #define AK_YL 0x04 //osa Y MSB.................... #define AK_ZH 0x05 //osa Z LSB.................... #define AK_ZL 0x06 //osa Z MSB........................................ //Magnetometr.................... #define MAG_W 0x3C //adresa akcelerometru zápis.................... #define MAG_R 0x3D //adresa akcelerometru ètení.................... #define MAG_XH 0x03 //osa X LSB.................... #define MAG_XL 0x04 //osa X MSB.................... #define MAG_ZH 0x05 //osa Y LSB.................... #define MAG_ZL 0x06 //osa Y MSB.................... #define MAG_YH 0x07 //osa Z LSB.................... #define MAG_YL 0x08 //osa Z MSB........................................................................................................................ //pøipojení motorù.................... //AIN1 - pro vysku slunce.................... #define AIN1 PIN_D0.................... #define AIN2 PIN_D1.................... //motor A -cerveny vodic na AOUT1.................... //motor A -modry vodic na Aout2........................................ //AIN2 - pro azimut.................... #define BIN1 PIN_D2.................... #define BIN2 PIN_D3.................... //motor B - èerveny vodic na BOUT2.................... //motor B - modrý vodic na BOUT1........................................ signed int16 X, Y, Z,AX, AY, AZ; //promenne pro magnetometr a akcelerometr........................................ unsigned int16 azimutZAD, elevaceZAD;........................................ void setAK (void) //nastaveni akcelerometru.................... {.................... i2c_start();*0122: BSF 20.40123: MOVF 20,W0124: BSF 03.50125: MOVWF 070126: NOP0127: BCF 03.50128: BSF 20.30129: MOVF 20,W012A: BSF 03.5012B: MOVWF 07012C: NOP012D: BCF 03.5012E: BCF 07.4012F: BCF 20.40130: MOVF 20,W0131: BSF 03.50132: MOVWF 070133: NOP0134: BCF 03.50135: BCF 07.30136: BCF 20.30137: MOVF 20,W0138: BSF 03.50139: MOVWF 07.................... I2C_Write(AK_W);013A: MOVLW 38013B: BCF 03.5013C: MOVWF 5D013D: CALL 0D8.................... I2C_write(0x2A);013E: MOVLW 2A013F: MOVWF 5D0140: CALL 0D8.................... I2C_write(0x01); //nastaví aktivní stav0141: MOVLW 010142: MOVWF 5D0143: CALL 0D8........................................ i2c_stop();0144: BCF 20.40145: MOVF 20,W0146: BSF 03.50147: MOVWF 070148: NOP0149: BCF 03.5014A: BSF 20.3014B: MOVF 20,W014C: BSF 03.5014D: MOVWF 07014E: BCF 03.5014F: BTFSS 07.30150: GOTO 14F0151: NOP0152: GOTO 1530153: NOP0154: BSF 20.40155: MOVF 20,W0156: BSF 03.50157: MOVWF 070158: NOP.................... }0159: BCF 03.5015A: BCF 0A.3015B: BSF 0A.4015C: GOTO 122 (RETURN)........................................ void setmag (void).................... {.................... i2c_start();*0171: BSF 20.40172: MOVF 20,W0173: BSF 03.50174: MOVWF 070175: NOP0176: BCF 03.50177: BSF 20.30178: MOVF 20,W0179: BSF 03.5017A: MOVWF 07017B: NOP017C: BCF 03.5017D: BCF 07.4017E: BCF 20.4017F: MOVF 20,W0180: BSF 03.50181: MOVWF 070182: NOP0183: BCF 03.50184: BCF 07.30185: BCF 20.30186: MOVF 20,W0187: BSF 03.50188: MOVWF 07.................... I2C_Write(MAG_W); // W0189: MOVLW 3C018A: BCF 03.5018B: MOVWF 5D018C: CALL 0D8.................... I2C_Write(0x00);018D: CLRF 5D018E: CALL 0D8.................... I2C_Write(0x78);018F: MOVLW 780190: MOVWF 5D0191: CALL 0D8.................... i2c_stop();0192: BCF 20.40193: MOVF 20,W0194: BSF 03.50195: MOVWF 070196: NOP0197: BCF 03.50198: BSF 20.30199: MOVF 20,W019A: BSF 03.5019B: MOVWF 07019C: BCF 03.5019D: BTFSS 07.3019E: GOTO 19D019F: NOP01A0: GOTO 1A101A1: NOP01A2: BSF 20.401A3: MOVF 20,W01A4: BSF 03.501A5: MOVWF 0701A6: NOP.................... Delay_ms(6);01A7: MOVLW 0601A8: BCF 03.501A9: MOVWF 4F01AA: CALL 15D........................................ i2c_start();01AB: BSF 20.401AC: MOVF 20,W01AD: BSF 03.501AE: MOVWF 0701AF: NOP01B0: BCF 03.501B1: BSF 20.301B2: MOVF 20,W01B3: BSF 03.501B4: MOVWF 0701B5: NOP01B6: BCF 03.501B7: BCF 07.401B8: BCF 20.401B9: MOVF 20,W01BA: BSF 03.501BB: MOVWF 0701BC: NOP01BD: BCF 03.501BE: BCF 07.301BF: BCF 20.301C0: MOVF 20,W01C1: BSF 03.501C2: MOVWF 07.................... I2C_Write(MAG_W); // W01C3: MOVLW 3C01C4: BCF 03.501C5: MOVWF 5D01C6: CALL 0D8.................... I2C_Write(0x01);01C7: MOVLW 0101C8: MOVWF 5D01C9: CALL 0D8.................... I2C_Write(0x00);01CA: CLRF 5D01CB: CALL 0D8.................... i2c_stop();01CC: BCF 20.401CD: MOVF 20,W01CE: BSF 03.501CF: MOVWF 0701D0: NOP01D1: BCF 03.501D2: BSF 20.301D3: MOVF 20,W01D4: BSF 03.501D5: MOVWF 0701D6: BCF 03.501D7: BTFSS 07.301D8: GOTO 1D701D9: NOP01DA: GOTO 1DB01DB: NOP01DC: BSF 20.401DD: MOVF 20,W01DE: BSF 03.501DF: MOVWF 0701E0: NOP........................................ Delay_ms(6);01E1: MOVLW 0601E2: BCF 03.501E3: MOVWF 4F01E4: CALL 15D........................................ i2c_start();01E5: BSF 20.401E6: MOVF 20,W01E7: BSF 03.501E8: MOVWF 0701E9: NOP01EA: BCF 03.501EB: BSF 20.301EC: MOVF 20,W01ED: BSF 03.501EE: MOVWF 0701EF: NOP01F0: BCF 03.501F1: BCF 07.401F2: BCF 20.401F3: MOVF 20,W01F4: BSF 03.501F5: MOVWF 0701F6: NOP01F7: BCF 03.501F8: BCF 07.301F9: BCF 20.301FA: MOVF 20,W01FB: BSF 03.501FC: MOVWF 07.................... I2C_Write(MAG_W); // W01FD: MOVLW 3C01FE: BCF 03.501FF: MOVWF 5D0200: CALL 0D8.................... I2C_Write(0x02);0201: MOVLW 020202: MOVWF 5D0203: CALL 0D8.................... I2C_Write(0x00);0204: CLRF 5D0205: CALL 0D8.................... i2c_stop();0206: BCF 20.40207: MOVF 20,W0208: BSF 03.50209: MOVWF 07020A: NOP020B: BCF 03.5020C: BSF 20.3020D: MOVF 20,W020E: BSF 03.5020F: MOVWF 070210: BCF 03.50211: BTFSS 07.30212: GOTO 2110213: NOP0214: GOTO 2150215: NOP0216: BSF 20.40217: MOVF 20,W0218: BSF 03.50219: MOVWF 07021A: NOP.................... Delay_ms(6);021B: MOVLW 06021C: BCF 03.5021D: MOVWF 4F021E: CALL 15D.................... }021F: BCF 0A.30220: BSF 0A.40221: GOTO 125 (RETURN)........................................ int16 akR (int8 H, int8 L) //vycitani hodnot z akcelerometru.................... {*03D4: CLRF 5903D5: CLRF 5A.................... unsigned int8 XL=0,XH=0;.................... signed int16 x;........................................ i2c_start();03D6: BSF 20.403D7: MOVF 20,W03D8: BSF 03.503D9: MOVWF 0703DA: NOP03DB: BCF 03.503DC: BSF 20.303DD: MOVF 20,W03DE: BSF 03.503DF: MOVWF 0703E0: NOP03E1: BCF 03.503E2: BCF 07.403E3: BCF 20.403E4: MOVF 20,W03E5: BSF 03.503E6: MOVWF 0703E7: NOP03E8: BCF 03.503E9: BCF 07.303EA: BCF 20.303EB: MOVF 20,W03EC: BSF 03.503ED: MOVWF 07.................... I2C_Write(AK_W);03EE: MOVLW 3803EF: BCF 03.503F0: MOVWF 5D03F1: CALL 0D8.................... I2C_write(H);03F2: MOVF 57,W03F3: MOVWF 5D03F4: CALL 0D8.................... i2c_start();03F5: BSF 20.403F6: MOVF 20,W03F7: BSF 03.503F8: MOVWF 0703F9: NOP03FA: BCF 03.503FB: BSF 20.303FC: MOVF 20,W03FD: BSF 03.503FE: MOVWF 0703FF: NOP0400: BCF 03.50401: BTFSS 07.30402: GOTO 4010403: BCF 07.40404: BCF 20.40405: MOVF 20,W0406: BSF 03.50407: MOVWF 070408: NOP0409: BCF 03.5040A: BCF 07.3040B: BCF 20.3040C: MOVF 20,W040D: BSF 03.5040E: MOVWF 07.................... I2C_Write(AK_R);040F: MOVLW 390410: BCF 03.50411: MOVWF 5D0412: CALL 0D8.................... XH=i2c_read(0);0413: CLRF 770414: CALL 38F0415: MOVF 78,W0416: MOVWF 5A.................... i2c_stop();0417: BCF 20.40418: MOVF 20,W0419: BSF 03.5041A: MOVWF 07041B: NOP041C: BCF 03.5041D: BSF 20.3041E: MOVF 20,W041F: BSF 03.50420: MOVWF 070421: BCF 03.50422: BTFSS 07.30423: GOTO 4220424: NOP0425: GOTO 4260426: NOP0427: BSF 20.40428: MOVF 20,W0429: BSF 03.5042A: MOVWF 07042B: NOP........................................ i2c_start();042C: BCF 03.5042D: BSF 20.4042E: MOVF 20,W042F: BSF 03.50430: MOVWF 070431: NOP0432: BCF 03.50433: BSF 20.30434: MOVF 20,W0435: BSF 03.50436: MOVWF 070437: NOP0438: BCF 03.50439: BCF 07.4043A: BCF 20.4043B: MOVF 20,W043C: BSF 03.5043D: MOVWF 07043E: NOP043F: BCF 03.50440: BCF 07.30441: BCF 20.30442: MOVF 20,W0443: BSF 03.50444: MOVWF 07.................... I2C_Write(AK_W);0445: MOVLW 380446: BCF 03.50447: MOVWF 5D0448: CALL 0D8.................... I2C_write(L);0449: MOVF 58,W044A: MOVWF 5D044B: CALL 0D8.................... i2c_start();044C: BSF 20.4044D: MOVF 20,W044E: BSF 03.5044F: MOVWF 070450: NOP0451: BCF 03.50452: BSF 20.30453: MOVF 20,W0454: BSF 03.50455: MOVWF 070456: NOP0457: BCF 03.50458: BTFSS 07.30459: GOTO 458045A: BCF 07.4045B: BCF 20.4045C: MOVF 20,W045D: BSF 03.5045E: MOVWF 07045F: NOP0460: BCF 03.50461: BCF 07.30462: BCF 20.30463: MOVF 20,W0464: BSF 03.50465: MOVWF 07.................... I2C_Write(AK_R);0466: MOVLW 390467: BCF 03.50468: MOVWF 5D0469: CALL 0D8.................... XL=i2c_read(0);046A: CLRF 77046B: CALL 38F046C: MOVF 78,W046D: MOVWF 59.................... i2c_stop();046E: BCF 20.4046F: MOVF 20,W0470: BSF 03.50471: MOVWF 070472: NOP0473: BCF 03.50474: BSF 20.30475: MOVF 20,W0476: BSF 03.50477: MOVWF 070478: BCF 03.50479: BTFSS 07.3047A: GOTO 479047B: NOP047C: GOTO 47D047D: NOP047E: BSF 20.4047F: MOVF 20,W0480: BSF 03.50481: MOVWF 070482: NOP........................................ x = (((unsigned int16) XH << 8) + XL ); //prevod na 16bit hodnotu0483: BCF 03.50484: CLRF 5E0485: MOVF 5A,W0486: MOVWF 5D0487: MOVWF 5E0488: CLRF 5D0489: MOVF 59,W048A: ADDWF 5D,W048B: MOVWF 78048C: MOVF 5E,W048D: MOVWF 7A048E: BTFSC 03.0048F: INCF 7A,F0490: MOVF 78,W0491: MOVWF 5B0492: MOVF 7A,W0493: MOVWF 5C.................... x=x/4;0494: MOVF 5C,W0495: MOVWF 5E0496: MOVF 5B,W0497: MOVWF 5D0498: CLRF 600499: MOVLW 04049A: MOVWF 5F*04D8: MOVF 79,W04D9: MOVWF 5C04DA: MOVF 78,W04DB: MOVWF 5B........................................ return x;04DC: MOVF 5B,W04DD: MOVWF 7804DE: MOVF 5C,W04DF: MOVWF 79.................... }04E0: RETURN........................................ int16 magR (int8 H, int8 L) //vycitani hodnot z magnetometru.................... {*0DBB: CLRF 590DBC: CLRF 5A.................... unsigned int8 XL=0,XH=0;.................... signed int16 x;........................................ i2c_start();0DBD: BSF 20.40DBE: MOVF 20,W0DBF: BSF 03.50DC0: MOVWF 070DC1: NOP0DC2: BCF 03.50DC3: BSF 20.30DC4: MOVF 20,W0DC5: BSF 03.50DC6: MOVWF 070DC7: NOP0DC8: BCF 03.50DC9: BCF 07.40DCA: BCF 20.40DCB: MOVF 20,W0DCC: BSF 03.50DCD: MOVWF 070DCE: NOP0DCF: BCF 03.50DD0: BCF 07.30DD1: BCF 20.30DD2: MOVF 20,W0DD3: BSF 03.50DD4: MOVWF 07.................... I2C_Write(MAG_W);0DD5: MOVLW 3C0DD6: BCF 03.50DD7: MOVWF 5D0DD8: BCF 0A.30DD9: CALL 0D80DDA: BSF 0A.3.................... I2C_write(H);0DDB: MOVF 57,W0DDC: MOVWF 5D0DDD: BCF 0A.30DDE: CALL 0D80DDF: BSF 0A.3.................... i2c_start();0DE0: BSF 20.40DE1: MOVF 20,W0DE2: BSF 03.50DE3: MOVWF 070DE4: NOP0DE5: BCF 03.50DE6: BSF 20.30DE7: MOVF 20,W0DE8: BSF 03.50DE9: MOVWF 070DEA: NOP0DEB: BCF 03.50DEC: BTFSS 07.30DED: GOTO 5EC0DEE: BCF 07.40DEF: BCF 20.40DF0: MOVF 20,W0DF1: BSF 03.50DF2: MOVWF 070DF3: NOP0DF4: BCF 03.50DF5: BCF 07.30DF6: BCF 20.30DF7: MOVF 20,W0DF8: BSF 03.50DF9: MOVWF 07.................... I2C_Write(MAG_R);0DFA: MOVLW 3D0DFB: BCF 03.50DFC: MOVWF 5D0DFD: BCF 0A.30DFE: CALL 0D80DFF: BSF 0A.3.................... XH=i2c_read(0);0E00: CLRF 770E01: BCF 0A.30E02: CALL 38F0E03: BSF 0A.30E04: MOVF 78,W0E05: MOVWF 5A.................... i2c_stop();0E06: BCF 20.40E07: MOVF 20,W0E08: BSF 03.50E09: MOVWF 070E0A: NOP0E0B: BCF 03.50E0C: BSF 20.30E0D: MOVF 20,W0E0E: BSF 03.50E0F: MOVWF 070E10: BCF 03.50E11: BTFSS 07.30E12: GOTO 6110E13: NOP0E14: GOTO 6150E15: NOP0E16: BSF 20.40E17: MOVF 20,W0E18: BSF 03.50E19: MOVWF 070E1A: NOP........................................ i2c_start();0E1B: BCF 03.50E1C: BSF 20.40E1D: MOVF 20,W0E1E: BSF 03.50E1F: MOVWF 070E20: NOP0E21: BCF 03.50E22: BSF 20.30E23: MOVF 20,W0E24: BSF 03.50E25: MOVWF 070E26: NOP0E27: BCF 03.50E28: BCF 07.40E29: BCF 20.40E2A: MOVF 20,W0E2B: BSF 03.50E2C: MOVWF 070E2D: NOP0E2E: BCF 03.50E2F: BCF 07.30E30: BCF 20.30E31: MOVF 20,W0E32: BSF 03.50E33: MOVWF 07.................... I2C_Write(MAG_W);0E34: MOVLW 3C0E35: BCF 03.50E36: MOVWF 5D0E37: BCF 0A.30E38: CALL 0D80E39: BSF 0A.3.................... I2C_write(L);0E3A: MOVF 58,W0E3B: MOVWF 5D0E3C: BCF 0A.30E3D: CALL 0D80E3E: BSF 0A.3.................... i2c_start();0E3F: BSF 20.40E40: MOVF 20,W0E41: BSF 03.50E42: MOVWF 070E43: NOP0E44: BCF 03.50E45: BSF 20.30E46: MOVF 20,W0E47: BSF 03.50E48: MOVWF 070E49: NOP0E4A: BCF 03.50E4B: BTFSS 07.30E4C: GOTO 64B0E4D: BCF 07.40E4E: BCF 20.40E4F: MOVF 20,W0E50: BSF 03.50E51: MOVWF 070E52: NOP0E53: BCF 03.50E54: BCF 07.30E55: BCF 20.30E56: MOVF 20,W0E57: BSF 03.50E58: MOVWF 07.................... I2C_Write(MAG_R);0E59: MOVLW 3D0E5A: BCF 03.50E5B: MOVWF 5D0E5C: BCF 0A.30E5D: CALL 0D80E5E: BSF 0A.3.................... XL=i2c_read(0);0E5F: CLRF 770E60: BCF 0A.30E61: CALL 38F0E62: BSF 0A.30E63: MOVF 78,W0E64: MOVWF 59.................... i2c_stop();0E65: BCF 20.40E66: MOVF 20,W0E67: BSF 03.50E68: MOVWF 070E69: NOP0E6A: BCF 03.50E6B: BSF 20.30E6C: MOVF 20,W0E6D: BSF 03.50E6E: MOVWF 070E6F: BCF 03.50E70: BTFSS 07.30E71: GOTO 6700E72: NOP0E73: GOTO 6740E74: NOP0E75: BSF 20.40E76: MOVF 20,W0E77: BSF 03.50E78: MOVWF 070E79: NOP........................................ x = (((unsigned int16) XH << 8) + XL );0E7A: BCF 03.50E7B: CLRF 5E0E7C: MOVF 5A,W0E7D: MOVWF 5D0E7E: MOVWF 5E0E7F: CLRF 5D0E80: MOVF 59,W0E81: ADDWF 5D,W0E82: MOVWF 5B0E83: MOVF 5E,W0E84: MOVWF 5C0E85: BTFSC 03.00E86: INCF 5C,F............................................................ return x;0E87: MOVF 5B,W0E88: MOVWF 780E89: MOVF 5C,W0E8A: MOVWF 79.................... }0E8B: RETURN........................................ float elevace (void) //vypocet aktualni elevace panelu.................... {.................... //printf("Akcelerometr5: \r\n",);........................................ X= akR (AK_XH, AK_XL);*0BDD: MOVLW 010BDE: MOVWF 570BDF: MOVLW 020BE0: MOVWF 580BE1: BCF 0A.30BE2: CALL 3D40BE3: BSF 0A.30BE4: MOVF 79,W0BE5: MOVWF 280BE6: MOVF 78,W0BE7: MOVWF 27.................... Y= akR (AK_YH, AK_YL);0BE8: MOVLW 030BE9: MOVWF 570BEA: MOVLW 040BEB: MOVWF 580BEC: BCF 0A.30BED: CALL 3D40BEE: BSF 0A.30BEF: MOVF 79,W0BF0: MOVWF 2A0BF1: MOVF 78,W0BF2: MOVWF 29.................... Z= akR (AK_ZH, AK_ZL);0BF3: MOVLW 050BF4: MOVWF 570BF5: MOVLW 060BF6: MOVWF 580BF7: BCF 0A.30BF8: CALL 3D40BF9: BSF 0A.30BFA: MOVF 79,W0BFB: MOVWF 2C0BFC: MOVF 78,W0BFD: MOVWF 2B........................................ AX=abs(X);0BFE: MOVF 28,W0BFF: MOVWF 7A0C00: MOVF 27,W0C01: BTFSS 28.70C02: GOTO 40C0C03: MOVF 27,W0C04: SUBLW 000C05: MOVWF 770C06: CLRF 7A0C07: MOVF 28,W0C08: BTFSS 03.00C09: INCFSZ 28,W0C0A: SUBWF 7A,F0C0B: MOVF 77,W0C0C: MOVWF 2D0C0D: MOVF 7A,W0C0E: MOVWF 2E.................... AY=abs(Y)+250;0C0F: MOVF 2A,W0C10: MOVWF 7A0C11: MOVF 29,W0C12: BTFSS 2A.70C13: GOTO 41D0C14: MOVF 29,W0C15: SUBLW 000C16: MOVWF 770C17: CLRF 7A0C18: MOVF 2A,W0C19: BTFSS 03.00C1A: INCFSZ 2A,W0C1B: SUBWF 7A,F0C1C: MOVF 77,W0C1D: MOVWF 570C1E: MOVLW FA0C1F: ADDWF 57,W0C20: MOVWF 2F0C21: MOVF 7A,W0C22: MOVWF 300C23: BTFSC 03.00C24: INCF 30,F.................... AZ=abs(Z)+250;0C25: MOVF 2C,W0C26: MOVWF 7A0C27: MOVF 2B,W0C28: BTFSS 2C.70C29: GOTO 4330C2A: MOVF 2B,W0C2B: SUBLW 000C2C: MOVWF 770C2D: CLRF 7A0C2E: MOVF 2C,W0C2F: BTFSS 03.00C30: INCFSZ 2C,W0C31: SUBWF 7A,F0C32: MOVF 77,W0C33: MOVWF 570C34: MOVLW FA0C35: ADDWF 57,W0C36: MOVWF 310C37: MOVF 7A,W0C38: MOVWF 320C39: BTFSC 03.00C3A: INCF 32,F........................................ float a, b;.................... a=(float)Y/Z;0C3B: MOVF 2A,W0C3C: MOVWF 5C0C3D: MOVF 29,W0C3E: MOVWF 5B0C3F: BCF 0A.30C40: CALL 4E10C41: BSF 0A.30C42: MOVF 77,W0C43: MOVWF 570C44: MOVF 78,W0C45: MOVWF 580C46: MOVF 79,W0C47: MOVWF 590C48: MOVF 7A,W0C49: MOVWF 5A0C4A: MOVF 2C,W0C4B: MOVWF 5C0C4C: MOVF 2B,W0C4D: MOVWF 5B0C4E: BCF 0A.30C4F: CALL 4E10C50: BSF 0A.30C51: MOVF 5A,W0C52: MOVWF 6F0C53: MOVF 59,W0C54: MOVWF 6E0C55: MOVF 58,W0C56: MOVWF 6D0C57: MOVF 57,W0C58: MOVWF 6C0C59: MOVF 7A,W0C5A: MOVWF 730C5B: MOVF 79,W0C5C: MOVWF 720C5D: MOVF 78,W0C5E: MOVWF 710C5F: MOVF 77,W0C60: MOVWF 700C61: BCF 0A.30C62: CALL 5060C63: BSF 0A.30C64: MOVF 7A,W0C65: MOVWF 520C66: MOVF 79,W0C67: MOVWF 510C68: MOVF 78,W0C69: MOVWF 500C6A: MOVF 77,W0C6B: MOVWF 4F.................... b=atan(a);0C6C: MOVF 52,W0C6D: MOVWF 5A0C6E: MOVF 51,W0C6F: MOVWF 590C70: MOVF 50,W0C71: MOVWF 580C72: MOVF 4F,W0C73: MOVWF 570C74: CALL 15D0C75: MOVF 7A,W0C76: MOVWF 560C77: MOVF 79,W0C78: MOVWF 550C79: MOVF 78,W0C7A: MOVWF 540C7B: MOVF 77,W0C7C: MOVWF 53.................... b = (b/3.14)*180;0C7D: MOVF 56,W0C7E: MOVWF 6F0C7F: MOVF 55,W0C80: MOVWF 6E0C81: MOVF 54,W0C82: MOVWF 6D0C83: MOVF 53,W0C84: MOVWF 6C0C85: MOVLW C30C86: MOVWF 730C87: MOVLW F50C88: MOVWF 720C89: MOVLW 480C8A: MOVWF 710C8B: MOVLW 800C8C: MOVWF 700C8D: BCF 0A.30C8E: CALL 5060C8F: BSF 0A.30C90: MOVF 77,W0C91: MOVWF 570C92: MOVF 78,W0C93: MOVWF 580C94: MOVF 79,W0C95: MOVWF 590C96: MOVF 7A,W0C97: MOVWF 5A0C98: MOVWF 6F0C99: MOVF 79,W0C9A: MOVWF 6E0C9B: MOVF 78,W0C9C: MOVWF 6D0C9D: MOVF 77,W0C9E: MOVWF 6C0C9F: CLRF 730CA0: CLRF 720CA1: MOVLW 340CA2: MOVWF 710CA3: MOVLW 860CA4: MOVWF 700CA5: BCF 0A.30CA6: CALL 6260CA7: BSF 0A.30CA8: MOVF 7A,W0CA9: MOVWF 560CAA: MOVF 79,W0CAB: MOVWF 550CAC: MOVF 78,W0CAD: MOVWF 540CAE: MOVF 77,W0CAF: MOVWF 53.................... b=abs(b);0CB0: MOVF 53,W0CB1: MOVWF 770CB2: MOVF 54,W0CB3: MOVWF 780CB4: MOVF 55,W0CB5: MOVWF 790CB6: MOVF 56,W0CB7: MOVWF 7A0CB8: BCF 78.70CB9: MOVF 56,W0CBA: MOVWF 560CBB: MOVF 55,W0CBC: MOVWF 550CBD: MOVF 78,W0CBE: MOVWF 540CBF: MOVF 53,W0CC0: MOVWF 53........................................ if(((AX>AY) || (AX>AZ))) //indikace prevraceni panelu0CC1: BTFSS 30.70CC2: GOTO 4C60CC3: BTFSS 2E.70CC4: GOTO 4E30CC5: GOTO 4C80CC6: BTFSC 2E.70CC7: GOTO 4D20CC8: MOVF 30,W0CC9: SUBWF 2E,W0CCA: BTFSS 03.00CCB: GOTO 4D20CCC: BTFSS 03.20CCD: GOTO 4E30CCE: MOVF 2D,W0CCF: SUBWF 2F,W0CD0: BTFSS 03.00CD1: GOTO 4E30CD2: BTFSS 32.70CD3: GOTO 4D70CD4: BTFSS 2E.70CD5: GOTO 4E30CD6: GOTO 4D90CD7: BTFSC 2E.70CD8: GOTO 50C0CD9: MOVF 32,W0CDA: SUBWF 2E,W0CDB: BTFSS 03.00CDC: GOTO 50C0CDD: BTFSS 03.20CDE: GOTO 4E30CDF: MOVF 2D,W0CE0: SUBWF 31,W0CE1: BTFSC 03.00CE2: GOTO 50C.................... {.................... printf("Prevracený panel)\r\n", );0CE3: MOVLW 040CE4: BSF 03.60CE5: MOVWF 0D0CE6: MOVLW 000CE7: MOVWF 0F.................... }.................... else*0D0A: GOTO 5980D0B: BCF 03.6.................... {.................... if(Z==0) //osetreni proti deleni 00D0C: MOVF 2B,F0D0D: BTFSS 03.20D0E: GOTO 5270D0F: MOVF 2C,F0D10: BTFSS 03.20D11: GOTO 527.................... {.................... if(Y>0)0D12: BTFSC 2A.70D13: GOTO 5220D14: MOVF 2A,F0D15: BTFSS 03.20D16: GOTO 51B0D17: MOVF 29,W0D18: SUBLW 000D19: BTFSC 03.00D1A: GOTO 522.................... {.................... b=180;0D1B: CLRF 560D1C: CLRF 550D1D: MOVLW 340D1E: MOVWF 540D1F: MOVLW 860D20: MOVWF 53.................... }.................... else0D21: GOTO 526.................... {.................... b=0;0D22: CLRF 560D23: CLRF 550D24: CLRF 540D25: CLRF 53.................... }.................... }.................... else0D26: GOTO 597.................... {.................... if(Z>0)0D27: BTFSC 2C.70D28: GOTO 5640D29: MOVF 2C,F0D2A: BTFSS 03.20D2B: GOTO 5300D2C: MOVF 2B,W0D2D: SUBLW 000D2E: BTFSC 03.00D2F: GOTO 564.................... {.................... if(Y>=0)0D30: BTFSC 2A.70D31: GOTO 54B.................... {.................... b=90+b;0D32: BCF 03.10D33: CLRF 6F0D34: CLRF 6E0D35: MOVLW 340D36: MOVWF 6D0D37: MOVLW 850D38: MOVWF 6C0D39: MOVF 56,W0D3A: MOVWF 730D3B: MOVF 55,W0D3C: MOVWF 720D3D: MOVF 54,W0D3E: MOVWF 710D3F: MOVF 53,W0D40: MOVWF 700D41: CALL 0000D42: MOVF 7A,W0D43: MOVWF 560D44: MOVF 79,W0D45: MOVWF 550D46: MOVF 78,W0D47: MOVWF 540D48: MOVF 77,W0D49: MOVWF 53.................... }.................... else0D4A: GOTO 563.................... {.................... b=90-b;0D4B: BSF 03.10D4C: CLRF 6F0D4D: CLRF 6E0D4E: MOVLW 340D4F: MOVWF 6D0D50: MOVLW 850D51: MOVWF 6C0D52: MOVF 56,W0D53: MOVWF 730D54: MOVF 55,W0D55: MOVWF 720D56: MOVF 54,W0D57: MOVWF 710D58: MOVF 53,W0D59: MOVWF 700D5A: CALL 0000D5B: MOVF 7A,W0D5C: MOVWF 560D5D: MOVF 79,W0D5E: MOVWF 550D5F: MOVF 78,W0D60: MOVWF 540D61: MOVF 77,W0D62: MOVWF 53.................... }.................... }.................... else0D63: GOTO 597.................... {.................... if(Y>=0)0D64: BTFSC 2A.70D65: GOTO 57F.................... {.................... b=180-b;0D66: BSF 03.10D67: CLRF 6F0D68: CLRF 6E0D69: MOVLW 340D6A: MOVWF 6D0D6B: MOVLW 860D6C: MOVWF 6C0D6D: MOVF 56,W0D6E: MOVWF 730D6F: MOVF 55,W0D70: MOVWF 720D71: MOVF 54,W0D72: MOVWF 710D73: MOVF 53,W0D74: MOVWF 700D75: CALL 0000D76: MOVF 7A,W0D77: MOVWF 560D78: MOVF 79,W0D79: MOVWF 550D7A: MOVF 78,W0D7B: MOVWF 540D7C: MOVF 77,W0D7D: MOVWF 53.................... }.................... else0D7E: GOTO 597.................... {.................... b=270+b;0D7F: BCF 03.10D80: CLRF 6F0D81: CLRF 6E0D82: MOVLW 070D83: MOVWF 6D0D84: MOVLW 870D85: MOVWF 6C0D86: MOVF 56,W0D87: MOVWF 730D88: MOVF 55,W0D89: MOVWF 720D8A: MOVF 54,W0D8B: MOVWF 710D8C: MOVF 53,W0D8D: MOVWF 700D8E: CALL 0000D8F: MOVF 7A,W0D90: MOVWF 560D91: MOVF 79,W0D92: MOVWF 550D93: MOVF 78,W0D94: MOVWF 540D95: MOVF 77,W0D96: MOVWF 530D97: BSF 03.6.................... }.................... }........................................ }................................................................................ }.................... // printf("uhel namìreny %10.2f \r\n", b);........................................ if(b>355)0D98: BCF 03.60D99: CLRF 6B0D9A: MOVLW 800D9B: MOVWF 6A0D9C: MOVLW 310D9D: MOVWF 690D9E: MOVLW 870D9F: MOVWF 680DA0: MOVF 56,W0DA1: MOVWF 6F0DA2: MOVF 55,W0DA3: MOVWF 6E0DA4: MOVF 54,W0DA5: MOVWF 6D0DA6: MOVF 53,W0DA7: MOVWF 6C0DA8: BCF 0A.30DA9: CALL 5E70DAA: BSF 0A.30DAB: BTFSS 03.00DAC: GOTO 5B2.................... {.................... b=0;0DAD: CLRF 560DAE: CLRF 550DAF: CLRF 540DB0: CLRF 53.................... }.................... else0DB1: GOTO 5B2.................... {........................................ }.................... return b;0DB2: MOVF 53,W0DB3: MOVWF 770DB4: MOVF 54,W0DB5: MOVWF 780DB6: MOVF 55,W0DB7: MOVWF 790DB8: MOVF 56,W0DB9: MOVWF 7A........................................ }0DBA: RETURN........................................ float azimut (void) //vypocet aktualni vysky panelu.................... {.................... X= magR (MAG_XH, MAG_XL);*0E8C: MOVLW 030E8D: MOVWF 570E8E: MOVLW 040E8F: MOVWF 580E90: CALL 5BB0E91: MOVF 79,W0E92: MOVWF 280E93: MOVF 78,W0E94: MOVWF 27.................... Y= magR (MAG_YH, MAG_YL);0E95: MOVLW 070E96: MOVWF 570E97: MOVLW 080E98: MOVWF 580E99: CALL 5BB0E9A: MOVF 79,W0E9B: MOVWF 2A0E9C: MOVF 78,W0E9D: MOVWF 29.................... Z= magR (MAG_ZH, MAG_ZL);0E9E: MOVLW 050E9F: MOVWF 570EA0: MOVLW 060EA1: MOVWF 580EA2: CALL 5BB0EA3: MOVF 79,W0EA4: MOVWF 2C0EA5: MOVF 78,W0EA6: MOVWF 2B.................................................................................................... AX=abs(X);0EA7: MOVF 28,W0EA8: MOVWF 7A0EA9: MOVF 27,W0EAA: BTFSS 28.70EAB: GOTO 6B50EAC: MOVF 27,W0EAD: SUBLW 000EAE: MOVWF 770EAF: CLRF 7A0EB0: MOVF 28,W0EB1: BTFSS 03.00EB2: INCFSZ 28,W0EB3: SUBWF 7A,F0EB4: MOVF 77,W0EB5: MOVWF 2D0EB6: MOVF 7A,W0EB7: MOVWF 2E.................... AY=abs(Y);0EB8: MOVF 2A,W0EB9: MOVWF 7A0EBA: MOVF 29,W0EBB: BTFSS 2A.70EBC: GOTO 6C60EBD: MOVF 29,W0EBE: SUBLW 000EBF: MOVWF 770EC0: CLRF 7A0EC1: MOVF 2A,W0EC2: BTFSS 03.00EC3: INCFSZ 2A,W0EC4: SUBWF 7A,F0EC5: MOVF 77,W0EC6: MOVWF 2F0EC7: MOVF 7A,W0EC8: MOVWF 30.................... AZ=abs(Z);0EC9: MOVF 2C,W0ECA: MOVWF 7A0ECB: MOVF 2B,W0ECC: BTFSS 2C.70ECD: GOTO 6D70ECE: MOVF 2B,W0ECF: SUBLW 000ED0: MOVWF 770ED1: CLRF 7A0ED2: MOVF 2C,W0ED3: BTFSS 03.00ED4: INCFSZ 2C,W0ED5: SUBWF 7A,F0ED6: MOVF 77,W0ED7: MOVWF 310ED8: MOVF 7A,W0ED9: MOVWF 32........................................ float a, b;.................... a=(float)Y/X;0EDA: MOVF 2A,W0EDB: MOVWF 5C0EDC: MOVF 29,W0EDD: MOVWF 5B0EDE: BCF 0A.30EDF: CALL 4E10EE0: BSF 0A.30EE1: MOVF 77,W0EE2: MOVWF 570EE3: MOVF 78,W0EE4: MOVWF 580EE5: MOVF 79,W0EE6: MOVWF 590EE7: MOVF 7A,W0EE8: MOVWF 5A0EE9: MOVF 28,W0EEA: MOVWF 5C0EEB: MOVF 27,W0EEC: MOVWF 5B0EED: BCF 0A.30EEE: CALL 4E10EEF: BSF 0A.30EF0: MOVF 5A,W0EF1: MOVWF 6F0EF2: MOVF 59,W0EF3: MOVWF 6E0EF4: MOVF 58,W0EF5: MOVWF 6D0EF6: MOVF 57,W0EF7: MOVWF 6C0EF8: MOVF 7A,W0EF9: MOVWF 730EFA: MOVF 79,W0EFB: MOVWF 720EFC: MOVF 78,W0EFD: MOVWF 710EFE: MOVF 77,W0EFF: MOVWF 700F00: BCF 0A.30F01: CALL 5060F02: BSF 0A.30F03: MOVF 7A,W0F04: MOVWF 520F05: MOVF 79,W0F06: MOVWF 510F07: MOVF 78,W0F08: MOVWF 500F09: MOVF 77,W0F0A: MOVWF 4F.................... b=atan(a);0F0B: MOVF 52,W0F0C: MOVWF 5A0F0D: MOVF 51,W0F0E: MOVWF 590F0F: MOVF 50,W0F10: MOVWF 580F11: MOVF 4F,W0F12: MOVWF 570F13: CALL 15D0F14: MOVF 7A,W0F15: MOVWF 560F16: MOVF 79,W0F17: MOVWF 550F18: MOVF 78,W0F19: MOVWF 540F1A: MOVF 77,W0F1B: MOVWF 53.................... b = (b/3.14)*180;0F1C: MOVF 56,W0F1D: MOVWF 6F0F1E: MOVF 55,W0F1F: MOVWF 6E0F20: MOVF 54,W0F21: MOVWF 6D0F22: MOVF 53,W0F23: MOVWF 6C0F24: MOVLW C30F25: MOVWF 730F26: MOVLW F50F27: MOVWF 720F28: MOVLW 480F29: MOVWF 710F2A: MOVLW 800F2B: MOVWF 700F2C: BCF 0A.30F2D: CALL 5060F2E: BSF 0A.30F2F: MOVF 77,W0F30: MOVWF 570F31: MOVF 78,W0F32: MOVWF 580F33: MOVF 79,W0F34: MOVWF 590F35: MOVF 7A,W0F36: MOVWF 5A0F37: MOVWF 6F0F38: MOVF 79,W0F39: MOVWF 6E0F3A: MOVF 78,W0F3B: MOVWF 6D0F3C: MOVF 77,W0F3D: MOVWF 6C0F3E: CLRF 730F3F: CLRF 720F40: MOVLW 340F41: MOVWF 710F42: MOVLW 860F43: MOVWF 700F44: BCF 0A.30F45: CALL 6260F46: BSF 0A.30F47: MOVF 7A,W0F48: MOVWF 560F49: MOVF 79,W0F4A: MOVWF 550F4B: MOVF 78,W0F4C: MOVWF 540F4D: MOVF 77,W0F4E: MOVWF 53.................... b=abs(b);0F4F: MOVF 53,W0F50: MOVWF 770F51: MOVF 54,W0F52: MOVWF 780F53: MOVF 55,W0F54: MOVWF 790F55: MOVF 56,W0F56: MOVWF 7A0F57: BCF 78.70F58: MOVF 56,W0F59: MOVWF 560F5A: MOVF 55,W0F5B: MOVWF 550F5C: MOVF 78,W0F5D: MOVWF 540F5E: MOVF 53,W0F5F: MOVWF 53.................................................................................................... if(X==0) //osetreni proti deleni 00F60: MOVF 27,F0F61: BTFSS 03.20F62: GOTO 77D0F63: MOVF 28,F0F64: BTFSS 03.20F65: GOTO 77D.................... {.................... if(Y>0)0F66: BTFSC 2A.70F67: GOTO 7760F68: MOVF 2A,F0F69: BTFSS 03.20F6A: GOTO 76F0F6B: MOVF 29,W0F6C: SUBLW 000F6D: BTFSC 03.00F6E: GOTO 776.................... {.................... b=90;0F6F: CLRF 560F70: CLRF 550F71: MOVLW 340F72: MOVWF 540F73: MOVLW 850F74: MOVWF 53.................... }.................... else0F75: GOTO 77C.................... {.................... b=270;0F76: CLRF 560F77: CLRF 550F78: MOVLW 070F79: MOVWF 540F7A: MOVLW 870F7B: MOVWF 53.................... }.................... }.................... else0F7C: GOTO 7D4.................... {.................... if(X>0)0F7D: BTFSC 28.70F7E: GOTO 7A10F7F: MOVF 28,F0F80: BTFSS 03.20F81: GOTO 7860F82: MOVF 27,W0F83: SUBLW 000F84: BTFSC 03.00F85: GOTO 7A1.................... {.................... if(Y>=0)0F86: BTFSS 2A.7.................... {.................... b=b;.................... }.................... else0F87: GOTO 7A0.................... {.................... b=360-b;0F88: BSF 03.10F89: CLRF 6F0F8A: CLRF 6E0F8B: MOVLW 340F8C: MOVWF 6D0F8D: MOVLW 870F8E: MOVWF 6C0F8F: MOVF 56,W0F90: MOVWF 730F91: MOVF 55,W0F92: MOVWF 720F93: MOVF 54,W0F94: MOVWF 710F95: MOVF 53,W0F96: MOVWF 700F97: CALL 0000F98: MOVF 7A,W0F99: MOVWF 560F9A: MOVF 79,W0F9B: MOVWF 550F9C: MOVF 78,W0F9D: MOVWF 540F9E: MOVF 77,W0F9F: MOVWF 53.................... }.................... }.................... else0FA0: GOTO 7D4.................... {.................... if(Y>=0)0FA1: BTFSC 2A.70FA2: GOTO 7BC.................... {.................... b=180-b;0FA3: BSF 03.10FA4: CLRF 6F0FA5: CLRF 6E0FA6: MOVLW 340FA7: MOVWF 6D0FA8: MOVLW 860FA9: MOVWF 6C0FAA: MOVF 56,W0FAB: MOVWF 730FAC: MOVF 55,W0FAD: MOVWF 720FAE: MOVF 54,W0FAF: MOVWF 710FB0: MOVF 53,W0FB1: MOVWF 700FB2: CALL 0000FB3: MOVF 7A,W0FB4: MOVWF 560FB5: MOVF 79,W0FB6: MOVWF 550FB7: MOVF 78,W0FB8: MOVWF 540FB9: MOVF 77,W0FBA: MOVWF 53.................... }.................... else0FBB: GOTO 7D4.................... {.................... b=180+b;0FBC: BCF 03.10FBD: CLRF 6F0FBE: CLRF 6E0FBF: MOVLW 340FC0: MOVWF 6D0FC1: MOVLW 860FC2: MOVWF 6C0FC3: MOVF 56,W0FC4: MOVWF 730FC5: MOVF 55,W0FC6: MOVWF 720FC7: MOVF 54,W0FC8: MOVWF 710FC9: MOVF 53,W0FCA: MOVWF 700FCB: CALL 0000FCC: MOVF 7A,W0FCD: MOVWF 560FCE: MOVF 79,W0FCF: MOVWF 550FD0: MOVF 78,W0FD1: MOVWF 540FD2: MOVF 77,W0FD3: MOVWF 53.................... }.................... }........................................ }............................................................ if(b>355)0FD4: CLRF 6B0FD5: MOVLW 800FD6: MOVWF 6A0FD7: MOVLW 310FD8: MOVWF 690FD9: MOVLW 870FDA: MOVWF 680FDB: MOVF 56,W0FDC: MOVWF 6F0FDD: MOVF 55,W0FDE: MOVWF 6E0FDF: MOVF 54,W0FE0: MOVWF 6D0FE1: MOVF 53,W0FE2: MOVWF 6C0FE3: BCF 0A.30FE4: CALL 5E70FE5: BSF 0A.30FE6: BTFSS 03.00FE7: GOTO 7ED.................... {.................... b=0;0FE8: CLRF 560FE9: CLRF 550FEA: CLRF 540FEB: CLRF 53.................... }.................... else0FEC: GOTO 7ED.................... {........................................ }........................................ return b;0FED: MOVF 53,W0FEE: MOVWF 770FEF: MOVF 54,W0FF0: MOVWF 780FF1: MOVF 55,W0FF2: MOVWF 790FF3: MOVF 56,W0FF4: MOVWF 7A........................................ }0FF5: RETURN........................................ void motorA (int8 H) //pro ovladani prvniho motoru nastaveni vysky.................... {.................... switch(H){*0092: MOVF 4F,W0093: XORLW 010094: BTFSC 03.20095: GOTO 09A0096: XORLW 030097: BTFSC 03.20098: GOTO 0A30099: GOTO 0AC.................... case 1: //reverzní chod.................... output_low (AIN2);009A: BSF 03.5009B: BCF 08.1009C: BCF 03.5009D: BCF 08.1.................... output_high (AIN1);009E: BSF 03.5009F: BCF 08.000A0: BCF 03.500A1: BSF 08.0.................... break;00A2: GOTO 0B4........................................ case 2: //dopøedu.................... output_low (AIN1);00A3: BSF 03.500A4: BCF 08.000A5: BCF 03.500A6: BCF 08.0.................... output_high (AIN2);00A7: BSF 03.500A8: BCF 08.100A9: BCF 03.500AA: BSF 08.1.................... break;00AB: GOTO 0B4........................................ default:.................... output_low (AIN2);00AC: BSF 03.500AD: BCF 08.100AE: BCF 03.500AF: BCF 08.1.................... output_low (AIN1);00B0: BSF 03.500B1: BCF 08.000B2: BCF 03.500B3: BCF 08.0.................... }.................... }00B4: RETURN........................................ void motorB (int8 H) //pro ovladani prvniho motoru nastaveni vysky.................... {.................... switch(H){00B5: MOVF 4F,W00B6: XORLW 0100B7: BTFSC 03.200B8: GOTO 0BD00B9: XORLW 0300BA: BTFSC 03.200BB: GOTO 0C600BC: GOTO 0CF.................... case 1: //reverzní chod.................... output_low (BIN2);00BD: BSF 03.500BE: BCF 08.300BF: BCF 03.500C0: BCF 08.3.................... output_high (BIN1);00C1: BSF 03.500C2: BCF 08.200C3: BCF 03.500C4: BSF 08.2.................... break;00C5: GOTO 0D7........................................ case 2: //dopøedu.................... output_low (BIN1);00C6: BSF 03.500C7: BCF 08.200C8: BCF 03.500C9: BCF 08.2.................... output_high (BIN2);00CA: BSF 03.500CB: BCF 08.300CC: BCF 03.500CD: BSF 08.3.................... break;00CE: GOTO 0D7........................................ default:.................... output_low (BIN2);00CF: BSF 03.500D0: BCF 08.300D1: BCF 03.500D2: BCF 08.3.................... output_low (BIN1);00D3: BSF 03.500D4: BCF 08.200D5: BCF 03.500D6: BCF 08.2.................... }.................... }00D7: RETURN........................................ void elevace_set (int16 H) //slouzi pro nastaveni nove vysky panelu.................... {.................... //printf("Akcelerometr4: \r\n",);.................... float a;.................... int16 b,c;................................................................................................................................................................ a=elevace();*06D8: BSF 0A.306D9: CALL 3DD06DA: BCF 0A.306DB: MOVF 7A,W06DC: MOVWF 4A06DD: MOVF 79,W06DE: MOVWF 4906DF: MOVF 78,W06E0: MOVWF 4806E1: MOVF 77,W06E2: MOVWF 47.................... b= (int16) a;06E3: MOVF 4A,W06E4: MOVWF 5206E5: MOVF 49,W06E6: MOVWF 5106E7: MOVF 48,W06E8: MOVWF 5006E9: MOVF 47,W06EA: MOVWF 4F06EB: CALL 6B906EC: MOVF 79,W06ED: MOVWF 4C06EE: MOVF 78,W06EF: MOVWF 4B.................... c=abs(H-b);06F0: MOVF 4B,W06F1: SUBWF 45,W06F2: MOVWF 4F06F3: MOVF 46,W06F4: MOVWF 5006F5: MOVF 4C,W06F6: BTFSS 03.006F7: INCFSZ 4C,W06F8: SUBWF 50,F06F9: MOVF 50,W06FA: MOVWF 4E06FB: MOVF 4F,W06FC: MOVWF 4D........................................ while(c>2) //maximalni odchylka uhlu, aby nebylo potreba panelem hybat.................... {06FD: MOVF 4E,F06FE: BTFSS 03.206FF: GOTO 7040700: MOVF 4D,W0701: SUBLW 020702: BTFSC 03.00703: GOTO 74D.................... while(H!=b) //probiha dokud se uhel panelu nerovna zadanemu na cele stupne.................... {0704: MOVF 4B,W0705: SUBWF 45,W0706: BTFSS 03.20707: GOTO 70C0708: MOVF 4C,W0709: SUBWF 46,W070A: BTFSC 03.2070B: GOTO 74C........................................ if(H>b)070C: MOVF 4C,W070D: SUBWF 46,W070E: BTFSS 03.0070F: GOTO 71A0710: BTFSS 03.20711: GOTO 7160712: MOVF 45,W0713: SUBWF 4B,W0714: BTFSC 03.00715: GOTO 71A.................... {.................... motorA(2);0716: MOVLW 020717: MOVWF 4F0718: CALL 092........................................ }.................... else0719: GOTO 71D.................... {.................... motorA(1);071A: MOVLW 01071B: MOVWF 4F071C: CALL 092.................... }........................................ delay_ms (50); //cas sepnuti motoru071D: MOVLW 32071E: MOVWF 4F071F: CALL 15D........................................ motorA(3); //vypne motor0720: MOVLW 030721: MOVWF 4F0722: CALL 092.................... delay_ms (50); //doma na ustaleni panelu pred merenim0723: MOVLW 320724: MOVWF 4F0725: CALL 15D.................... a=elevace();0726: BSF 0A.30727: CALL 3DD0728: BCF 0A.30729: MOVF 7A,W072A: MOVWF 4A072B: MOVF 79,W072C: MOVWF 49072D: MOVF 78,W072E: MOVWF 48072F: MOVF 77,W0730: MOVWF 47.................... b= (int16) a;0731: MOVF 4A,W0732: MOVWF 520733: MOVF 49,W0734: MOVWF 510735: MOVF 48,W0736: MOVWF 500737: MOVF 47,W0738: MOVWF 4F0739: CALL 6B9073A: MOVF 79,W073B: MOVWF 4C073C: MOVF 78,W073D: MOVWF 4B............................................................ c=abs(H-b);073E: MOVF 4B,W073F: SUBWF 45,W0740: MOVWF 4F0741: MOVF 46,W0742: MOVWF 500743: MOVF 4C,W0744: BTFSS 03.00745: INCFSZ 4C,W0746: SUBWF 50,F0747: MOVF 50,W0748: MOVWF 4E0749: MOVF 4F,W074A: MOVWF 4D.................... }074B: GOTO 704.................... }074C: GOTO 6FD.................... motorA(3); //vypne motor074D: MOVLW 03074E: MOVWF 4F074F: CALL 092.................... printf("Podaøené nastavení výka: %Ld\r\n", b);0750: MOVLW 180751: BSF 03.60752: MOVWF 0D0753: MOVLW 000754: MOVWF 0F0755: MOVLW 1A0756: BCF 03.60757: MOVWF 4F0758: CALL 2EE0759: MOVLW 10075A: MOVWF 04075B: MOVF 4C,W075C: MOVWF 50075D: MOVF 4B,W075E: MOVWF 4F075F: CALL 30F0760: MOVLW 0D0761: MOVWF 590762: CALL 2220763: MOVLW 0A0764: MOVWF 590765: CALL 222............................................................ }0766: BCF 0A.30767: BSF 0A.40768: GOTO 254 (RETURN)................................................................................ void azimut_set (int16 H) //slouzi pro nastaveni nove vysky panelu.................... {.................... float a;.................... int16 b,c;............................................................ a=azimut();*1000: BCF 0A.41001: BSF 0A.31002: CALL 68C1003: BSF 0A.41004: BCF 0A.31005: MOVF 7A,W1006: MOVWF 4A1007: MOVF 79,W1008: MOVWF 491009: MOVF 78,W100A: MOVWF 48100B: MOVF 77,W100C: MOVWF 47.................... b= (int16) a;100D: MOVF 4A,W100E: MOVWF 52100F: MOVF 49,W1010: MOVWF 511011: MOVF 48,W1012: MOVWF 501013: MOVF 47,W1014: MOVWF 4F1015: BCF 0A.41016: CALL 6B91017: BSF 0A.41018: MOVF 79,W1019: MOVWF 4C101A: MOVF 78,W101B: MOVWF 4B.................... c=abs(H-b);101C: MOVF 4B,W101D: SUBWF 45,W101E: MOVWF 4F101F: MOVF 46,W1020: MOVWF 501021: MOVF 4C,W1022: BTFSS 03.01023: INCFSZ 4C,W1024: SUBWF 50,F1025: MOVF 50,W1026: MOVWF 4E1027: MOVF 4F,W1028: MOVWF 4D........................................ while(c>2) //maximalni odchylka uhlu, aby nebylo potreba panelem hybat.................... {1029: MOVF 4E,F102A: BTFSS 03.2102B: GOTO 030102C: MOVF 4D,W102D: SUBLW 02102E: BTFSC 03.0102F: GOTO 087.................... while(H!=b) //probiha dokud se uhel panelu nerovna zadanemu na cele stupne.................... {1030: MOVF 4B,W1031: SUBWF 45,W1032: BTFSS 03.21033: GOTO 0381034: MOVF 4C,W1035: SUBWF 46,W1036: BTFSC 03.21037: GOTO 086........................................ if(H>b)1038: MOVF 4C,W1039: SUBWF 46,W103A: BTFSS 03.0103B: GOTO 048103C: BTFSS 03.2103D: GOTO 042103E: MOVF 45,W103F: SUBWF 4B,W1040: BTFSC 03.01041: GOTO 048.................... {.................... motorB(2);1042: MOVLW 021043: MOVWF 4F1044: BCF 0A.41045: CALL 0B51046: BSF 0A.4........................................ }.................... else1047: GOTO 04D.................... {.................... motorB(1);1048: MOVLW 011049: MOVWF 4F104A: BCF 0A.4104B: CALL 0B5104C: BSF 0A.4.................... }........................................ delay_ms (50); //cas sepnuti motoru104D: MOVLW 32104E: MOVWF 4F104F: BCF 0A.41050: CALL 15D1051: BSF 0A.4........................................ motorB(3); //vypne motor1052: MOVLW 031053: MOVWF 4F1054: BCF 0A.41055: CALL 0B51056: BSF 0A.4.................... delay_ms (50); //doma na ustaleni panelu pred merenim1057: MOVLW 321058: MOVWF 4F1059: BCF 0A.4105A: CALL 15D105B: BSF 0A.4.................... a=azimut();105C: BCF 0A.4105D: BSF 0A.3105E: CALL 68C105F: BSF 0A.41060: BCF 0A.31061: MOVF 7A,W1062: MOVWF 4A1063: MOVF 79,W1064: MOVWF 491065: MOVF 78,W1066: MOVWF 481067: MOVF 77,W1068: MOVWF 47.................... b= (int16) a;1069: MOVF 4A,W106A: MOVWF 52106B: MOVF 49,W106C: MOVWF 51106D: MOVF 48,W106E: MOVWF 50106F: MOVF 47,W1070: MOVWF 4F1071: BCF 0A.41072: CALL 6B91073: BSF 0A.41074: MOVF 79,W1075: MOVWF 4C1076: MOVF 78,W1077: MOVWF 4B........................................ c=abs(H-b);1078: MOVF 4B,W1079: SUBWF 45,W107A: MOVWF 4F107B: MOVF 46,W107C: MOVWF 50107D: MOVF 4C,W107E: BTFSS 03.0107F: INCFSZ 4C,W1080: SUBWF 50,F1081: MOVF 50,W1082: MOVWF 4E1083: MOVF 4F,W1084: MOVWF 4D.................... }1085: GOTO 030.................... }1086: GOTO 029.................... motorA(3); //vypne motor1087: MOVLW 031088: MOVWF 4F1089: BCF 0A.4108A: CALL 092108B: BSF 0A.4.................... printf("Podaøené nastavení azimut: %Ld\r\n", b);108C: MOVLW 38108D: BSF 03.6108E: MOVWF 0D108F: MOVLW 001090: MOVWF 0F1091: MOVLW 1B1092: BCF 03.61093: MOVWF 4F1094: BCF 0A.41095: CALL 2EE1096: BSF 0A.41097: MOVLW 101098: MOVWF 041099: MOVF 4C,W109A: MOVWF 50109B: MOVF 4B,W109C: MOVWF 4F109D: BCF 0A.4109E: CALL 30F109F: BSF 0A.410A0: MOVLW 0D10A1: MOVWF 5910A2: BCF 0A.410A3: CALL 22210A4: BSF 0A.410A5: MOVLW 0A10A6: MOVWF 5910A7: BCF 0A.410A8: CALL 22210A9: BSF 0A.4................................................................................ }10AA: BCF 0A.310AB: BSF 0A.410AC: GOTO 25A (RETURN)........................................ void main().................... {10AD: CLRF 0410AE: BCF 03.710AF: MOVLW 1F10B0: ANDWF 03,F10B1: MOVLW 7110B2: BSF 03.510B3: MOVWF 0F10B4: MOVF 0F,W10B5: BCF 03.510B6: BCF 20.710B7: MOVF 20,W10B8: BSF 03.510B9: MOVWF 0710BA: BCF 03.510BB: BSF 07.710BC: BSF 03.510BD: BSF 03.610BE: MOVF 09,W10BF: ANDLW C010C0: MOVWF 0910C1: BCF 03.610C2: BCF 1F.410C3: BCF 1F.510C4: MOVLW 0010C5: BSF 03.610C6: MOVWF 0810C7: BCF 03.510C8: CLRF 0710C9: CLRF 0810CA: CLRF 09.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);*10D0: BSF 03.510D1: BSF 03.610D2: MOVF 09,W10D3: ANDLW C010D4: MOVWF 0910D5: BCF 03.610D6: BCF 1F.410D7: BCF 1F.510D8: MOVLW 0010D9: BSF 03.610DA: MOVWF 08.................... setup_adc(ADC_CLOCK_DIV_2);10DB: BCF 03.510DC: BCF 03.610DD: BCF 1F.610DE: BCF 1F.710DF: BSF 03.510E0: BCF 1F.710E1: BCF 03.510E2: BSF 1F.0.................... setup_spi(SPI_SS_DISABLED);10E3: BCF 14.510E4: BCF 20.510E5: MOVF 20,W10E6: BSF 03.510E7: MOVWF 0710E8: BCF 03.510E9: BSF 20.410EA: MOVF 20,W10EB: BSF 03.510EC: MOVWF 0710ED: BCF 03.510EE: BCF 20.310EF: MOVF 20,W10F0: BSF 03.510F1: MOVWF 0710F2: MOVLW 0110F3: BCF 03.510F4: MOVWF 1410F5: MOVLW 0010F6: BSF 03.510F7: MOVWF 14.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);10F8: MOVF 01,W10F9: ANDLW C710FA: IORLW 0810FB: MOVWF 01.................... setup_timer_1(T1_DISABLED);10FC: BCF 03.510FD: CLRF 10.................... setup_timer_2(T2_DISABLED,0,1);10FE: MOVLW 0010FF: MOVWF 781100: MOVWF 121101: MOVLW 001102: BSF 03.51103: MOVWF 12.................... setup_ccp1(CCP_OFF);1104: BCF 03.51105: BSF 20.21106: MOVF 20,W1107: BSF 03.51108: MOVWF 071109: BCF 03.5110A: CLRF 17110B: BSF 03.5110C: CLRF 1B110D: CLRF 1C110E: MOVLW 01110F: MOVWF 1D.................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard1110: BCF 03.51111: BSF 03.61112: CLRF 071113: CLRF 081114: CLRF 09........................................ //setup_adc_ports(PIN_A0); //piny pro A/D RA0.................... //setup_adc_ports(PIN_A1); //piny pro A/D RA1........................................ motorA(3); //vyponuti motorù1115: MOVLW 031116: BCF 03.61117: MOVWF 4F1118: BCF 0A.41119: CALL 092111A: BSF 0A.4.................... motorB(3);111B: MOVLW 03111C: MOVWF 4F111D: BCF 0A.4111E: CALL 0B5111F: BSF 0A.4........................................ setAK(); //nastaveni akcelerometru1120: BCF 0A.41121: GOTO 1221122: BSF 0A.4.................... setmag();1123: BCF 0A.41124: GOTO 1711125: BSF 0A.4.................... printf("System nataceni panelu \r\n",);1126: MOVLW 591127: BSF 03.61128: MOVWF 0D1129: MOVLW 00112A: MOVWF 0F112B: BCF 0A.4112C: BCF 03.6112D: GOTO 246112E: BSF 0A.4.................... while(TRUE).................... {.................... int i[10];.................... int16 vysledek;.................... int b=0;.................... int c;112F: CLRF 43.................... do {.................... b++;1130: INCF 43,F.................... i[b] = getchar();1131: MOVLW 371132: ADDWF 43,W1133: MOVWF 041134: BCF 03.71135: CLRF 481136: MOVF 04,W1137: MOVWF 471138: BCF 48.01139: BTFSC 03.7113A: BSF 48.0113B: BCF 0A.4113C: CALL 28E113D: BSF 0A.4113E: MOVF 47,W113F: MOVWF 041140: BCF 03.71141: BTFSC 48.01142: BSF 03.71143: MOVF 78,W1144: MOVWF 00........................................ // printf("zadaný azimut %d \r\n", i[b]);........................................ } while (i[b] != ' ');1145: MOVLW 371146: ADDWF 43,W1147: MOVWF 041148: BCF 03.71149: MOVF 00,W114A: SUBLW 20114B: BTFSS 03.2114C: GOTO 130.................... b=b-1;114D: MOVLW 01114E: SUBWF 43,F........................................ switch(b){114F: MOVF 43,W1150: XORLW 011151: BTFSC 03.21152: GOTO 15A1153: XORLW 031154: BTFSC 03.21155: GOTO 15F1156: XORLW 011157: BTFSC 03.21158: GOTO 1701159: GOTO 199.................... case 1: //reverzní chod.................... elevaceZAD=i[1]-48;115A: MOVLW 30115B: SUBWF 38,W115C: MOVWF 35115D: CLRF 36.................... break;115E: GOTO 199........................................ case 2: //dopøedu.................... elevaceZAD=(i[2]-48)+(i[1]-48)*10;115F: MOVLW 301160: SUBWF 39,W1161: MOVWF 451162: MOVLW 301163: SUBWF 38,W1164: MOVWF 471165: MOVWF 481166: MOVLW 0A1167: MOVWF 491168: BCF 0A.41169: CALL 2B4116A: BSF 0A.4116B: MOVF 78,W116C: ADDWF 45,W116D: MOVWF 35116E: CLRF 36.................... break;116F: GOTO 199.................... case 3: //dopøedu.................... elevaceZAD=(i[3]-48)+(i[2]-48)*10+((int16)i[1]-48)*100;1170: MOVLW 301171: SUBWF 3A,W1172: MOVWF 451173: MOVLW 301174: SUBWF 39,W1175: MOVWF 471176: MOVWF 481177: MOVLW 0A1178: MOVWF 491179: BCF 0A.4117A: CALL 2B4117B: BSF 0A.4117C: MOVF 78,W117D: ADDWF 45,F117E: CLRF 47117F: MOVF 38,W1180: MOVWF 461181: MOVLW 301182: SUBWF 46,F1183: MOVLW 001184: BTFSS 03.01185: MOVLW 011186: SUBWF 47,F1187: MOVF 47,W1188: MOVWF 491189: MOVF 46,W118A: MOVWF 48118B: CLRF 4B118C: MOVLW 64118D: MOVWF 4A118E: BCF 0A.4118F: CALL 2D91190: BSF 0A.41191: MOVF 78,W1192: ADDWF 45,W1193: MOVWF 351194: MOVF 79,W1195: MOVWF 361196: BTFSC 03.01197: INCF 36,F.................... break;1198: GOTO 199........................................ default:........................................ }.................... printf("Zadaná elevace %Ld \r\n", elevaceZAD);1199: MOVLW 67119A: BSF 03.6119B: MOVWF 0D119C: MOVLW 00119D: MOVWF 0F119E: MOVLW 0F119F: BCF 03.611A0: MOVWF 4F11A1: BCF 0A.411A2: CALL 2EE11A3: BSF 0A.411A4: MOVLW 1011A5: MOVWF 0411A6: MOVF 36,W11A7: MOVWF 5011A8: MOVF 35,W11A9: MOVWF 4F11AA: BCF 0A.411AB: CALL 30F11AC: BSF 0A.411AD: MOVLW 2011AE: MOVWF 5911AF: BCF 0A.411B0: CALL 22211B1: BSF 0A.411B2: MOVLW 0D11B3: MOVWF 5911B4: BCF 0A.411B5: CALL 22211B6: BSF 0A.411B7: MOVLW 0A11B8: MOVWF 5911B9: BCF 0A.411BA: CALL 22211BB: BSF 0A.4........................................ i=0;11BC: CLRF 3811BD: CLRF 37.................... vysledek=0;11BE: CLRF 4211BF: CLRF 41.................... b=0;11C0: CLRF 43.................... c=0;11C1: CLRF 44.................... do {.................... b++;11C2: INCF 43,F.................... i[b] = getchar();11C3: MOVLW 3711C4: ADDWF 43,W11C5: MOVWF 0411C6: BCF 03.711C7: CLRF 4811C8: MOVF 04,W11C9: MOVWF 4711CA: BCF 48.011CB: BTFSC 03.711CC: BSF 48.011CD: BCF 0A.411CE: CALL 28E11CF: BSF 0A.411D0: MOVF 47,W11D1: MOVWF 0411D2: BCF 03.711D3: BTFSC 48.011D4: BSF 03.711D5: MOVF 78,W11D6: MOVWF 00........................................ //printf("Zadaný azimut %d \r\n", i[b]);........................................ } while (i[b] != ' ');11D7: MOVLW 3711D8: ADDWF 43,W11D9: MOVWF 0411DA: BCF 03.711DB: MOVF 00,W11DC: SUBLW 2011DD: BTFSS 03.211DE: GOTO 1C2.................... b=b-1;11DF: MOVLW 0111E0: SUBWF 43,F........................................ switch(b){11E1: MOVF 43,W11E2: XORLW 0111E3: BTFSC 03.211E4: GOTO 1EC11E5: XORLW 0311E6: BTFSC 03.211E7: GOTO 1F111E8: XORLW 0111E9: BTFSC 03.211EA: GOTO 20211EB: GOTO 22B.................... case 1: //reverzní chod.................... azimutZAD=i[1]-48;11EC: MOVLW 3011ED: SUBWF 38,W11EE: MOVWF 3311EF: CLRF 34.................... break;11F0: GOTO 22B........................................ case 2: //dopøedu.................... azimutZAD=(i[2]-48)+(i[1]-48)*10;11F1: MOVLW 3011F2: SUBWF 39,W11F3: MOVWF 4511F4: MOVLW 3011F5: SUBWF 38,W11F6: MOVWF 4711F7: MOVWF 4811F8: MOVLW 0A11F9: MOVWF 4911FA: BCF 0A.411FB: CALL 2B411FC: BSF 0A.411FD: MOVF 78,W11FE: ADDWF 45,W11FF: MOVWF 331200: CLRF 34.................... break;1201: GOTO 22B.................... case 3: //dopøedu.................... azimutZAD=(i[3]-48)+(i[2]-48)*10+((int16)i[1]-48)*100;1202: MOVLW 301203: SUBWF 3A,W1204: MOVWF 451205: MOVLW 301206: SUBWF 39,W1207: MOVWF 471208: MOVWF 481209: MOVLW 0A120A: MOVWF 49120B: BCF 0A.4120C: CALL 2B4120D: BSF 0A.4120E: MOVF 78,W120F: ADDWF 45,F1210: CLRF 471211: MOVF 38,W1212: MOVWF 461213: MOVLW 301214: SUBWF 46,F1215: MOVLW 001216: BTFSS 03.01217: MOVLW 011218: SUBWF 47,F1219: MOVF 47,W121A: MOVWF 49121B: MOVF 46,W121C: MOVWF 48121D: CLRF 4B121E: MOVLW 64121F: MOVWF 4A1220: BCF 0A.41221: CALL 2D91222: BSF 0A.41223: MOVF 78,W1224: ADDWF 45,W1225: MOVWF 331226: MOVF 79,W1227: MOVWF 341228: BTFSC 03.01229: INCF 34,F.................... break;122A: GOTO 22B........................................ default:........................................ }............................................................ printf("Zadaný azimut %Ld \r\n", azimutZAD);122B: MOVLW 7D122C: BSF 03.6122D: MOVWF 0D122E: MOVLW 00122F: MOVWF 0F1230: MOVLW 0E1231: BCF 03.61232: MOVWF 4F1233: BCF 0A.41234: CALL 2EE1235: BSF 0A.41236: MOVLW 101237: MOVWF 041238: MOVF 34,W1239: MOVWF 50123A: MOVF 33,W123B: MOVWF 4F123C: BCF 0A.4123D: CALL 30F123E: BSF 0A.4123F: MOVLW 201240: MOVWF 591241: BCF 0A.41242: CALL 2221243: BSF 0A.41244: MOVLW 0D1245: MOVWF 591246: BCF 0A.41247: CALL 2221248: BSF 0A.41249: MOVLW 0A124A: MOVWF 59124B: BCF 0A.4124C: CALL 222124D: BSF 0A.4.................................................................................................... elevace_set (elevaceZAD);124E: MOVF 36,W124F: MOVWF 461250: MOVF 35,W1251: MOVWF 451252: BCF 0A.41253: GOTO 6D81254: BSF 0A.4.................... azimut_set(azimutZAD);1255: MOVF 34,W1256: MOVWF 461257: MOVF 33,W1258: MOVWF 451259: GOTO 000................................................................................ delay_ms (2000);125A: MOVLW 08125B: MOVWF 45125C: MOVLW FA125D: MOVWF 4F125E: BCF 0A.4125F: CALL 15D1260: BSF 0A.41261: DECFSZ 45,F1262: GOTO 25C............................................................ }1263: GOTO 12F.................... }1264: SLEEPConfiguration Fuses:Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUGWord 2: 3FFF NOWRT BORV40