CCS PCH C Compiler, Version 4.039u, 37276               05-Jul-07 21:13

               Filename: C:\Program Files\PICC\Projects\SWATH\main.lst

               ROM used: 5602 bytes (17%)
                         Largest free fragment is 27162
               RAM used: 283 (19%) at main() level
                         500 (33%) worst case
               Stack:    6 worst case (3 in main + 3 for interrupts)

*
0000:  GOTO   127C
*
0008:  MOVWF  05
000A:  MOVFF  FD8,06
000E:  MOVFF  FE0,07
0012:  MOVLB  0
0014:  MOVFF  FE9,0D
0018:  MOVFF  FEA,08
001C:  MOVFF  FE1,09
0020:  MOVFF  FE2,0A
0024:  MOVFF  FD9,0B
0028:  MOVFF  FDA,0C
002C:  MOVFF  FF3,14
0030:  MOVFF  FF4,15
0034:  MOVFF  FFA,16
0038:  MOVFF  00,0F
003C:  MOVFF  01,10
0040:  MOVFF  02,11
0044:  MOVFF  03,12
0048:  MOVFF  04,13
004C:  BTFSS  F9D.5
004E:  GOTO   0058
0052:  BTFSC  F9E.5
0054:  GOTO   0216
0058:  MOVFF  0F,00
005C:  MOVFF  10,01
0060:  MOVFF  11,02
0064:  MOVFF  12,03
0068:  MOVFF  13,04
006C:  BSF    0E.7
006E:  MOVFF  0D,FE9
0072:  MOVFF  08,FEA
0076:  MOVFF  09,FE1
007A:  MOVFF  0A,FE2
007E:  MOVFF  0B,FD9
0082:  MOVFF  0C,FDA
0086:  MOVFF  14,FF3
008A:  MOVFF  15,FF4
008E:  MOVFF  16,FFA
0092:  MOVF   05,W
0094:  MOVFF  07,FE0
0098:  MOVFF  06,FD8
009C:  RETFIE 0
....................   #include "main.h" 
.................... #include <18F4520.h> 
.................... //////// Standard Header file for the PIC18F4520 device //////////////// 
.................... #device PIC18F4520 
.................... #list 
....................  
.................... #device adc=8 
.................... #device icd=true                   //8bit ADC 
....................  
.................... #FUSES NOWDT                    //No Watch Dog Timer 
.................... #FUSES HS                       //High speed Osc (> 4mhz) 
.................... #FUSES NOCPD                    //No EE protection 
.................... #FUSES STVREN                   //Stack full/underflow will cause reset 
.................... #FUSES MCLR                     //Master Clear pin enabled 
....................  
.................... #use delay(clock=20000000)       //20MHZ CLOCK 
1252:  MOVLW  01
1254:  MOVWF  FEA
1256:  MOVLW  15
1258:  MOVWF  FE9
125A:  MOVF   FEF,W
125C:  BZ    1278
125E:  MOVLW  06
1260:  MOVWF  01
1262:  CLRF   00
1264:  DECFSZ 00,F
1266:  BRA    1264
1268:  DECFSZ 01,F
126A:  BRA    1262
126C:  MOVLW  7B
126E:  MOVWF  00
1270:  DECFSZ 00,F
1272:  BRA    1270
1274:  DECFSZ FEF,F
1276:  BRA    125E
1278:  GOTO   15DA (RETURN)
.................... #use rs232(baud=9600,parity=N,xmit=PIN_c1,rcv=PIN_C0,bits=8,stream=BASESTREAM,ERRORS,force_sw) 
*
0128:  BCF    F94.1
012A:  BCF    F8B.1
012C:  MOVLW  08
012E:  MOVWF  01
0130:  BRA    0132
0132:  NOP   
0134:  BSF    01.7
0136:  BRA    0158
0138:  BCF    01.7
013A:  MOVLB  1
013C:  RRCF   xF1,F
013E:  MOVLB  0
0140:  BTFSC  FD8.0
0142:  BSF    F8B.1
0144:  BTFSS  FD8.0
0146:  BCF    F8B.1
0148:  BSF    01.6
014A:  BRA    0158
014C:  BCF    01.6
014E:  DECFSZ 01,F
0150:  BRA    013A
0152:  BRA    0154
0154:  NOP   
0156:  BSF    F8B.1
0158:  MOVLW  A7
015A:  MOVWF  FE9
015C:  DECFSZ FE9,F
015E:  BRA    015C
0160:  BRA    0162
0162:  BTFSC  01.7
0164:  BRA    0138
0166:  BTFSC  01.6
0168:  BRA    014C
016A:  RETLW  00
....................  
.................... #use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3) 
....................  
....................  
....................   #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(int *)==1 
.................... #define ptrdiff_t int 
.................... #else 
.................... #define ptrdiff_t long 
.................... #endif 
....................  
.................... #define size_t int 
.................... #define wchar_t char 
.................... #define NULL 0 
....................  
.................... #define offsetof(s,f) (offsetofbit(s,f)/8) 
....................  
.................... #endif 
....................  
....................  
.................... //--------------------------------------------------------------------------- 
.................... // String conversion functions 
.................... //--------------------------------------------------------------------------- 
....................  
.................... /* Standard template: float atof(char * s) 
....................  * converts the initial portion of the string s to a float. 
....................  * returns the converted value if any, 0 otherwise 
....................  */ 
.................... float atof(char * s); 
....................  
.................... /* Standard template: float 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 
....................  */ 
.................... float atoe(char * s); 
....................  
.................... /* 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*/ 
.................... signed int32 atoi32(char *s); 
....................  
.................... /* 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, int8 base, char * s); 
....................  
.................... /* Standard template: signed long  atol(char * s) 
....................  * converts the initial portion of the string s to a signed long 
....................  * returns the converted value if any, 0 otherwise 
....................  */ 
.................... signed long atol(char *s); 
....................  
.................... /* Standard template: float strtol(char * s,char *endptr) 
....................  * converts the initial portion of the string s to a float 
....................  * returns the converted value if any, 0 otherwise 
....................  * the final string is returned in the endptr, if endptr is not null 
....................  */ 
.................... float strtod(char *s,char *endptr); 
....................  
.................... /* Standard template: long 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: long 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 
....................  */ 
.................... long strtoul(char *s,char *endptr,signed int base); 
....................  
.................... //--------------------------------------------------------------------------- 
.................... // 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 
....................  */ 
.................... long 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 int 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(int *)==1 
.................... #define ptrdiff_t int 
.................... #else 
.................... #define ptrdiff_t long 
.................... #endif 
....................  
.................... #define size_t int 
.................... #define wchar_t char 
.................... #define NULL 0 
....................  
.................... #define offsetof(s,f) (offsetofbit(s,f)/8) 
....................  
.................... #endif 
....................  
.................... #include <string.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 _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(int *)==1 
.................... #define ptrdiff_t int 
.................... #else 
.................... #define ptrdiff_t long 
.................... #endif 
....................  
.................... #define size_t int 
.................... #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; 
....................   } 
....................  
.................... /* compiler ignored the name 'strcpy()'; perhaps, it's reserved? 
....................    Standard template: char *strcpy(char *s1, const char *s2) 
....................    copies the string s2 including the null character to s1*/ 
....................  
.................... char *strcopy(char *s1, char *s2) 
.................... { 
....................   char *s; 
....................  
....................   for (s = s1; *s2 != 0; s++, s2++) { 
....................      *s = *s2; 
....................   } 
....................   *s = *s2; 
....................   return(s1); 
.................... } 
....................  
.................... /* 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--) 
*
046C:  MOVFF  1C5,1CA
0470:  MOVFF  1C4,1C9
0474:  MOVLB  1
0476:  MOVF   xC8,F
0478:  BZ    04C2
047A:  MOVFF  1C7,03
047E:  MOVFF  1C6,FE9
0482:  MOVFF  1C7,FEA
0486:  MOVF   FEF,F
0488:  BZ    04C2
....................      *s++ = *s2++; 
048A:  MOVFF  1CA,03
048E:  MOVF   xC9,W
0490:  INCF   xC9,F
0492:  BTFSC  FD8.2
0494:  INCF   xCA,F
0496:  MOVWF  xCB
0498:  MOVFF  03,1CC
049C:  MOVFF  1C7,03
04A0:  MOVF   xC6,W
04A2:  INCF   xC6,F
04A4:  BTFSC  FD8.2
04A6:  INCF   xC7,F
04A8:  MOVWF  FE9
04AA:  MOVFF  03,FEA
04AE:  MOVFF  FEF,1CD
04B2:  MOVFF  1CC,FEA
04B6:  MOVFF  1CB,FE9
04BA:  MOVFF  1CD,FEF
04BE:  DECF   xC8,F
04C0:  BRA    0476
....................   for (; n > 0; n--) 
04C2:  MOVF   xC8,F
04C4:  BZ    04DE
....................      *s++ = '\0'; 
04C6:  MOVFF  1CA,03
04CA:  MOVF   xC9,W
04CC:  INCF   xC9,F
04CE:  BTFSC  FD8.2
04D0:  INCF   xCA,F
04D2:  MOVWF  FE9
04D4:  MOVFF  03,FEA
04D8:  CLRF   FEF
04DA:  DECF   xC8,F
04DC:  BRA    04C2
....................  
....................   return(s1); 
04DE:  MOVFF  1C4,01
04E2:  MOVFF  1C5,02
.................... } 
04E6:  MOVLB  0
04E8:  RETLW  00
.................... /***********************************************************/ 
....................  
.................... /*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 int 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 int 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 int 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 int 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; 
....................   int 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,int 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, int 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*/ 
....................  
.................... int *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++) 
*
0342:  MOVFF  1CD,1D1
0346:  MOVFF  1CC,1D0
034A:  MOVFF  1D1,03
034E:  MOVLB  1
0350:  MOVFF  1D0,FE9
0354:  MOVFF  1D1,FEA
0358:  MOVF   FEF,F
035A:  BZ    03B0
....................       for (sc2 = s2; *sc2 != 0; sc2++) 
035C:  MOVFF  1CF,1D3
0360:  MOVFF  1CE,1D2
0364:  MOVFF  1D3,03
0368:  MOVFF  1D2,FE9
036C:  MOVFF  1D3,FEA
0370:  MOVF   FEF,F
0372:  BZ    03A4
....................          if (*sc1 == *sc2) 
0374:  MOVFF  1D0,FE9
0378:  MOVFF  1D1,FEA
037C:  MOVFF  FEF,1D4
0380:  MOVFF  1D3,03
0384:  MOVFF  1D2,FE9
0388:  MOVFF  1D3,FEA
038C:  MOVF   FEF,W
038E:  SUBWF  xD4,W
0390:  BNZ   039C
....................             return(sc1); 
0392:  MOVFF  1D0,01
0396:  MOVFF  1D1,02
039A:  BRA    03B6
039C:  INCF   xD2,F
039E:  BTFSC  FD8.2
03A0:  INCF   xD3,F
03A2:  BRA    0364
03A4:  INCF   xD0,F
03A6:  BTFSC  FD8.2
03A8:  INCF   xD1,F
03AA:  MOVLB  0
03AC:  BRA    034A
03AE:  MOVLB  1
....................    return(0); 
03B0:  MOVLW  00
03B2:  MOVWF  01
03B4:  MOVWF  02
.................... } 
03B6:  MOVLB  0
03B8:  GOTO   042E (RETURN)
....................  
....................  
.................... /* standard template: char *strrchr(const char *s, int c). 
....................    Finds last occurrence of c in s */ 
....................  
.................... char *strrchr(char *s, int 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 */ 
....................  
.................... int *strspn(char *s1, char *s2) 
.................... { 
....................    char *sc1, *sc2; 
....................  
....................    for (sc1 = s1; *sc1 != 0; sc1++) 
*
02AE:  MOVFF  1CD,1D1
02B2:  MOVFF  1CC,1D0
02B6:  MOVFF  1D1,03
02BA:  MOVLB  1
02BC:  MOVFF  1D0,FE9
02C0:  MOVFF  1D1,FEA
02C4:  MOVF   FEF,F
02C6:  BZ    032A
....................       for (sc2 = s2; ; sc2++) 
02C8:  MOVFF  1CF,1D3
02CC:  MOVFF  1CE,1D2
....................     if (*sc2 == '\0') 
02D0:  MOVFF  1D3,03
02D4:  MOVFF  1D2,FE9
02D8:  MOVFF  1D3,FEA
02DC:  MOVF   FEF,F
02DE:  BNZ   02F6
....................        return(sc1 - s1); 
02E0:  MOVF   xCC,W
02E2:  SUBWF  xD0,W
02E4:  MOVWF  00
02E6:  MOVF   xCD,W
02E8:  SUBWFB xD1,W
02EA:  MOVWF  03
02EC:  MOVFF  00,01
02F0:  MOVWF  02
02F2:  BRA    033C
....................          else if (*sc1 == *sc2) 
02F4:  BRA    0316
02F6:  MOVFF  1D0,FE9
02FA:  MOVFF  1D1,FEA
02FE:  MOVFF  FEF,1D4
0302:  MOVFF  1D3,03
0306:  MOVFF  1D2,FE9
030A:  MOVFF  1D3,FEA
030E:  MOVF   FEF,W
0310:  SUBWF  xD4,W
0312:  BNZ   0316
....................             break; 
0314:  BRA    031E
0316:  INCF   xD2,F
0318:  BTFSC  FD8.2
031A:  INCF   xD3,F
031C:  BRA    02D0
031E:  INCF   xD0,F
0320:  BTFSC  FD8.2
0322:  INCF   xD1,F
0324:  MOVLB  0
0326:  BRA    02B6
0328:  MOVLB  1
....................    return(sc1 - s1); 
032A:  MOVF   xCC,W
032C:  SUBWF  xD0,W
032E:  MOVWF  00
0330:  MOVF   xCD,W
0332:  SUBWFB xD1,W
0334:  MOVWF  03
0336:  MOVFF  00,01
033A:  MOVWF  02
.................... } 
033C:  MOVLB  0
033E:  GOTO   03EC (RETURN)
.................... /* 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; 
*
03BC:  MOVLB  1
03BE:  MOVF   xC4,W
03C0:  IORWF  xC5,W
03C2:  BZ    03CC
03C4:  MOVFF  1C5,03
03C8:  MOVF   xC4,W
03CA:  BRA    03D2
03CC:  MOVFF  1A,03
03D0:  MOVF   19,W
03D2:  MOVWF  xC8
03D4:  MOVFF  03,1C9
....................    beg += strspn(beg, s2); 
03D8:  MOVFF  1C9,1CD
03DC:  MOVFF  1C8,1CC
03E0:  MOVFF  1C7,1CF
03E4:  MOVFF  1C6,1CE
03E8:  MOVLB  0
03EA:  BRA    02AE
03EC:  MOVF   01,W
03EE:  MOVLB  1
03F0:  ADDWF  xC8,F
03F2:  MOVF   02,W
03F4:  ADDWFC xC9,F
....................    if (*beg == '\0') 
03F6:  MOVFF  1C9,03
03FA:  MOVFF  1C8,FE9
03FE:  MOVFF  1C9,FEA
0402:  MOVF   FEF,F
0404:  BNZ   041A
....................    { 
....................       *save = ' '; 
0406:  MOVFF  19,FE9
040A:  MOVFF  1A,FEA
040E:  MOVLW  20
0410:  MOVWF  FEF
....................       return(0); 
0412:  MOVLW  00
0414:  MOVWF  01
0416:  MOVWF  02
0418:  BRA    0468
....................    } 
....................    end = strpbrk(beg, s2); 
041A:  MOVFF  1C9,1CD
041E:  MOVFF  1C8,1CC
0422:  MOVFF  1C7,1CF
0426:  MOVFF  1C6,1CE
042A:  MOVLB  0
042C:  BRA    0342
042E:  MOVFF  02,1CB
0432:  MOVFF  01,1CA
....................    if (*end != '\0') 
0436:  MOVFF  1CB,03
043A:  MOVLB  1
043C:  MOVFF  1CA,FE9
0440:  MOVFF  1CB,FEA
0444:  MOVF   FEF,F
0446:  BZ    0458
....................    { 
....................       *end = '\0'; 
0448:  MOVFF  1CA,FE9
044C:  MOVFF  1CB,FEA
0450:  CLRF   FEF
....................       end++; 
0452:  INCF   xCA,F
0454:  BTFSC  FD8.2
0456:  INCF   xCB,F
....................    } 
....................    save = end; 
0458:  MOVFF  1CB,1A
045C:  MOVFF  1CA,19
....................    return(beg); 
0460:  MOVFF  1C8,01
0464:  MOVFF  1C9,02
.................... } 
0468:  MOVLB  0
046A:  RETLW  00
....................  
.................... /*****************************************************************/ 
.................... /*Miscellaneous functions*/ 
.................... /* standard template 
.................... maps error number in errnum to an error message string 
.................... Returns: Pointer to string 
.................... */ 
.................... #ifdef _ERRNO 
.................... char * strerror(int 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) */ 
....................  
.................... int *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 int 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); 
.................... } 
....................  
.................... float atof(char * s) 
.................... { 
....................    float pow10 = 1.0; 
*
09EC:  MOVLW  7F
09EE:  MOVLB  1
09F0:  MOVWF  xCA
09F2:  CLRF   xCB
09F4:  CLRF   xCC
09F6:  CLRF   xCD
....................    float result = 0.0; 
09F8:  CLRF   xCE
09FA:  CLRF   xCF
09FC:  CLRF   xD0
09FE:  CLRF   xD1
....................    int sign = 0; 
0A00:  CLRF   xD2
....................    char c; 
....................    int ptr = 0; 
0A02:  CLRF   xD4
....................  
....................    c = s[ptr++]; 
0A04:  MOVF   xD4,W
0A06:  INCF   xD4,F
0A08:  CLRF   03
0A0A:  ADDWF  xC8,W
0A0C:  MOVWF  FE9
0A0E:  MOVF   xC9,W
0A10:  ADDWFC 03,W
0A12:  MOVWF  FEA
0A14:  MOVFF  FEF,1D3
....................  
....................    if ((c>='0' && c<='9') || c=='+' || c=='-' || c=='.') { 
0A18:  MOVF   xD3,W
0A1A:  SUBLW  2F
0A1C:  BC    0A24
0A1E:  MOVF   xD3,W
0A20:  SUBLW  39
0A22:  BC    0A38
0A24:  MOVF   xD3,W
0A26:  SUBLW  2B
0A28:  BZ    0A38
0A2A:  MOVF   xD3,W
0A2C:  SUBLW  2D
0A2E:  BZ    0A38
0A30:  MOVF   xD3,W
0A32:  SUBLW  2E
0A34:  BTFSS  FD8.2
0A36:  BRA    0C0A
....................       if(c == '-') { 
0A38:  MOVF   xD3,W
0A3A:  SUBLW  2D
0A3C:  BNZ   0A56
....................          sign = 1; 
0A3E:  MOVLW  01
0A40:  MOVWF  xD2
....................          c = s[ptr++]; 
0A42:  MOVF   xD4,W
0A44:  INCF   xD4,F
0A46:  CLRF   03
0A48:  ADDWF  xC8,W
0A4A:  MOVWF  FE9
0A4C:  MOVF   xC9,W
0A4E:  ADDWFC 03,W
0A50:  MOVWF  FEA
0A52:  MOVFF  FEF,1D3
....................       } 
....................       if(c == '+') 
0A56:  MOVF   xD3,W
0A58:  SUBLW  2B
0A5A:  BNZ   0A70
....................          c = s[ptr++]; 
0A5C:  MOVF   xD4,W
0A5E:  INCF   xD4,F
0A60:  CLRF   03
0A62:  ADDWF  xC8,W
0A64:  MOVWF  FE9
0A66:  MOVF   xC9,W
0A68:  ADDWFC 03,W
0A6A:  MOVWF  FEA
0A6C:  MOVFF  FEF,1D3
....................  
....................       while((c >= '0' && c <= '9')) { 
0A70:  MOVF   xD3,W
0A72:  SUBLW  2F
0A74:  BC    0B38
0A76:  MOVF   xD3,W
0A78:  SUBLW  39
0A7A:  BNC   0B38
....................          result = 10*result + c - '0'; 
0A7C:  CLRF   xD8
0A7E:  CLRF   xD7
0A80:  MOVLW  20
0A82:  MOVWF  xD6
0A84:  MOVLW  82
0A86:  MOVWF  xD5
0A88:  MOVFF  1D1,1DC
0A8C:  MOVFF  1D0,1DB
0A90:  MOVFF  1CF,1DA
0A94:  MOVFF  1CE,1D9
0A98:  MOVLB  0
0A9A:  RCALL  04EA
0A9C:  MOVFF  00,1D5
0AA0:  MOVFF  01,1D6
0AA4:  MOVFF  02,1D7
0AA8:  MOVFF  03,1D8
0AAC:  MOVLB  1
0AAE:  CLRF   xDA
0AB0:  MOVFF  1D3,1D9
0AB4:  MOVLB  0
0AB6:  RCALL  05E0
0AB8:  BCF    FD8.1
0ABA:  MOVFF  1D8,1E0
0ABE:  MOVFF  1D7,1DF
0AC2:  MOVFF  1D6,1DE
0AC6:  MOVFF  1D5,1DD
0ACA:  MOVFF  03,1E4
0ACE:  MOVFF  02,1E3
0AD2:  MOVFF  01,1E2
0AD6:  MOVFF  00,1E1
0ADA:  RCALL  0616
0ADC:  MOVFF  00,1D9
0AE0:  MOVFF  01,1DA
0AE4:  MOVFF  02,1DB
0AE8:  MOVFF  03,1DC
0AEC:  BSF    FD8.1
0AEE:  MOVFF  03,1E0
0AF2:  MOVFF  02,1DF
0AF6:  MOVFF  01,1DE
0AFA:  MOVFF  00,1DD
0AFE:  MOVLB  1
0B00:  CLRF   xE4
0B02:  CLRF   xE3
0B04:  MOVLW  40
0B06:  MOVWF  xE2
0B08:  MOVLW  84
0B0A:  MOVWF  xE1
0B0C:  MOVLB  0
0B0E:  RCALL  0616
0B10:  MOVFF  03,1D1
0B14:  MOVFF  02,1D0
0B18:  MOVFF  01,1CF
0B1C:  MOVFF  00,1CE
....................          c = s[ptr++]; 
0B20:  MOVLB  1
0B22:  MOVF   xD4,W
0B24:  INCF   xD4,F
0B26:  CLRF   03
0B28:  ADDWF  xC8,W
0B2A:  MOVWF  FE9
0B2C:  MOVF   xC9,W
0B2E:  ADDWFC 03,W
0B30:  MOVWF  FEA
0B32:  MOVFF  FEF,1D3
....................       } 
0B36:  BRA    0A70
....................  
....................       if (c == '.') { 
0B38:  MOVF   xD3,W
0B3A:  SUBLW  2E
0B3C:  BNZ   0C0A
....................          c = s[ptr++]; 
0B3E:  MOVF   xD4,W
0B40:  INCF   xD4,F
0B42:  CLRF   03
0B44:  ADDWF  xC8,W
0B46:  MOVWF  FE9
0B48:  MOVF   xC9,W
0B4A:  ADDWFC 03,W
0B4C:  MOVWF  FEA
0B4E:  MOVFF  FEF,1D3
....................          while((c >= '0' && c <= '9')) { 
0B52:  MOVF   xD3,W
0B54:  SUBLW  2F
0B56:  BC    0C0A
0B58:  MOVF   xD3,W
0B5A:  SUBLW  39
0B5C:  BNC   0C0A
....................              pow10 = pow10*10; 
0B5E:  MOVFF  1CD,1D8
0B62:  MOVFF  1CC,1D7
0B66:  MOVFF  1CB,1D6
0B6A:  MOVFF  1CA,1D5
0B6E:  CLRF   xDC
0B70:  CLRF   xDB
0B72:  MOVLW  20
0B74:  MOVWF  xDA
0B76:  MOVLW  82
0B78:  MOVWF  xD9
0B7A:  MOVLB  0
0B7C:  RCALL  04EA
0B7E:  MOVFF  03,1CD
0B82:  MOVFF  02,1CC
0B86:  MOVFF  01,1CB
0B8A:  MOVFF  00,1CA
....................              result += (c - '0')/pow10; 
0B8E:  MOVLW  30
0B90:  MOVLB  1
0B92:  SUBWF  xD3,W
0B94:  CLRF   xDA
0B96:  MOVWF  xD9
0B98:  MOVLB  0
0B9A:  RCALL  05E0
0B9C:  MOVFF  03,1D9
0BA0:  MOVFF  02,1D8
0BA4:  MOVFF  01,1D7
0BA8:  MOVFF  00,1D6
0BAC:  MOVFF  1CD,1DD
0BB0:  MOVFF  1CC,1DC
0BB4:  MOVFF  1CB,1DB
0BB8:  MOVFF  1CA,1DA
0BBC:  RCALL  088E
0BBE:  BCF    FD8.1
0BC0:  MOVFF  1D1,1E0
0BC4:  MOVFF  1D0,1DF
0BC8:  MOVFF  1CF,1DE
0BCC:  MOVFF  1CE,1DD
0BD0:  MOVFF  03,1E4
0BD4:  MOVFF  02,1E3
0BD8:  MOVFF  01,1E2
0BDC:  MOVFF  00,1E1
0BE0:  RCALL  0616
0BE2:  MOVFF  03,1D1
0BE6:  MOVFF  02,1D0
0BEA:  MOVFF  01,1CF
0BEE:  MOVFF  00,1CE
....................              c = s[ptr++]; 
0BF2:  MOVLB  1
0BF4:  MOVF   xD4,W
0BF6:  INCF   xD4,F
0BF8:  CLRF   03
0BFA:  ADDWF  xC8,W
0BFC:  MOVWF  FE9
0BFE:  MOVF   xC9,W
0C00:  ADDWFC 03,W
0C02:  MOVWF  FEA
0C04:  MOVFF  FEF,1D3
....................          } 
0C08:  BRA    0B52
....................       } 
....................  
....................    } 
....................  
....................    if (sign == 1) 
0C0A:  DECFSZ xD2,W
0C0C:  BRA    0C40
....................       result = -1*result; 
0C0E:  CLRF   xD8
0C10:  CLRF   xD7
0C12:  MOVLW  80
0C14:  MOVWF  xD6
0C16:  MOVLW  7F
0C18:  MOVWF  xD5
0C1A:  MOVFF  1D1,1DC
0C1E:  MOVFF  1D0,1DB
0C22:  MOVFF  1CF,1DA
0C26:  MOVFF  1CE,1D9
0C2A:  MOVLB  0
0C2C:  RCALL  04EA
0C2E:  MOVFF  03,1D1
0C32:  MOVFF  02,1D0
0C36:  MOVFF  01,1CF
0C3A:  MOVFF  00,1CE
0C3E:  MOVLB  1
....................    return(result); 
0C40:  MOVFF  1CE,00
0C44:  MOVFF  1CF,01
0C48:  MOVFF  1D0,02
0C4C:  MOVFF  1D1,03
.................... } 
0C50:  MOVLB  0
0C52:  RETLW  00
....................  
.................... float atoe(char * s) 
.................... { 
....................    float pow10 = 1.0; 
....................    float result = 0.0; 
....................    int sign = 0; 
....................    int expsign = 0; 
....................    char c; 
....................    int ptr = 0; 
....................    int i; 
....................    float exp = 1.0; 
....................    int 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); 
.................... } 
....................  
.................... signed int atoi(char *s) 
.................... { 
....................    signed int result; 
....................    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; 
....................    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) ); 
.................... } 
....................  
.................... signed int32 atoi32(char *s) 
.................... { 
....................    signed int32 result; 
....................    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 = (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); 
.................... } 
....................  
.................... char * itoa(signed int32 num, int8 base, char *s) 
.................... { 
....................      int32 temp=1; 
....................      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 strtod(char *s,char *endptr) { 
....................    float pow10 = 1.0; 
....................    float result = 0.0; 
....................    int sign = 0, point = 0; 
....................    char c; 
....................    int ptr = 0; 
....................  
....................    if (!s) 
....................       return 0; 
....................    c=s[ptr++]; 
....................  
....................  
....................    while((c>='0' && c<='9') || c=='+' || c=='-' || c=='.') { 
....................       if(c == '-') { 
....................          sign = 1; 
....................          c = s[ptr++]; 
....................       } 
....................  
....................       while((c >= '0' && c <= '9') && point == 0) { 
....................          result = 10*result + c - '0'; 
....................          c = s[ptr++]; 
....................       } 
....................  
....................       if (c == '.') { 
....................          point = 1; 
....................          c = s[ptr++]; 
....................       } 
....................  
....................       while((c >= '0' && c <= '9') && point == 1) { 
....................          pow10 = pow10*10; 
....................          result += (c - '0')/pow10; 
....................          c = s[ptr++]; 
....................       } 
....................  
....................       if (c == '+') { 
....................          c = s[ptr++]; 
....................       } 
....................    } 
....................  
....................    if (sign == 1) 
....................       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); 
.................... } 
....................  
.................... 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 int system(char *string) 
.................... { 
....................    return 0; 
.................... } 
....................  
.................... int mblen(char *s,size_t n) 
.................... { 
....................    return strlen(s); 
.................... } 
....................  
.................... int mbtowc(wchar_t *pwc,char *s,size_t n) 
.................... { 
....................    *pwc=*s; 
....................    return 1; 
.................... } 
....................  
.................... int 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; 
....................  
.................... long rand(void) 
.................... { 
....................    _Randseed = _Randseed * 1103515245 + 12345; 
....................    return ((unsigned long)(_Randseed >> 16) % RAND_MAX); 
.................... } 
....................  
.................... void srand(unsigned int32 seed) 
.................... { 
....................    _Randseed = seed; 
.................... } 
....................  
.................... //--------------------------------------------------------------------------- 
.................... // Searching and sorting utilities implementation 
.................... //--------------------------------------------------------------------------- 
....................  
.................... typedef signed int (*_Cmpfun)(char * p1,char * p2); 
....................  
.................... void qsort(char * qdata, int qitems, int qsize, _Cmpfun cmp) { 
....................    int m,j,i,l; 
....................    short done; 
....................    BYTE t[16]; 
....................  
....................    m = qitems/2; 
....................    while( m > 0 ) { 
....................      for(j=0; j<(qitems-m); ++j) { 
....................         i = j; 
....................         do 
....................         { 
....................            done=TRUE; 
....................            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 = FALSE; 
....................            } 
....................         } 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 <math.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.                                //// 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... ////                                                                    //// 
.................... //// 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.141592654 
....................  
....................  
.................... #define SQRT2  1.41421356 
....................  
.................... //float const ps[4] = {5.9304945, 21.125224, 8.9403076, 0.29730279}; 
.................... //float const qs[4] = {1.0000000, 15.035723, 17.764134, 2.4934718}; 
....................  
.................... ///////////////////////////// Round Functions ////////////////////////////// 
....................  
.................... float CEIL_FLOOR(float x, int n) 
.................... { 
....................    float y, res; 
....................    long l; 
....................    int1 s; 
....................  
....................    s = 0; 
....................    y = x; 
....................  
....................    if (x < 0) 
....................    { 
....................       s = 1; 
....................       y = -y; 
....................    } 
....................  
....................    if (y <= 32768.0) 
....................   res = (float)(long)y; 
....................  
....................  else if (y < 10000000.0) 
....................    { 
....................   l = (long)(y/32768.0); 
....................       y = 32768.0*(y/32768.0 - (float)l); 
....................   res = 32768.0*(float)l; 
....................   res += (float)(long)y; 
....................  } 
....................  
....................  else 
....................   res = y; 
....................  
....................  y = y - (float)(long)y; 
....................  
....................  if (s) 
....................   res = -res; 
....................  
....................  if (y != 0) 
....................  { 
....................   if (s == 1 && n == 0) 
....................    res -= 1.0; 
....................  
....................   if (s == 0 && n == 1) 
....................    res += 1.0; 
....................  } 
....................  if (x == 0) 
....................     res = 0; 
....................  
....................  return (res); 
.................... } 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float floor(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : rounds down the number x. 
.................... // Date : N/A 
.................... // 
.................... float floor(float x) 
.................... { 
....................    return CEIL_FLOOR(x, 0); 
.................... } 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float ceil(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : rounds up the number x. 
.................... // Date : N/A 
.................... // 
.................... float ceil(float x) 
.................... { 
....................    return CEIL_FLOOR(x, 1); 
.................... } 
....................  
....................  //////////////////////////////////////////////////////////////////////////// 
.................... //   float fabs(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : Computes the absolute value of floating point number x 
.................... // Returns : returns the absolute value of x 
.................... // Date : N/A 
.................... // 
.................... #define fabs abs 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float fmod(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : Computes the floating point remainder of x/y 
.................... // Returns : returns the value of x= i*y, for some integer i such that, if y 
.................... // is non zero, the result has the same isgn of x na dmagnitude less than the 
.................... // magnitude of y. If y is zero then a domain error occurs. 
.................... // Date : N/A 
.................... // 
....................  
.................... float fmod(float x,float y) 
.................... { 
....................    float i; 
....................    if (y!=0.0) 
....................    { 
....................       i=(x/y < 0.0)? ceil(x/y): floor(x/y); 
....................       return(x-(i*y)); 
....................    } 
....................    else 
....................    { 
....................    #ifdef _ERRNO 
....................    { 
....................       errno=EDOM; 
....................    } 
....................    #endif 
....................    } 
.................... } 
....................  
.................... //////////////////// Exponential and logarithmic functions //////////////////// 
....................  
.................... #define LN2 0.6931471806 
....................  
.................... float const pe[6] = {0.000207455774, 0.00127100575, 0.00965065093, 
....................                      0.0554965651,  0.240227138,  0.693147172}; 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float exp(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : returns the value (e^x) 
.................... // Date : N/A 
.................... // 
.................... float exp(float x) 
.................... { 
....................    float y, res, r; 
....................    signed int n; 
....................    int1 s; 
....................    #ifdef _ERRNO 
....................    if(x > 88.722838) 
....................    { 
....................       errno=ERANGE; 
....................       return(0); 
....................    } 
....................    #endif 
....................    n = (signed long)(x/LN2); 
....................    s = 0; 
....................    y = x; 
....................  
....................    if (x < 0) 
....................    { 
....................       s = 1; 
....................       n = -n; 
....................       y = -y; 
....................    } 
....................  
....................    res = 0.0; 
....................    *((int8 *)(&res)) = n + 0x7F; 
....................  
....................    y = y/LN2 - (float)n; 
....................  
....................    r = pe[0]*y + pe[1]; 
....................    r = r*y + pe[2]; 
....................    r = r*y + pe[3]; 
....................    r = r*y + pe[4]; 
....................    r = r*y + pe[5]; 
....................  
....................    res = res*(1.0 + y*r); 
....................  
....................    if (s) 
....................       res = 1.0/res; 
....................    return(res); 
.................... } 
....................  
.................... /************************************************************/ 
....................  
.................... float const pl[4] = {0.45145214, -9.0558803, 26.940971, -19.860189}; 
.................... float const ql[4] = {1.0000000,  -8.1354259, 16.780517, -9.9300943}; 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float log(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : returns the the natural log of x 
.................... // Date : N/A 
.................... // 
.................... float log(float x) 
.................... { 
....................    float y, res, r, y2; 
....................  
....................    signed n; 
....................    #ifdef _ERRNO 
....................    if(x <0) 
....................    { 
....................       errno=EDOM; 
....................    } 
....................    if(x ==0) 
....................    { 
....................       errno=ERANGE; 
....................       return(0); 
....................    } 
....................    #endif 
....................    y = x; 
....................  
....................    if (y != 1.0) 
....................    { 
....................      *((int8 *)(&y)) = 0x7E;  
....................  
....................       y = (y - 1.0)/(y + 1.0); 
....................  
....................       y2=y*y; 
....................  
....................       res = pl[0]*y2 + pl[1]; 
....................       res = res*y2 + pl[2]; 
....................       res = res*y2 + pl[3]; 
....................  
....................       r = ql[0]*y2 + ql[1]; 
....................       r = r*y2 + ql[2]; 
....................       r = r*y2 + ql[3]; 
....................  
....................       res = y*res/r; 
....................  
....................       n = *((int8 *)(&x)) - 0x7E; 
....................  
....................       if (n<0) 
....................          r = -(float)-n; 
....................       else 
....................          r = (float)n; 
....................  
....................       res += r*LN2; 
....................    } 
....................  
....................    else 
....................       res = 0.0; 
....................  
....................    return(res); 
.................... } 
....................  
.................... #define LN10 2.30258509 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float log10(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : returns the the log base 10 of x 
.................... // Date : N/A 
.................... // 
.................... float log10(float x) 
.................... { 
....................    float r; 
....................  
....................    r = log(x); 
....................    r = r/LN10; 
....................    return(r); 
.................... } 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float modf(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description :breaks the argument value int integral and fractional parts, 
.................... // ach of which have the same sign as the argument.  It stores the integral part 
.................... // as a float in the object pointed to by the iptr 
.................... // Returns : returns the signed fractional part of value. 
.................... // Date : N/A 
.................... // 
....................  
.................... float modf(float value,float *iptr) 
.................... { 
....................    *iptr=(value < 0.0)? ceil(value): floor(value); 
....................    return(value - *iptr); 
.................... } 
....................  
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float pwr(float x,float y) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : returns the value (x^y) 
.................... // Date : N/A 
.................... // 
.................... float pwr(float x,float y) 
.................... { 
....................    if(x>=0) 
....................      return(  exp(y*log(x)) ); 
....................    else 
....................      return(  -exp(y*log(-x)) ); 
.................... } 
....................  
....................  
.................... //////////////////// Power functions //////////////////// 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float pow(float x,float y) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : returns the value (x^y) 
.................... // Date : N/A 
.................... // 
.................... float pow(float x,float y) 
.................... { 
....................    if(x>=0) 
....................      return(  exp(y*log(x)) ); 
....................    else 
....................      return(  -exp(y*log(-x)) ); 
.................... } 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float sqrt(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : returns the square root of x 
.................... // Date : N/A 
.................... // 
.................... float sqrt(float x) 
.................... { 
....................    float y, res; 
....................    BYTE *p; 
....................  
....................    #ifdef _ERRNO 
....................    if(x < 0) 
....................    { 
....................       errno=EDOM; 
....................    } 
....................    #endif 
....................  
....................    if( x<=0.0) 
....................       return(0.0); 
....................  
....................    y=x; 
....................    p=&y; 
....................    (*p)=(BYTE)((((int16)(*p)) + 127) >> 1); 
....................  
....................    do { 
....................       res=y; 
....................       y+=(x/y); 
....................       (*p)--; 
....................    } while(res != y); 
....................  
....................    return(res); 
.................... } 
....................  
....................  
....................  
.................... ////////////////////////////// Trig Functions ////////////////////////////// 
.................... #ifdef PI_DIV_BY_TWO 
.................... #undef PI_DIV_BY_TWO 
.................... #endif 
.................... #define PI_DIV_BY_TWO   1.570796326794896 
.................... #ifdef TWOBYPI 
.................... #undef TWOBYPI 
.................... #define TWOBYPI          0.6366197724 
.................... #endif 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float cos(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : returns the cosine value of the angle x, which is in radian 
.................... // Date : 9/20/2001 
.................... // 
.................... float cos(float x) 
.................... { 
....................    float y, t, t2 = 1.0; 
....................    int quad, i; 
....................    float frac; 
....................    float p[4] = { 
....................       -0.499999993585, 
....................        0.041666636258, 
....................       -0.0013888361399, 
....................        0.00002476016134 
....................    }; 
....................  
....................    if (x < 0) x = -x;                  // absolute value of input 
....................  
....................    quad = (int)(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 <= 3; i++) 
....................    { 
....................       t2 = t2 * t; 
....................       y = y + p[i] * t2; 
....................    } 
....................  
....................    if (quad == 2 || quad == 1) 
....................       y = -y;  // correct sign 
....................  
....................    return (y); 
.................... } 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float sin(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : returns the sine value of the angle x, which is in radian 
.................... // Date : 9/20/2001 
.................... // 
.................... float sin(float x) 
.................... { 
....................    return cos(x - PI_DIV_BY_TWO); 
.................... } 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float tan(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : returns the tangent value of the angle x, which is in radian 
.................... // Date : 9/20/2001 
.................... // 
.................... float tan(float x) 
.................... { 
....................    float c, s; 
....................  
....................    c = cos(x); 
....................    if (c == 0.0) 
....................       return (1.0e+36); 
....................  
....................    s = sin(x); 
....................    return(s/c); 
.................... } 
....................  
....................  
....................  
.................... float const pas[3] = {0.49559947, -4.6145309, 5.6036290}; 
.................... float const qas[3] = {1.0000000,  -5.5484666, 5.6036290}; 
....................  
.................... float ASIN_COS(float x, int n) 
.................... { 
....................    float 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); 
.................... } 
....................  
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float asin(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : returns the arcsine value of the value x. 
.................... // Date : N/A 
.................... // 
.................... float asin(float x) 
.................... { 
....................    float r; 
....................  
....................    r = ASIN_COS(x, 0); 
....................    return(r); 
.................... } 
....................  
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float acos(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : returns the arccosine value of the value x. 
.................... // Date : N/A 
.................... // 
.................... float acos(float x) 
.................... { 
....................    float r; 
....................  
....................    r = ASIN_COS(x, 1); 
....................    return(r); 
.................... } 
....................  
.................... float const pat[4] = {0.17630401, 5.6710795, 22.376096, 19.818457}; 
.................... float 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 
.................... // 
.................... float atan(float x) 
.................... { 
....................    float 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); 
.................... } 
....................  
.................... ///////////////////////////////////////////////////////////////////////////// 
.................... //   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 
.................... // 
....................  
....................  
.................... float atan2(float y,float x) 
.................... { 
....................    float z; 
....................    int1 sign; 
....................    int 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; 
....................          } 
....................       } 
....................    } 
.................... } 
....................  
.................... //////////////////// 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 
.................... // 
....................  
.................... float cosh(float x) 
.................... { 
....................    return ((exp(x)+exp(-x))/2); 
.................... } 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float sinh(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : Computes the hyperbolic sine value of x 
.................... // Returns : returns the hyperbolic sine value of x 
.................... // Date : N/A 
.................... // 
....................  
.................... float sinh(float x) 
.................... { 
....................  
....................    return ((exp(x) - exp(-x))/2); 
.................... } 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   float tanh(float x) 
.................... //////////////////////////////////////////////////////////////////////////// 
.................... // Description : Computes the hyperbolic tangent value of x 
.................... // Returns : returns the hyperbolic tangent value of x 
.................... // Date : N/A 
.................... // 
....................  
.................... float tanh(float x) 
.................... { 
....................    return(sinh(x)/cosh(x)); 
.................... } 
....................  
.................... //////////////////////////////////////////////////////////////////////////// 
.................... //   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 
.................... float frexp(float x, signed int *exp) 
.................... { 
....................    float 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; 
.................... } 
....................  
.................... ////////////////////////////////////////////////////////////////////////////// 
.................... //   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 
.................... // 
....................  
.................... float ldexp(float value, signed int exp) 
.................... { 
....................    return (value * pow(2,exp)); 
.................... } 
.................... #endif 
....................  
....................   #include <string.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 _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; 
....................   } 
....................  
.................... /* compiler ignored the name 'strcpy()'; perhaps, it's reserved? 
....................    Standard template: char *strcpy(char *s1, const char *s2) 
....................    copies the string s2 including the null character to s1*/ 
....................  
.................... char *strcopy(char *s1, char *s2) 
.................... { 
....................   char *s; 
....................  
....................   for (s = s1; *s2 != 0; s++, s2++) { 
....................      *s = *s2; 
....................   } 
....................   *s = *s2; 
....................   return(s1); 
.................... } 
....................  
.................... /* 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 int 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 int 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 int 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 int 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; 
....................   int 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,int 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, int 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*/ 
....................  
.................... int *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, int 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 */ 
....................  
.................... int *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(int 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) */ 
....................  
.................... int *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 int 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 
....................  
....................   #include "gps.c" 
.................... //This defines the pins and properties of the GPS Serial Stream 
.................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=GPSSTREAM,ERRORS) 
*
0110:  BTFSS  F9E.5
0112:  BRA    0110
0114:  MOVFF  FAB,1F
0118:  MOVFF  FAE,01
011C:  BTFSS  1F.1
011E:  BRA    0124
0120:  BCF    FAB.4
0122:  BSF    FAB.4
0124:  GOTO   0218 (RETURN)
.................... //----GLOBAL VARIABLES---- 
.................... char GPSbuffer[83]=""; //this is where the incoming string will be stored 
.................... int8 BuffIndex = 0; //this is the index of the char array 
....................  
.................... //Test NMEA String to use for debugging 
.................... //char gps_test[83] = "$GPRMC,184547,A,3648.1513,N,12147.2863,W,000.0,239.9,050707,014.8,E*67";  
....................  
.................... //GPRMC string used for calculations 
.................... char GPRMC[83] = ""; 
....................  
.................... //-----FLAGS------- 
.................... int1 noUpdate = 0;   //this is raised when the GPRMC string is being utilized 
.................... int1 needUpdate = 0; //raise this flag if GPSbuffer needs to be written to GPRMC after noUpdate flag is lowered 
.................... int1 GPSRecieving = FALSE; //this is true if we're accepting characters 
....................  
.................... /** 
....................   * This struct is nested in the GPS struct 
....................   * It contains all the GPS parameters 
.................... **/ 
.................... struct gps_data 
.................... { 
....................    char  time[7];    //the UTC time in HHMMSS 
....................    char  status;     //Status of Reciever, A=valid V=warning 
....................    float lat;        //Lattitude in Degrees ie:36.80252166666 degrees  
....................    char  latHem;     //Lattitude Hemisphere N or S  
....................    float lon;        //Longitude in Degrees, ie: 121.788105 degrees 
....................    char  lonHem;     //Longitude Hemisphere E or W 
....................    float sog;       //speed over ground (SOG) in Knots 
....................    float course;     //Course over ground 000.0 to 359.9 degrees true  
....................    char  date[7];    //UTC date in ddmmyy 
....................    float magVar;     //Magnetic variation in degrees 000.0 to 180.000 
....................    char  magVarDir;  //Magnetic Variation Direction E or W 
....................  
.................... }; 
....................  
.................... /** 
....................   *   This struct contains all the data for the current and last state 
....................   *   access properties of this by GPS.now.course 
.................... **/ 
.................... struct gps 
.................... { 
....................    struct gps_data now;    //current state of the system 
....................    struct gps_data last;   //The last state of the system 
.................... } GPS; 
....................  
.................... /** 
....................  * 
....................  * input: NMEA $GPRMC STRING POINTER- NULL TERMINATED 
....................  * This function takes in a GRPMC STRING and parses it 
....................  * Written by Todd Berk, toddberk@gmail.com 2007 
.................... **/ 
.................... void parse_gps() 
.................... { 
....................    //Define Local Variables 
....................    char separators[3] = ",";  //separators in GPRMC string 
*
0C54:  MOVLW  2C
0C56:  MOVLB  1
0C58:  MOVWF  x14
0C5A:  CLRF   x15
0C5C:  CLRF   x16
....................    char parts[12][13];        //The parts of the GPRMC string, ie 
....................    char *part;                //Pointer Used while splitting string 
....................    int i=0;                   //counter used in loops 
0C5E:  CLRF   xB5
....................    char degrees[4]="";           //used for converting ddmm.mmmm to degrees 
0C60:  CLRF   xB6
0C62:  CLRF   xB7
0C64:  CLRF   xB8
0C66:  CLRF   xB9
....................    char minutes[10]="";           //used for converting ddmm.mmmm to degrees 
0C68:  CLRF   xBA
0C6A:  CLRF   xBB
0C6C:  CLRF   xBC
0C6E:  CLRF   xBD
0C70:  CLRF   xBE
0C72:  CLRF   xBF
0C74:  CLRF   xC0
0C76:  CLRF   xC1
0C78:  CLRF   xC2
0C7A:  CLRF   xC3
.................... //char teststr[13]="";//USED SOLELY FOR DEBUGGING STRINGS 
.................... //float testf = 0;//USED FOR DEBUGGING FLOATS 
....................    //copy GPS.now to GPS.last before we change GPS.now 
....................    GPS.last = GPS.now; 
0C7C:  CLRF   FEA
0C7E:  MOVLW  EE
0C80:  MOVWF  FE9
0C82:  CLRF   FE2
0C84:  MOVLW  C8
0C86:  MOVWF  FE1
0C88:  MOVLW  26
0C8A:  MOVWF  01
0C8C:  MOVFF  FE6,FEE
0C90:  DECFSZ 01,F
0C92:  BRA    0C8C
....................    //First Split string into array of string parameters 
....................       //raise noUpdate flag here 
....................       noUpdate = 1; 
0C94:  MOVLB  0
0C96:  BSF    xC7.0
....................       //this first call ensures the string contains separators  
....................       part = strtok(GPRMC,separators); 
0C98:  MOVLB  1
0C9A:  CLRF   xC5
0C9C:  MOVLW  74
0C9E:  MOVWF  xC4
0CA0:  MOVLW  01
0CA2:  MOVWF  xC7
0CA4:  MOVLW  14
0CA6:  MOVWF  xC6
0CA8:  MOVLB  0
0CAA:  CALL   03BC
0CAE:  MOVFF  02,1B4
0CB2:  MOVFF  01,1B3
....................       while(part!=0) 
....................       { 
0CB6:  MOVLB  1
0CB8:  MOVF   xB3,F
0CBA:  BNZ   0CC0
0CBC:  MOVF   xB4,F
0CBE:  BZ    0D10
....................          strcpy(parts[i], part);//*REPLACE THIS WILL CALL TO GPSAPPEND(part,i) function 
0CC0:  MOVF   xB5,W
0CC2:  MULLW  0D
0CC4:  MOVF   FF3,W
0CC6:  CLRF   03
0CC8:  ADDLW  17
0CCA:  MOVWF  01
0CCC:  MOVLW  01
0CCE:  ADDWFC 03,F
0CD0:  MOVFF  01,1C4
0CD4:  MOVFF  03,1C5
0CD8:  MOVFF  03,FEA
0CDC:  MOVFF  01,FE9
0CE0:  MOVFF  1B4,FE2
0CE4:  MOVFF  1B3,FE1
0CE8:  MOVF   FE7,F
0CEA:  MOVFF  FE6,FEE
0CEE:  BNZ   0CE8
....................          part = strtok(0,separators); 
0CF0:  CLRF   xC5
0CF2:  CLRF   xC4
0CF4:  MOVLW  01
0CF6:  MOVWF  xC7
0CF8:  MOVLW  14
0CFA:  MOVWF  xC6
0CFC:  MOVLB  0
0CFE:  CALL   03BC
0D02:  MOVFF  02,1B4
0D06:  MOVFF  01,1B3
....................          i++; 
0D0A:  MOVLB  1
0D0C:  INCF   xB5,F
....................       } 
0D0E:  BRA    0CB8
....................       //lower noUPdate flag 
....................       noUpdate = 0; 
0D10:  MOVLB  0
0D12:  BCF    xC7.0
....................       //perform update if flag is raised 
....................       if(needUpdate && !GPSRecieving) 
0D14:  BTFSS  xC7.1
0D16:  BRA    0D32
0D18:  BTFSC  xC7.2
0D1A:  BRA    0D32
....................       { 
....................          //copy buffer to string 
....................          strcpy(GPRMC,GPSbuffer); 
0D1C:  CLRF   FEA
0D1E:  MOVLW  74
0D20:  MOVWF  FE9
0D22:  CLRF   FE2
0D24:  MOVLW  20
0D26:  MOVWF  FE1
0D28:  MOVF   FE7,F
0D2A:  MOVFF  FE6,FEE
0D2E:  BNZ   0D28
....................          //lower needupdate flag 
....................          needUpdate = 0; 
0D30:  BCF    xC7.1
....................       } 
....................  
.................... //*BELOW HERE SHOULD BE SPLIT INTO A NEW FUNCTION AND CALLED  
....................    //FROM while(part!=0) TO REDUCE MEMORY FROM 12x13 ARRAY 
....................     
....................    //Append new parameters to GPS.now 
....................       //time 
....................       strcpy(GPS.now.time,parts[1]); 
0D32:  CLRF   FEA
0D34:  MOVLW  C8
0D36:  MOVWF  FE9
0D38:  MOVLW  01
0D3A:  MOVWF  FE2
0D3C:  MOVLW  24
0D3E:  MOVWF  FE1
0D40:  MOVF   FE7,F
0D42:  MOVFF  FE6,FEE
0D46:  BNZ   0D40
....................       //status 
....................       GPS.now.status = parts[2][0]; 
0D48:  MOVFF  131,CF
....................       //lattitude 
....................          //We need to convert from ddmm.mmmm to degrees 
....................          //point to lat 
....................          part=&parts[3][0]; 
0D4C:  MOVLW  01
0D4E:  MOVLB  1
0D50:  MOVWF  xB4
0D52:  MOVLW  3E
0D54:  MOVWF  xB3
....................          //copy first two character to degrees 
....................          strncpy(degrees,part,2); 
0D56:  MOVLW  01
0D58:  MOVWF  xC5
0D5A:  MOVLW  B6
0D5C:  MOVWF  xC4
0D5E:  MOVFF  1B4,1C7
0D62:  MOVFF  1B3,1C6
0D66:  MOVLW  02
0D68:  MOVWF  xC8
0D6A:  MOVLB  0
0D6C:  CALL   046C
....................          //increment part twice 
....................          part++;part++; 
0D70:  MOVLB  1
0D72:  INCF   xB3,F
0D74:  BTFSC  FD8.2
0D76:  INCF   xB4,F
0D78:  INCF   xB3,F
0D7A:  BTFSC  FD8.2
0D7C:  INCF   xB4,F
....................          //copy rest of string to minutes 
....................          strcpy(minutes,part); 
0D7E:  MOVLW  01
0D80:  MOVWF  FEA
0D82:  MOVLW  BA
0D84:  MOVWF  FE9
0D86:  MOVFF  1B4,FE2
0D8A:  MOVFF  1B3,FE1
0D8E:  MOVF   FE7,F
0D90:  MOVFF  FE6,FEE
0D94:  BNZ   0D8E
....................          //convert and set lattitude in degrees 
....................          GPS.now.lat = atof(degrees)+(atof(minutes)/60); 
0D96:  MOVLW  01
0D98:  MOVWF  xC9
0D9A:  MOVLW  B6
0D9C:  MOVWF  xC8
0D9E:  MOVLB  0
0DA0:  RCALL  09EC
0DA2:  MOVFF  00,1C4
0DA6:  MOVFF  01,1C5
0DAA:  MOVFF  02,1C6
0DAE:  MOVFF  03,1C7
0DB2:  MOVLW  01
0DB4:  MOVLB  1
0DB6:  MOVWF  xC9
0DB8:  MOVLW  BA
0DBA:  MOVWF  xC8
0DBC:  MOVLB  0
0DBE:  RCALL  09EC
0DC0:  MOVFF  00,1C8
0DC4:  MOVFF  01,1C9
0DC8:  MOVFF  02,1CA
0DCC:  MOVFF  03,1CB
0DD0:  MOVFF  03,1D9
0DD4:  MOVFF  02,1D8
0DD8:  MOVFF  01,1D7
0DDC:  MOVFF  00,1D6
0DE0:  MOVLB  1
0DE2:  CLRF   xDD
0DE4:  CLRF   xDC
0DE6:  MOVLW  70
0DE8:  MOVWF  xDB
0DEA:  MOVLW  84
0DEC:  MOVWF  xDA
0DEE:  MOVLB  0
0DF0:  RCALL  088E
0DF2:  MOVFF  FEA,1CD
0DF6:  MOVFF  FE9,1CC
0DFA:  BCF    FD8.1
0DFC:  MOVFF  1C7,1E0
0E00:  MOVFF  1C6,1DF
0E04:  MOVFF  1C5,1DE
0E08:  MOVFF  1C4,1DD
0E0C:  MOVFF  03,1E4
0E10:  MOVFF  02,1E3
0E14:  MOVFF  01,1E2
0E18:  MOVFF  00,1E1
0E1C:  CALL   0616
0E20:  MOVFF  1CD,FEA
0E24:  MOVFF  1CC,FE9
0E28:  MOVFF  03,D3
0E2C:  MOVFF  02,D2
0E30:  MOVFF  01,D1
0E34:  MOVFF  00,D0
....................       //lattitude hemisphere 
....................       GPS.now.latHem = parts[4][0]; 
0E38:  MOVFF  14B,D4
....................       //Longitude  
....................          //We need to convert from ddmm.mmmm to degrees 
....................          //point to lng 
....................          part=&parts[5][0]; 
0E3C:  MOVLW  01
0E3E:  MOVLB  1
0E40:  MOVWF  xB4
0E42:  MOVLW  58
0E44:  MOVWF  xB3
....................          //copy first three characters to degrees 
....................          strncpy(degrees,part,3); 
0E46:  MOVLW  01
0E48:  MOVWF  xC5
0E4A:  MOVLW  B6
0E4C:  MOVWF  xC4
0E4E:  MOVFF  1B4,1C7
0E52:  MOVFF  1B3,1C6
0E56:  MOVLW  03
0E58:  MOVWF  xC8
0E5A:  MOVLB  0
0E5C:  CALL   046C
....................          //increment part thrice 
....................          part++;part++;part++; 
0E60:  MOVLB  1
0E62:  INCF   xB3,F
0E64:  BTFSC  FD8.2
0E66:  INCF   xB4,F
0E68:  INCF   xB3,F
0E6A:  BTFSC  FD8.2
0E6C:  INCF   xB4,F
0E6E:  INCF   xB3,F
0E70:  BTFSC  FD8.2
0E72:  INCF   xB4,F
....................          //copy rest of string to minutes 
....................          strcpy(minutes,part); 
0E74:  MOVLW  01
0E76:  MOVWF  FEA
0E78:  MOVLW  BA
0E7A:  MOVWF  FE9
0E7C:  MOVFF  1B4,FE2
0E80:  MOVFF  1B3,FE1
0E84:  MOVF   FE7,F
0E86:  MOVFF  FE6,FEE
0E8A:  BNZ   0E84
....................          //convert and set longitude in degrees 
....................          GPS.now.lon = atof(degrees)+atof(minutes)/60; 
0E8C:  MOVLW  01
0E8E:  MOVWF  xC9
0E90:  MOVLW  B6
0E92:  MOVWF  xC8
0E94:  MOVLB  0
0E96:  RCALL  09EC
0E98:  MOVFF  00,1C4
0E9C:  MOVFF  01,1C5
0EA0:  MOVFF  02,1C6
0EA4:  MOVFF  03,1C7
0EA8:  MOVLW  01
0EAA:  MOVLB  1
0EAC:  MOVWF  xC9
0EAE:  MOVLW  BA
0EB0:  MOVWF  xC8
0EB2:  MOVLB  0
0EB4:  RCALL  09EC
0EB6:  MOVFF  00,1C8
0EBA:  MOVFF  01,1C9
0EBE:  MOVFF  02,1CA
0EC2:  MOVFF  03,1CB
0EC6:  MOVFF  03,1D9
0ECA:  MOVFF  02,1D8
0ECE:  MOVFF  01,1D7
0ED2:  MOVFF  00,1D6
0ED6:  MOVLB  1
0ED8:  CLRF   xDD
0EDA:  CLRF   xDC
0EDC:  MOVLW  70
0EDE:  MOVWF  xDB
0EE0:  MOVLW  84
0EE2:  MOVWF  xDA
0EE4:  MOVLB  0
0EE6:  RCALL  088E
0EE8:  MOVFF  FEA,1CD
0EEC:  MOVFF  FE9,1CC
0EF0:  BCF    FD8.1
0EF2:  MOVFF  1C7,1E0
0EF6:  MOVFF  1C6,1DF
0EFA:  MOVFF  1C5,1DE
0EFE:  MOVFF  1C4,1DD
0F02:  MOVFF  03,1E4
0F06:  MOVFF  02,1E3
0F0A:  MOVFF  01,1E2
0F0E:  MOVFF  00,1E1
0F12:  CALL   0616
0F16:  MOVFF  1CD,FEA
0F1A:  MOVFF  1CC,FE9
0F1E:  MOVFF  03,D8
0F22:  MOVFF  02,D7
0F26:  MOVFF  01,D6
0F2A:  MOVFF  00,D5
....................       //longitude hemisphere 
....................       GPS.now.lonHem = parts[6][0]; 
0F2E:  MOVFF  165,D9
....................       //velocity 
....................       GPS.now.sog = atof(parts[7]); 
0F32:  MOVLW  01
0F34:  MOVLB  1
0F36:  MOVWF  xC9
0F38:  MOVLW  72
0F3A:  MOVWF  xC8
0F3C:  MOVLB  0
0F3E:  RCALL  09EC
0F40:  MOVFF  03,DD
0F44:  MOVFF  02,DC
0F48:  MOVFF  01,DB
0F4C:  MOVFF  00,DA
....................       //course 
....................       GPS.now.course = atof(parts[8]); 
0F50:  MOVLW  01
0F52:  MOVLB  1
0F54:  MOVWF  xC9
0F56:  MOVLW  7F
0F58:  MOVWF  xC8
0F5A:  MOVLB  0
0F5C:  RCALL  09EC
0F5E:  MOVFF  03,E1
0F62:  MOVFF  02,E0
0F66:  MOVFF  01,DF
0F6A:  MOVFF  00,DE
....................       //date 
....................       strcpy(GPS.now.date,parts[9]); 
0F6E:  CLRF   FEA
0F70:  MOVLW  E2
0F72:  MOVWF  FE9
0F74:  MOVLW  01
0F76:  MOVWF  FE2
0F78:  MOVLW  8C
0F7A:  MOVWF  FE1
0F7C:  MOVF   FE7,F
0F7E:  MOVFF  FE6,FEE
0F82:  BNZ   0F7C
....................       //magnetic variation 
....................       GPS.now.magVar = atof(parts[10]); 
0F84:  MOVLW  01
0F86:  MOVLB  1
0F88:  MOVWF  xC9
0F8A:  MOVLW  99
0F8C:  MOVWF  xC8
0F8E:  MOVLB  0
0F90:  RCALL  09EC
0F92:  MOVFF  03,EC
0F96:  MOVFF  02,EB
0F9A:  MOVFF  01,EA
0F9E:  MOVFF  00,E9
....................       //magnetic variation direction 
....................       GPS.now.magVarDir = parts[11][0]; 
0FA2:  MOVFF  1A6,ED
....................  
.................... } 
0FA6:  GOTO   140A (RETURN)
....................  
....................   #include "interrupts.c" 
.................... /** 
....................   *THIS IS A SERIAL INTERRUPT 
....................   *IT OCCURS WHEN THE GPS IS OUTPUTTING A STRING 
....................   *it inputs the entire string 
.................... **/ 
.................... /**COMMENT OUT 
.................... #int_rda 
.................... void rda_isr(void) 
.................... { 
....................    //ch is the incoming character 
....................    char ch; 
....................    //get incoming character from GPS Stream 
....................    ch = fgetc(GPSSTREAM); 
....................    if(ch == '$')        //$ Marks beginning of a packet 
....................    { 
....................    fgets(GPSbuffer,GPSSTREAM); 
....................          //check if GPRMC string is in use 
....................          if(noUpdate) 
....................          { 
....................             //we'll let the function update the string 
....................             needUpdate = 1; 
....................          } else { 
....................             //put string into GPRMC 
....................             strcpy(GPRMC,GPSbuffer); 
....................          } 
....................    } 
....................  
.................... } 
.................... **/ //END COMMENT OUT 
.................... /** 
....................   *THIS IS A SERIAL INTERRUPT 
....................   *IT OCCURS WHEN THE GPS IS OUTPUTTING A STRING 
....................   *it inputs individual characters 
.................... **/ 
....................  
.................... #int_rda 
.................... void rda_isr(void) 
.................... { 
....................    //ch is the incoming character 
....................    char ch; 
....................    //get incoming character from GPS Stream 
....................    ch = fgetc(GPSSTREAM); 
*
0216:  BRA    0110
0218:  MOVFF  01,1ED
....................    if(ch == '$')        //$ Marks beginning of a packet  
021C:  MOVLB  1
021E:  MOVF   xED,W
0220:  SUBLW  24
0222:  BNZ   022A
....................    { 
....................       //start accepting packets 
....................       GPSRecieving = TRUE; 
0224:  MOVLB  0
0226:  BSF    xC7.2
....................       BuffIndex = 0;      // Reset buffer index 
0228:  CLRF   73
....................    } 
....................    //accept packets if we are recieving 
....................    if(GPSRecieving) 
022A:  MOVLB  0
022C:  BTFSS  xC7.2
022E:  BRA    02A8
....................    { 
....................       if(ch==13 || ch==10)    //Got a CR\r\n end of packet 
0230:  MOVLB  1
0232:  MOVF   xED,W
0234:  SUBLW  0D
0236:  BZ    023E
0238:  MOVF   xED,W
023A:  SUBLW  0A
023C:  BNZ   0262
....................       { 
....................          //stop recieving 
....................          GPSRecieving = FALSE; 
023E:  MOVLB  0
0240:  BCF    xC7.2
....................          //check if GPRMC string is in use 
....................          if(noUpdate) 
0242:  BTFSS  xC7.0
0244:  BRA    024A
....................          { 
....................             //we'll let the function update the string 
....................             needUpdate = 1; 
0246:  BSF    xC7.1
....................          } else { 
0248:  BRA    025E
....................             //put string into GPRMC 
....................             strcpy(GPRMC,GPSbuffer); 
024A:  CLRF   FEA
024C:  MOVLW  74
024E:  MOVWF  FE9
0250:  CLRF   FE2
0252:  MOVLW  20
0254:  MOVWF  FE1
0256:  MOVF   FE7,F
0258:  MOVFF  FE6,FEE
025C:  BNZ   0256
....................          } 
....................       } else { 
025E:  BRA    0278
0260:  MOVLB  1
....................        
....................       GPSbuffer[BuffIndex] = ch;   // Add char to buffer 
0262:  CLRF   03
0264:  MOVF   73,W
0266:  ADDLW  20
0268:  MOVWF  FE9
026A:  MOVLW  00
026C:  ADDWFC 03,W
026E:  MOVWF  FEA
0270:  MOVFF  1ED,FEF
....................       BuffIndex++;                   // Advance buffer pointer      
0274:  INCF   73,F
0276:  MOVLB  0
....................        
....................       } 
....................  
....................       if(BuffIndex > 82) //If buffer is full, this is an error 
0278:  MOVF   73,W
027A:  SUBLW  52
027C:  BC    02A8
....................       { 
....................          //*HANDLE BUFFER OVERRUN ERROR 
....................          fprintf(BASESTREAM,"!ERROR:BUFFER-OVERRUN%u",BuffIndex); 
027E:  MOVLB  1
0280:  CLRF   xEE
0282:  MOVF   xEE,W
0284:  MOVLB  0
0286:  RCALL  009E
0288:  MOVLB  1
028A:  INCF   xEE,F
028C:  MOVWF  00
028E:  MOVWF  xF1
0290:  MOVLB  0
0292:  RCALL  0128
0294:  MOVLW  15
0296:  MOVLB  1
0298:  SUBWF  xEE,W
029A:  BNZ   0282
029C:  MOVFF  73,1EF
02A0:  MOVLW  1B
02A2:  MOVWF  xF0
02A4:  MOVLB  0
02A6:  BRA    0198
....................       } 
....................    }  
.................... } 
....................  
....................  
....................  
....................  
....................  
....................  
02A8:  BCF    F9E.5
02AA:  GOTO   0058
.................... void main() 
.................... { 
*
127C:  CLRF   FF8
127E:  BCF    FD0.7
1280:  BSF    0D.7
1282:  CLRF   FEA
1284:  CLRF   FE9
1286:  BCF    F94.1
1288:  BSF    F8B.1
128A:  BSF    FB8.3
128C:  MOVLW  08
128E:  MOVWF  FAF
1290:  MOVLW  02
1292:  MOVWF  FB0
1294:  MOVLW  A6
1296:  MOVWF  FAC
1298:  MOVLW  90
129A:  MOVWF  FAB
129C:  MOVF   FC1,W
129E:  ANDLW  C0
12A0:  IORLW  0F
12A2:  MOVWF  FC1
12A4:  MOVLW  07
12A6:  MOVWF  FB4
12A8:  CLRF   19
12AA:  CLRF   1A
12AC:  CLRF   1F
12AE:  CLRF   20
12B0:  CLRF   21
12B2:  CLRF   22
12B4:  CLRF   23
12B6:  CLRF   24
12B8:  CLRF   25
12BA:  CLRF   26
12BC:  CLRF   27
12BE:  CLRF   28
12C0:  CLRF   29
12C2:  CLRF   2A
12C4:  CLRF   2B
12C6:  CLRF   2C
12C8:  CLRF   2D
12CA:  CLRF   2E
12CC:  CLRF   2F
12CE:  CLRF   30
12D0:  CLRF   31
12D2:  CLRF   32
12D4:  CLRF   33
12D6:  CLRF   34
12D8:  CLRF   35
12DA:  CLRF   36
12DC:  CLRF   37
12DE:  CLRF   38
12E0:  CLRF   39
12E2:  CLRF   3A
12E4:  CLRF   3B
12E6:  CLRF   3C
12E8:  CLRF   3D
12EA:  CLRF   3E
12EC:  CLRF   3F
12EE:  CLRF   40
12F0:  CLRF   41
12F2:  CLRF   42
12F4:  CLRF   43
12F6:  CLRF   44
12F8:  CLRF   45
12FA:  CLRF   46
12FC:  CLRF   47
12FE:  CLRF   48
1300:  CLRF   49
1302:  CLRF   4A
1304:  CLRF   4B
1306:  CLRF   4C
1308:  CLRF   4D
130A:  CLRF   4E
130C:  CLRF   4F
130E:  CLRF   50
1310:  CLRF   51
1312:  CLRF   52
1314:  CLRF   53
1316:  CLRF   54
1318:  CLRF   55
131A:  CLRF   56
131C:  CLRF   57
131E:  CLRF   58
1320:  CLRF   59
1322:  CLRF   5A
1324:  CLRF   5B
1326:  CLRF   5C
1328:  CLRF   5D
132A:  CLRF   5E
132C:  CLRF   5F
132E:  CLRF   60
1330:  CLRF   61
1332:  CLRF   62
1334:  CLRF   63
1336:  CLRF   64
1338:  CLRF   65
133A:  CLRF   66
133C:  CLRF   67
133E:  CLRF   68
1340:  CLRF   69
1342:  CLRF   6A
1344:  CLRF   6B
1346:  CLRF   6C
1348:  CLRF   6D
134A:  CLRF   6E
134C:  CLRF   6F
134E:  CLRF   70
1350:  CLRF   71
1352:  CLRF   72
1354:  CLRF   73
1356:  CLRF   74
1358:  CLRF   75
135A:  CLRF   76
135C:  CLRF   77
135E:  CLRF   78
1360:  CLRF   79
1362:  CLRF   7A
1364:  CLRF   7B
1366:  CLRF   7C
1368:  CLRF   7D
136A:  CLRF   7E
136C:  CLRF   7F
136E:  CLRF   x80
1370:  CLRF   x81
1372:  CLRF   x82
1374:  CLRF   x83
1376:  CLRF   x84
1378:  CLRF   x85
137A:  CLRF   x86
137C:  CLRF   x87
137E:  CLRF   x88
1380:  CLRF   x89
1382:  CLRF   x8A
1384:  CLRF   x8B
1386:  CLRF   x8C
1388:  CLRF   x8D
138A:  CLRF   x8E
138C:  CLRF   x8F
138E:  CLRF   x90
1390:  CLRF   x91
1392:  CLRF   x92
1394:  CLRF   x93
1396:  CLRF   x94
1398:  CLRF   x95
139A:  CLRF   x96
139C:  CLRF   x97
139E:  CLRF   x98
13A0:  CLRF   x99
13A2:  CLRF   x9A
13A4:  CLRF   x9B
13A6:  CLRF   x9C
13A8:  CLRF   x9D
13AA:  CLRF   x9E
13AC:  CLRF   x9F
13AE:  CLRF   xA0
13B0:  CLRF   xA1
13B2:  CLRF   xA2
13B4:  CLRF   xA3
13B6:  CLRF   xA4
13B8:  CLRF   xA5
13BA:  CLRF   xA6
13BC:  CLRF   xA7
13BE:  CLRF   xA8
13C0:  CLRF   xA9
13C2:  CLRF   xAA
13C4:  CLRF   xAB
13C6:  CLRF   xAC
13C8:  CLRF   xAD
13CA:  CLRF   xAE
13CC:  CLRF   xAF
13CE:  CLRF   xB0
13D0:  CLRF   xB1
13D2:  CLRF   xB2
13D4:  CLRF   xB3
13D6:  CLRF   xB4
13D8:  CLRF   xB5
13DA:  CLRF   xB6
13DC:  CLRF   xB7
13DE:  CLRF   xB8
13E0:  CLRF   xB9
13E2:  CLRF   xBA
13E4:  CLRF   xBB
13E6:  CLRF   xBC
13E8:  CLRF   xBD
13EA:  CLRF   xBE
13EC:  CLRF   xBF
13EE:  CLRF   xC0
13F0:  CLRF   xC1
13F2:  CLRF   xC2
13F4:  CLRF   xC3
13F6:  CLRF   xC4
13F8:  CLRF   xC5
13FA:  CLRF   xC6
13FC:  BCF    xC7.0
13FE:  BCF    xC7.1
1400:  BCF    xC7.2
.................... //enable interrupts 
.................... enable_interrupts(INT_RDA); 
1402:  BSF    F9D.5
.................... enable_interrupts(GLOBAL); 
1404:  MOVLW  C0
1406:  IORWF  FF2,F
....................  
....................    // Main Loop 
....................    WHILE(1) 
....................    { 
....................    parse_gps(); 
1408:  BRA    0C54
....................  
.................... //disable_interrupts(GLOBAL); 
....................    //THIS STRING WILL BE USED FOR REPORTING BACK TO BASE WITH REPORT_TO_BASE(); 
....................    fprintf(BASESTREAM,"!STATUS:%c!TIME:%s!LAT:%1.6f!LON:%1.6f!SOG:%f\r\n",GPS.now.status,GPS.now.time,GPS.now.lat,GPS.now.lon,GPS.now.sog); 
140A:  MOVLB  1
140C:  CLRF   x14
140E:  MOVF   x14,W
1410:  MOVLB  0
1412:  CALL   00C6
1416:  MOVLB  1
1418:  INCF   x14,F
141A:  MOVWF  00
141C:  CLRF   18
141E:  BTFSC  FF2.7
1420:  BSF    18.7
1422:  BCF    FF2.7
1424:  MOVWF  xF1
1426:  MOVLB  0
1428:  CALL   0128
142C:  BTFSC  18.7
142E:  BSF    FF2.7
1430:  MOVLW  08
1432:  MOVLB  1
1434:  SUBWF  x14,W
1436:  BNZ   140E
1438:  CLRF   18
143A:  BTFSC  FF2.7
143C:  BSF    18.7
143E:  BCF    FF2.7
1440:  MOVFF  CF,1F1
1444:  MOVLB  0
1446:  CALL   0128
144A:  BTFSC  18.7
144C:  BSF    FF2.7
144E:  MOVLW  0A
1450:  MOVLB  1
1452:  MOVWF  x15
1454:  MOVF   x15,W
1456:  MOVLB  0
1458:  CALL   00C6
145C:  MOVLB  1
145E:  INCF   x15,F
1460:  MOVWF  00
1462:  CLRF   18
1464:  BTFSC  FF2.7
1466:  BSF    18.7
1468:  BCF    FF2.7
146A:  MOVWF  xF1
146C:  MOVLB  0
146E:  CALL   0128
1472:  BTFSC  18.7
1474:  BSF    FF2.7
1476:  MOVLW  10
1478:  MOVLB  1
147A:  SUBWF  x15,W
147C:  BNZ   1454
147E:  CLRF   FEA
1480:  MOVLW  C8
1482:  MOVWF  FE9
1484:  MOVLW  00
1486:  IORWF  FEF,W
1488:  BZ    14BA
148A:  MOVFF  FEA,117
148E:  MOVFF  FE9,116
1492:  CLRF   18
1494:  BTFSC  FF2.7
1496:  BSF    18.7
1498:  BCF    FF2.7
149A:  MOVFF  FEF,1F1
149E:  MOVLB  0
14A0:  CALL   0128
14A4:  BTFSC  18.7
14A6:  BSF    FF2.7
14A8:  MOVFF  117,FEA
14AC:  MOVFF  116,FE9
14B0:  INCF   FE9,F
14B2:  BTFSC  FD8.2
14B4:  INCF   FEA,F
14B6:  MOVLB  1
14B8:  BRA    1484
14BA:  MOVLW  12
14BC:  MOVWF  x18
14BE:  MOVF   x18,W
14C0:  MOVLB  0
14C2:  CALL   00C6
14C6:  MOVLB  1
14C8:  INCF   x18,F
14CA:  MOVWF  00
14CC:  CLRF   18
14CE:  BTFSC  FF2.7
14D0:  BSF    18.7
14D2:  BCF    FF2.7
14D4:  MOVWF  xF1
14D6:  MOVLB  0
14D8:  CALL   0128
14DC:  BTFSC  18.7
14DE:  BSF    FF2.7
14E0:  MOVLW  17
14E2:  MOVLB  1
14E4:  SUBWF  x18,W
14E6:  BNZ   14BE
14E8:  MOVLW  89
14EA:  MOVWF  FE9
14EC:  MOVFF  D3,11E
14F0:  MOVFF  D2,11D
14F4:  MOVFF  D1,11C
14F8:  MOVFF  D0,11B
14FC:  MOVLW  06
14FE:  MOVWF  x1F
1500:  MOVLB  0
1502:  RCALL  106E
1504:  MOVLW  1C
1506:  MOVLB  1
1508:  MOVWF  x19
150A:  MOVF   x19,W
150C:  MOVLB  0
150E:  CALL   00C6
1512:  MOVLB  1
1514:  INCF   x19,F
1516:  MOVWF  00
1518:  CLRF   18
151A:  BTFSC  FF2.7
151C:  BSF    18.7
151E:  BCF    FF2.7
1520:  MOVWF  xF1
1522:  MOVLB  0
1524:  CALL   0128
1528:  BTFSC  18.7
152A:  BSF    FF2.7
152C:  MOVLW  21
152E:  MOVLB  1
1530:  SUBWF  x19,W
1532:  BNZ   150A
1534:  MOVLW  89
1536:  MOVWF  FE9
1538:  MOVFF  D8,11E
153C:  MOVFF  D7,11D
1540:  MOVFF  D6,11C
1544:  MOVFF  D5,11B
1548:  MOVLW  06
154A:  MOVWF  x1F
154C:  MOVLB  0
154E:  RCALL  106E
1550:  MOVLW  26
1552:  MOVLB  1
1554:  MOVWF  x1A
1556:  MOVF   x1A,W
1558:  MOVLB  0
155A:  CALL   00C6
155E:  MOVLB  1
1560:  INCF   x1A,F
1562:  MOVWF  00
1564:  CLRF   18
1566:  BTFSC  FF2.7
1568:  BSF    18.7
156A:  BCF    FF2.7
156C:  MOVWF  xF1
156E:  MOVLB  0
1570:  CALL   0128
1574:  BTFSC  18.7
1576:  BSF    FF2.7
1578:  MOVLW  2B
157A:  MOVLB  1
157C:  SUBWF  x1A,W
157E:  BNZ   1556
1580:  MOVLW  89
1582:  MOVWF  FE9
1584:  MOVFF  DD,11E
1588:  MOVFF  DC,11D
158C:  MOVFF  DB,11C
1590:  MOVFF  DA,11B
1594:  MOVLW  02
1596:  MOVWF  x1F
1598:  MOVLB  0
159A:  RCALL  106E
159C:  CLRF   18
159E:  BTFSC  FF2.7
15A0:  BSF    18.7
15A2:  BCF    FF2.7
15A4:  MOVLW  0D
15A6:  MOVLB  1
15A8:  MOVWF  xF1
15AA:  MOVLB  0
15AC:  CALL   0128
15B0:  BTFSC  18.7
15B2:  BSF    FF2.7
15B4:  CLRF   18
15B6:  BTFSC  FF2.7
15B8:  BSF    18.7
15BA:  BCF    FF2.7
15BC:  MOVLW  0A
15BE:  MOVLB  1
15C0:  MOVWF  xF1
15C2:  MOVLB  0
15C4:  CALL   0128
15C8:  BTFSC  18.7
15CA:  BSF    FF2.7
....................    //fprintf(BASESTREAM,"HELLO\n\r"); 
.................... //enable_interrupts(GLOBAL); 
....................    delay_ms(2500); 
15CC:  MOVLW  0A
15CE:  MOVLB  1
15D0:  MOVWF  x14
15D2:  MOVLW  FA
15D4:  MOVWF  x15
15D6:  MOVLB  0
15D8:  BRA    1252
15DA:  MOVLB  1
15DC:  DECFSZ x14,F
15DE:  BRA    15D2
....................  
.................... //fprintf(BASESTREAM,"%s\r\n",GPSBuffer); //OUTPUTS BUFFER FOR TROUBLESHOOTING 
....................    } 
15E0:  MOVLB  0
15E2:  BRA    1408
....................     
.................... } 
15E4:  BRA    15E4

Configuration Fuses:
   Word  1: 0200   HS NOIESO NOFCMEN RESERVED
   Word  2: 1E19   NOBROWNOUT NOWDT BORV25 NOPUT WDT32768
   Word  3: 8300   PBADEN CCP2C1 NOLPT1OSC MCLR RESERVED
   Word  4: 0000   NOSTVREN DEBUG NOLVP NOXINST RESERVED
   Word  5: C00F   NOPROTECT NOCPD NOCPB
   Word  6: E00F   NOWRT NOWRTD NOWRTC NOWRTB
   Word  7: 400F   NOEBTR NOEBTRB
