CCS PCM C Compiler, Version 3.245, 27853 11-V-08 15:47Filename: D:\MLAB_E\projekty\Ovladani_mobilnim_telefonem\SW\final\main.lstROM used: 1315 words (16%)Largest free fragment is 2048RAM used: 52 (30%) at main() level139 (79%) worst caseStack: 2 locations*0000: MOVLW 000001: MOVWF 0A0002: GOTO 3D50003: NOP.................... #include ".\main.h".................... #include <16F876A.h>.................... //////// Standard Header file for the PIC16F876A device ////////////////.................... #device PIC16F876A.................... #list........................................ #device adc=8........................................ #FUSES NOWDT //Watch Dog Timer.................... #FUSES HS//XT //Crystal osc <= 4mhz.................... #FUSES NOPUT //No Power Up Timer.................... #FUSES NOPROTECT //Code not protected from reading.................... #FUSES NODEBUG //No Debug mode for ICD.................... #FUSES NOBROWNOUT //No brownout reset.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O.................... #FUSES NOCPD //No EE protection.................... #FUSES NOWRT //Program memory not write protected........................................ #use delay(clock=18432000,RESTART_WDT)*004E: MOVLW 52004F: MOVWF 040050: MOVF 00,W0051: BTFSC 03.20052: GOTO 0630053: MOVLW 050054: MOVWF 780055: MOVLW BF0056: MOVWF 770057: CLRWDT0058: DECFSZ 77,F0059: GOTO 057005A: DECFSZ 78,F005B: GOTO 055005C: MOVLW F9005D: MOVWF 77005E: DECFSZ 77,F005F: GOTO 05E0060: CLRWDT0061: DECFSZ 00,F0062: GOTO 0530063: RETLW 00.................... #use rs232(STREAM=MOBIL,baud=19200,force_sw,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)0064: BCF 20.60065: MOVF 20,W0066: BSF 03.50067: MOVWF 070068: BCF 03.50069: BCF 07.6006A: MOVLW 08006B: MOVWF 78006C: NOP006D: NOP006E: NOP006F: BSF 78.70070: GOTO 0800071: BCF 78.70072: RRF 53,F0073: BTFSC 03.00074: BSF 07.60075: BTFSS 03.00076: BCF 07.60077: BSF 78.60078: GOTO 0800079: BCF 78.6007A: DECFSZ 78,F007B: GOTO 072007C: NOP007D: NOP007E: NOP007F: BSF 07.60080: MOVLW 490081: MOVWF 040082: DECFSZ 04,F0083: GOTO 0820084: NOP0085: NOP0086: NOP0087: BTFSC 78.70088: GOTO 0710089: BTFSC 78.6008A: GOTO 079008B: RETLW 00008C: MOVLW 08008D: MOVWF 77008E: BSF 20.7008F: MOVF 20,W0090: BSF 03.50091: MOVWF 070092: BCF 03.50093: BTFSS 07.70094: GOTO 0970095: BSF 03.50096: GOTO 0920097: CLRF 570098: BSF 77.70099: GOTO 0A8009A: BCF 77.7009B: GOTO 0A8009C: BCF 03.0009D: BTFSC 07.7009E: BSF 03.0009F: RRF 57,F00A0: BSF 77.600A1: GOTO 0A800A2: BCF 77.600A3: DECFSZ 77,F00A4: GOTO 09C00A5: MOVF 57,W00A6: MOVWF 7800A7: GOTO 0B500A8: MOVLW 4900A9: BTFSC 77.700AA: MOVLW 1400AB: MOVWF 7800AC: DECFSZ 78,F00AD: GOTO 0AC00AE: NOP00AF: NOP00B0: BTFSC 77.700B1: GOTO 09A00B2: BTFSC 77.600B3: GOTO 0A200B4: GOTO 09C00B5: RETLW 00*03E9: MOVLW FF03EA: BCF 03.503EB: MOVWF 20.................... #use rs232(STREAM=VRTULE,baud=600,parity=N,xmit=PIN_B2,rcv=PIN_B4,bits=8)*01D0: BSF 03.501D1: BCF 06.201D2: BCF 03.501D3: BCF 06.201D4: MOVLW 0801D5: MOVWF 7801D6: NOP01D7: NOP01D8: NOP01D9: BSF 78.701DA: GOTO 1EA01DB: BCF 78.701DC: RRF 52,F01DD: BTFSC 03.001DE: BSF 06.201DF: BTFSS 03.001E0: BCF 06.201E1: BSF 78.601E2: GOTO 1EA01E3: BCF 78.601E4: DECFSZ 78,F01E5: GOTO 1DC01E6: NOP01E7: NOP01E8: NOP01E9: BSF 06.201EA: MOVLW 0901EB: MOVWF 7701EC: CLRF 0401ED: DECFSZ 04,F01EE: GOTO 1ED01EF: DECFSZ 77,F01F0: GOTO 1EC01F1: MOVLW F001F2: MOVWF 0401F3: DECFSZ 04,F01F4: GOTO 1F301F5: NOP01F6: NOP01F7: BTFSC 78.701F8: GOTO 1DB01F9: BTFSC 78.601FA: GOTO 1E301FB: RETLW 00................................................................................ #define LCD_RS PIN_B1 // rizeni registru LCD displeje.................... #define LCD_E PIN_B0 // enable LCD displeje.................... #define LCD_DATA_LSB PIN_C0 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)............................................................ #bit SPEN=0x18.7.................... #bit RCIF=0x0C.5........................................ #include <stdio.h>.................... ///////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2003 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ///////////////////////////////////////////////////////////////////////////........................................ #ifndef _STDIO.................... #define _STDIO.................... #include <string.h>.................... ////////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,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--).................... *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;*021D: BSF 03.5021E: MOVF 47,W021F: MOVWF 49.................... for(su=s;0<n;++su,--n)0220: MOVF 46,W0221: MOVWF 4A0222: MOVF 48,W0223: SUBLW 000224: BTFSC 03.00225: GOTO 232.................... if(*su==uc)0226: MOVF 4A,W0227: MOVWF 040228: MOVF 49,W0229: SUBWF 00,W022A: BTFSS 03.2022B: GOTO 22F.................... return su;022C: MOVF 4A,W022D: MOVWF 78022E: GOTO 234022F: INCF 4A,F0230: DECF 48,F0231: GOTO 222.................... return NULL;0232: MOVLW 000233: MOVWF 78.................... }0234: BCF 03.50235: RETLW 00........................................ /* 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;*03EC: CLRF 21........................................ 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........................................ #ifndef getc.................... #define getc getch.................... #define getchar getch.................... #define puts(s) {printf(s); putchar(13); putchar(10);}.................... #define putc putchar.................... #endif.................... /* maps error number to an error message. Writes a sequence of characters to.................... stderr stream thus: if s is not null then string pointed to by s follwed by.................... a colon (:) and a space and the appropriate error message returned by strerror.................... function with argument errno........................................ Returns: no value.................... */........................................ #ifdef _ERRNO.................... void perror(char *s).................... {.................... if(s).................... fprintf(STDERR,"%s: ",s);.................... fprintf(STDERR,"%s\r\n",strerror(errno));.................... }.................... #endif.................... #endif........................................ #include <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 <stdlib.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 _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........................................ 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>.................... #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............................................................ 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;.................... float result = 0.0;.................... int sign = 0;.................... char c;.................... int ptr = 0;........................................ c = s[ptr++];........................................ if ((c>='0' && c<='9') || c=='+' || c=='-' || c=='.') {.................... 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++];.................... }.................... }........................................ }........................................ if (sign == 1).................... result = -1*result;.................... return(result);.................... }........................................ 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--;.................... *((char *)endptr)=s+ptr;.................... }.................... else.................... *((char *)endptr)=s;.................... }........................................ return(result);.................... }........................................ long strtoul(char *s,char *endptr,signed int base).................... {.................... char *sc,*s1,*sd;.................... unsigned long x=0;*024F: CLRF 570250: CLRF 58.................... char sign;.................... char digits[]="0123456789abcdefghijklmnopqstuvwxyz";0251: MOVLW 300252: BSF 03.50253: MOVWF 200254: MOVLW 310255: MOVWF 210256: MOVLW 320257: MOVWF 220258: MOVLW 330259: MOVWF 23025A: MOVLW 34025B: MOVWF 24025C: MOVLW 35025D: MOVWF 25025E: MOVLW 36025F: MOVWF 260260: MOVLW 370261: MOVWF 270262: MOVLW 380263: MOVWF 280264: MOVLW 390265: MOVWF 290266: MOVLW 610267: MOVWF 2A0268: MOVLW 620269: MOVWF 2B026A: MOVLW 63026B: MOVWF 2C026C: MOVLW 64026D: MOVWF 2D026E: MOVLW 65026F: MOVWF 2E0270: MOVLW 660271: MOVWF 2F0272: MOVLW 670273: MOVWF 300274: MOVLW 680275: MOVWF 310276: MOVLW 690277: MOVWF 320278: MOVLW 6A0279: MOVWF 33027A: MOVLW 6B027B: MOVWF 34027C: MOVLW 6C027D: MOVWF 35027E: MOVLW 6D027F: MOVWF 360280: MOVLW 6E0281: MOVWF 370282: MOVLW 6F0283: MOVWF 380284: MOVLW 700285: MOVWF 390286: MOVLW 710287: MOVWF 3A0288: MOVLW 730289: MOVWF 3B028A: MOVLW 74028B: MOVWF 3C028C: MOVLW 75028D: MOVWF 3D028E: MOVLW 76028F: MOVWF 3E0290: MOVLW 770291: MOVWF 3F0292: MOVLW 780293: MOVWF 400294: MOVLW 790295: MOVWF 410296: MOVLW 7A0297: MOVWF 420298: CLRF 43.................... for(sc=s;isspace(*sc);++sc);0299: BCF 03.5029A: MOVF 51,W029B: MOVWF 54029C: MOVF 54,W029D: MOVWF 04029E: MOVF 00,W029F: SUBLW 2002A0: BTFSS 03.202A1: GOTO 2A402A2: INCF 54,F02A3: GOTO 29C.................... sign=*sc=='-'||*sc=='+'?*sc++:'+';02A4: MOVF 54,W02A5: MOVWF 0402A6: MOVF 00,W02A7: SUBLW 2D02A8: BTFSC 03.202A9: GOTO 2B002AA: MOVF 54,W02AB: MOVWF 0402AC: MOVF 00,W02AD: SUBLW 2B02AE: BTFSS 03.202AF: GOTO 2B502B0: MOVF 54,W02B1: INCF 54,F02B2: MOVWF 0402B3: MOVF 00,W02B4: GOTO 2B602B5: MOVLW 2B02B6: MOVWF 59.................... if(sign=='-')02B7: MOVF 59,W02B8: SUBLW 2D02B9: BTFSS 03.202BA: GOTO 2C6.................... {.................... if (endptr)02BB: MOVF 52,F02BC: BTFSC 03.202BD: GOTO 2C2.................... {.................... *((char *)endptr)=s;02BE: MOVF 52,W02BF: MOVWF 0402C0: MOVF 51,W02C1: MOVWF 00.................... }.................... return 0;02C2: MOVLW 0002C3: MOVWF 7802C4: MOVWF 7902C5: GOTO 3D2.................... }........................................ if (base <0 || base ==1|| base >36) // invalid base02C6: BTFSC 53.702C7: GOTO 2D102C8: DECFSZ 53,W02C9: GOTO 2CB02CA: GOTO 2D102CB: BTFSC 53.702CC: GOTO 2DD02CD: MOVF 53,W02CE: SUBLW 2402CF: BTFSC 03.002D0: GOTO 2DD.................... {.................... if (endptr)02D1: MOVF 52,F02D2: BTFSC 03.202D3: GOTO 2D8.................... {.................... *((char *)endptr)=s;02D4: MOVF 52,W02D5: MOVWF 0402D6: MOVF 51,W02D7: MOVWF 00.................... }.................... return 0;02D8: MOVLW 0002D9: MOVWF 7802DA: MOVWF 7902DB: GOTO 3D2.................... }.................... else if (base)02DC: GOTO 34302DD: MOVF 53,F02DE: BTFSC 03.202DF: GOTO 31A.................... {.................... if(base==16 && *sc =='0'&&(sc[1]=='x' || sc[1]=='X'))02E0: MOVF 53,W02E1: SUBLW 1002E2: BTFSS 03.202E3: GOTO 2FA02E4: MOVF 54,W02E5: MOVWF 0402E6: MOVF 00,W02E7: SUBLW 3002E8: BTFSS 03.202E9: GOTO 2FA02EA: MOVLW 0102EB: ADDWF 54,W02EC: MOVWF 0402ED: MOVF 00,W02EE: SUBLW 7802EF: BTFSC 03.202F0: GOTO 2F802F1: MOVLW 0102F2: ADDWF 54,W02F3: MOVWF 0402F4: MOVF 00,W02F5: SUBLW 5802F6: BTFSS 03.202F7: GOTO 2FA.................... sc+=2;02F8: MOVLW 0202F9: ADDWF 54,F.................... if(base==8 && *sc =='0')02FA: MOVF 53,W02FB: SUBLW 0802FC: BTFSS 03.202FD: GOTO 30602FE: MOVF 54,W02FF: MOVWF 040300: MOVF 00,W0301: SUBLW 300302: BTFSS 03.20303: GOTO 306.................... sc+=1;0304: MOVLW 010305: ADDWF 54,F.................... if(base==2 && *sc =='0'&&sc[1]=='b')0306: MOVF 53,W0307: SUBLW 020308: BTFSS 03.20309: GOTO 319030A: MOVF 54,W030B: MOVWF 04030C: MOVF 00,W030D: SUBLW 30030E: BTFSS 03.2030F: GOTO 3190310: MOVLW 010311: ADDWF 54,W0312: MOVWF 040313: MOVF 00,W0314: SUBLW 620315: BTFSS 03.20316: GOTO 319.................... sc+=2;0317: MOVLW 020318: ADDWF 54,F........................................ }.................... else if(*sc!='0') // base is 0, find base0319: GOTO 343031A: MOVF 54,W031B: MOVWF 04031C: MOVF 00,W031D: SUBLW 30031E: BTFSC 03.2031F: GOTO 323.................... base=10;0320: MOVLW 0A0321: MOVWF 53.................... else if (sc[1]=='x' || sc[1]=='X')0322: GOTO 3430323: MOVLW 010324: ADDWF 54,W0325: MOVWF 040326: MOVF 00,W0327: SUBLW 780328: BTFSC 03.20329: GOTO 331032A: MOVLW 01032B: ADDWF 54,W032C: MOVWF 04032D: MOVF 00,W032E: SUBLW 58032F: BTFSS 03.20330: GOTO 336.................... base =16,sc+=2;0331: MOVLW 100332: MOVWF 530333: MOVLW 020334: ADDWF 54,F.................... else if(sc[1]=='b')0335: GOTO 3430336: MOVLW 010337: ADDWF 54,W0338: MOVWF 040339: MOVF 00,W033A: SUBLW 62033B: BTFSS 03.2033C: GOTO 341.................... base=2,sc+=2;033D: MOVLW 02033E: MOVWF 53033F: ADDWF 54,F.................... else0340: GOTO 343.................... base=8;0341: MOVLW 080342: MOVWF 53.................... for (s1=sc;*sc=='0';++sc);// skip leading zeroes0343: MOVF 54,W0344: MOVWF 550345: MOVF 54,W0346: MOVWF 040347: MOVF 00,W0348: SUBLW 300349: BTFSS 03.2034A: GOTO 34D034B: INCF 54,F034C: GOTO 345.................... sd=memchr(digits,tolower(*sc),base);034D: MOVF 54,W034E: MOVWF 04034F: MOVF 00,W0350: MOVWF 5A0351: SUBLW 400352: BTFSC 03.00353: GOTO 35B0354: MOVF 5A,W0355: SUBLW 5A0356: BTFSS 03.00357: GOTO 35B0358: MOVF 5A,W0359: IORLW 20035A: GOTO 35C035B: MOVF 5A,W035C: MOVWF 5B035D: MOVLW A0035E: BSF 03.5035F: MOVWF 460360: BCF 03.50361: MOVF 5A,W0362: BSF 03.50363: MOVWF 470364: BCF 03.50365: MOVF 53,W0366: BSF 03.50367: MOVWF 480368: BCF 03.50369: CALL 21D036A: MOVF 78,W036B: MOVWF 56.................... for(; sd!=0; )036C: MOVF 56,F036D: BTFSC 03.2036E: GOTO 3B8.................... {.................... x=x*base+(int16)(sd-digits);036F: CLRF 7A0370: MOVF 53,W0371: MOVWF 770372: BTFSC 53.70373: DECF 7A,F0374: MOVWF 5A0375: MOVF 7A,W0376: MOVWF 5B0377: MOVF 58,W0378: BSF 03.50379: MOVWF 47037A: BCF 03.5037B: MOVF 57,W037C: BSF 03.5037D: MOVWF 46037E: BCF 03.5037F: MOVF 7A,W0380: BSF 03.50381: MOVWF 490382: BCF 03.50383: MOVF 5A,W0384: BSF 03.50385: MOVWF 480386: BCF 03.50387: GOTO 2360388: MOVF 78,W0389: MOVWF 5B038A: MOVLW A0038B: SUBWF 56,W038C: CLRF 7A038D: ADDWF 78,W038E: MOVWF 78038F: BTFSC 03.00390: INCF 7A,F0391: MOVF 79,W0392: ADDWF 7A,F0393: MOVF 78,W0394: MOVWF 570395: MOVF 7A,W0396: MOVWF 58.................... ++sc;0397: INCF 54,F.................... sd=memchr(digits,tolower(*sc),base);0398: MOVF 54,W0399: MOVWF 04039A: MOVF 00,W039B: MOVWF 5A039C: SUBLW 40039D: BTFSC 03.0039E: GOTO 3A6039F: MOVF 5A,W03A0: SUBLW 5A03A1: BTFSS 03.003A2: GOTO 3A603A3: MOVF 5A,W03A4: IORLW 2003A5: GOTO 3A703A6: MOVF 5A,W03A7: MOVWF 5B03A8: MOVLW A003A9: BSF 03.503AA: MOVWF 4603AB: BCF 03.503AC: MOVF 5A,W03AD: BSF 03.503AE: MOVWF 4703AF: BCF 03.503B0: MOVF 53,W03B1: BSF 03.503B2: MOVWF 4803B3: BCF 03.503B4: CALL 21D03B5: MOVF 78,W03B6: MOVWF 56.................... }03B7: GOTO 36C.................... if(s1==sc)03B8: MOVF 54,W03B9: SUBWF 55,W03BA: BTFSS 03.203BB: GOTO 3C7.................... {.................... if (endptr)03BC: MOVF 52,F03BD: BTFSC 03.203BE: GOTO 3C3.................... {.................... *((char *)endptr)=s;03BF: MOVF 52,W03C0: MOVWF 0403C1: MOVF 51,W03C2: MOVWF 00.................... }.................... return 0;03C3: MOVLW 0003C4: MOVWF 7803C5: MOVWF 7903C6: GOTO 3D2.................... }.................... if (endptr)03C7: MOVF 52,F03C8: BTFSC 03.203C9: GOTO 3CE.................... *((char *)endptr)=sc;03CA: MOVF 52,W03CB: MOVWF 0403CC: MOVF 54,W03CD: MOVWF 00.................... return x;03CE: MOVF 57,W03CF: MOVWF 7803D0: MOVF 58,W03D1: MOVWF 79.................... }03D2: BCF 0A.303D3: BCF 0A.403D4: GOTO 4FF (RETURN)............................................................ 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.................... {.................... if (endptr).................... {.................... *((char *)endptr)=s;.................... }.................... return 0;.................... }.................... 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).................... {.................... if (endptr).................... {.................... *((char *)endptr)=s;.................... }.................... return 0;.................... }.................... if(sign=='-').................... x =-x;.................... if (endptr).................... *((char *)endptr)=sc;.................... 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 = 1;*03ED: MOVLW 0103EE: MOVWF 2203EF: CLRF 2303F0: CLRF 2403F1: CLRF 25........................................ 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............................................................ #define DELKA 40........................................ char odp[DELKA];........................................ int1 check_new_sms().................... {.................... fprintf(MOBIL,"AT+CMGL=1\r"); //vycti prijate SMS (0=nove;1=vsechny)*00B6: CLRF 5100B7: MOVF 51,W00B8: CALL 00400B9: IORLW 0000BA: BTFSC 03.200BB: GOTO 0C000BC: INCF 51,F00BD: MOVWF 5300BE: CALL 06400BF: GOTO 0B7.................... while(fgetc(MOBIL)!=0x0A); // predkoc prvni radek odpovedi00C0: CALL 08C00C1: MOVF 78,W00C2: SUBLW 0A00C3: BTFSS 03.200C4: GOTO 0C0.................... odp[0]=fgetc(MOBIL); // Nacti prvni dva znaky druheho radku odpovedi00C5: CALL 08C00C6: MOVF 78,W00C7: MOVWF 26.................... odp[1]=fgetc(MOBIL);00C8: CALL 08C00C9: MOVF 78,W00CA: MOVWF 27.................... while(fgetc(MOBIL)!=0x0A); // Preskoc zbytek radku00CB: CALL 08C00CC: MOVF 78,W00CD: SUBLW 0A00CE: BTFSS 03.200CF: GOTO 0CB........................................ if(odp[0] == 'O' && odp[1] == 'K') return 1;00D0: MOVF 26,W00D1: SUBLW 4F00D2: BTFSS 03.200D3: GOTO 0DC00D4: MOVF 27,W00D5: SUBLW 4B00D6: BTFSS 03.200D7: GOTO 0DC00D8: MOVLW 0100D9: MOVWF 7800DA: GOTO 0DF.................... else return 0;00DB: GOTO 0DF00DC: MOVLW 0000DD: MOVWF 7800DE: GOTO 0DF.................... }00DF: BCF 0A.300E0: BCF 0A.400E1: GOTO 46E (RETURN)........................................ read_sms().................... {.................... int pom,pom2,pom3,odkl,odkl2,maskovadlo;.................... for(pom=0;pom<54;pom++) //preskoc nedulezite informace00E2: CLRF 5100E3: MOVF 51,W00E4: SUBLW 3500E5: BTFSS 03.000E6: GOTO 0EA.................... {.................... fgetc(MOBIL);00E7: CALL 08C.................... }00E8: INCF 51,F00E9: GOTO 0E3........................................ //gets(odp); //uloz zakodovany text SMS........................................ odp[0]=fgetc(MOBIL);00EA: CALL 08C00EB: MOVF 78,W00EC: MOVWF 26.................... odp[1]=fgetc(MOBIL);00ED: CALL 08C00EE: MOVF 78,W00EF: MOVWF 27.................... odp[2]=fgetc(MOBIL);00F0: CALL 08C00F1: MOVF 78,W00F2: MOVWF 28.................... odp[3]=fgetc(MOBIL);00F3: CALL 08C00F4: MOVF 78,W00F5: MOVWF 29.................... odp[4]=fgetc(MOBIL);00F6: CALL 08C00F7: MOVF 78,W00F8: MOVWF 2A.................... odp[5]=fgetc(MOBIL);00F9: CALL 08C00FA: MOVF 78,W00FB: MOVWF 2B.................... odp[6]=fgetc(MOBIL);00FC: CALL 08C00FD: MOVF 78,W00FE: MOVWF 2C.................... odp[7]=fgetc(MOBIL);00FF: CALL 08C0100: MOVF 78,W0101: MOVWF 2D........................................ /*lcd_gotoxy(1,1);.................... printf(lcd_putc,"\f%s\n",odp);*/........................................ if(odp[0]==0) odp[1]='0'; // Prevod z ASCII do BIN0102: MOVF 26,F0103: BTFSS 03.20104: GOTO 1070105: MOVLW 300106: MOVWF 27.................... odp[0]=odp[0] - '0';0107: MOVLW 300108: SUBWF 26,F.................... odp[1]=odp[1] - '0';0109: SUBWF 27,F.................... if(odp[0]>9) odp[0]=odp[0]-7;010A: MOVF 26,W010B: SUBLW 09010C: BTFSC 03.0010D: GOTO 110010E: MOVLW 07010F: SUBWF 26,F.................... if(odp[1]>9) odp[1]=odp[1]-7;0110: MOVF 27,W0111: SUBLW 090112: BTFSC 03.00113: GOTO 1160114: MOVLW 070115: SUBWF 27,F.................... odp[0]=odp[0] << 4;0116: SWAPF 26,F0117: MOVLW F00118: ANDWF 26,F.................... odp[0] |= odp[1];0119: MOVF 27,W011A: IORWF 26,F........................................ if(odp[2]==0) odp[3]='0';011B: MOVF 28,F011C: BTFSS 03.2011D: GOTO 120011E: MOVLW 30011F: MOVWF 29.................... odp[2]=odp[2] - '0';0120: MOVLW 300121: SUBWF 28,F.................... odp[3]=odp[3] - '0';0122: SUBWF 29,F.................... if(odp[2]>9) odp[2]=odp[2]-7;0123: MOVF 28,W0124: SUBLW 090125: BTFSC 03.00126: GOTO 1290127: MOVLW 070128: SUBWF 28,F.................... if(odp[3]>9) odp[3]=odp[3]-7;0129: MOVF 29,W012A: SUBLW 09012B: BTFSC 03.0012C: GOTO 12F012D: MOVLW 07012E: SUBWF 29,F.................... odp[2]=odp[2] << 4;012F: SWAPF 28,F0130: MOVLW F00131: ANDWF 28,F.................... odp[2] |= odp[3];0132: MOVF 29,W0133: IORWF 28,F........................................ if(odp[4]==0) odp[5]='0';0134: MOVF 2A,F0135: BTFSS 03.20136: GOTO 1390137: MOVLW 300138: MOVWF 2B.................... odp[4]=odp[4] - '0';0139: MOVLW 30013A: SUBWF 2A,F.................... odp[5]=odp[5] - '0';013B: SUBWF 2B,F.................... if(odp[4]>9) odp[4]=odp[4]-7;013C: MOVF 2A,W013D: SUBLW 09013E: BTFSC 03.0013F: GOTO 1420140: MOVLW 070141: SUBWF 2A,F.................... if(odp[5]>9) odp[5]=odp[5]-7;0142: MOVF 2B,W0143: SUBLW 090144: BTFSC 03.00145: GOTO 1480146: MOVLW 070147: SUBWF 2B,F.................... odp[4]=odp[4] << 4;0148: SWAPF 2A,F0149: MOVLW F0014A: ANDWF 2A,F.................... odp[4] |= odp[5];014B: MOVF 2B,W014C: IORWF 2A,F........................................ if(odp[6]==0) odp[7]='0';014D: MOVF 2C,F014E: BTFSS 03.2014F: GOTO 1520150: MOVLW 300151: MOVWF 2D.................... odp[6]=odp[6] - '0';0152: MOVLW 300153: SUBWF 2C,F.................... odp[7]=odp[7] - '0';0154: SUBWF 2D,F.................... if(odp[6]>9) odp[6]=odp[6]-7;0155: MOVF 2C,W0156: SUBLW 090157: BTFSC 03.00158: GOTO 15B0159: MOVLW 07015A: SUBWF 2C,F.................... if(odp[7]>9) odp[7]=odp[7]-7;015B: MOVF 2D,W015C: SUBLW 09015D: BTFSC 03.0015E: GOTO 161015F: MOVLW 070160: SUBWF 2D,F.................... odp[6]=odp[6] << 4;0161: SWAPF 2C,F0162: MOVLW F00163: ANDWF 2C,F.................... odp[6] |= odp[7];0164: MOVF 2D,W0165: IORWF 2C,F........................................ odp[1]=odp[2];0166: MOVF 28,W0167: MOVWF 27.................... odp[2]=odp[4];0168: MOVF 2A,W0169: MOVWF 28.................... odp[3]=odp[6];016A: MOVF 2C,W016B: MOVWF 29.................... odp[4]=odp[5]=odp[6]=0;016C: CLRF 2C016D: MOVF 2C,W016E: MOVWF 2B016F: MOVWF 2A........................................ /*lcd_gotoxy(1,2);.................... printf(lcd_putc,"%u %u %u %u",odp[0],odp[1],odp[2]odp[3]); */........................................ pom3=0;0170: CLRF 53.................... for (pom = 0; pom < 4;pom++)0171: CLRF 510172: MOVF 51,W0173: SUBLW 030174: BTFSS 03.00175: GOTO 1C9.................... {.................... maskovadlo = maskovadlo >> 1; //rotace promene urcene pro maskovani0176: BCF 03.00177: RRF 56,F.................... maskovadlo = maskovadlo | 0x80;0178: BSF 56.7.................... odkl = odp[pom] & maskovadlo; //odlozeni "prenosu" do odkl pomoci maskovadla0179: MOVLW 26017A: ADDWF 51,W017B: MOVWF 04017C: MOVF 00,W017D: ANDWF 56,W017E: MOVWF 54.................... odp[pom] = odp[pom] << pom3; //rotace znaku017F: MOVLW 260180: ADDWF 51,W0181: MOVWF 570182: MOVLW 260183: ADDWF 51,W0184: MOVWF 040185: MOVF 00,W0186: MOVWF 770187: MOVF 53,W0188: MOVWF 780189: BTFSC 03.2018A: GOTO 18F018B: BCF 03.0018C: RLF 77,F018D: DECFSZ 78,F018E: GOTO 18B018F: MOVF 57,W0190: MOVWF 040191: MOVF 77,W0192: MOVWF 00.................... for (pom2 = 0; pom2 < (8-pom3);pom2++) //rotace odkl20193: CLRF 520194: MOVF 53,W0195: SUBLW 080196: SUBWF 52,W0197: BTFSC 03.00198: GOTO 19E.................... {.................... odkl2 = odkl2 >> 1;0199: BCF 03.0019A: RRF 55,F.................... odkl2 = odkl2 & 127;019B: BCF 55.7.................... }019C: INCF 52,F019D: GOTO 194.................... odp[pom] = odp[pom] | odkl2; //pridani odkl2 ke znaku019E: MOVLW 26019F: ADDWF 51,W01A0: MOVWF 5701A1: MOVLW 2601A2: ADDWF 51,W01A3: MOVWF 0401A4: MOVF 00,W01A5: IORWF 55,W01A6: MOVWF 5901A7: MOVF 57,W01A8: MOVWF 0401A9: MOVF 59,W01AA: MOVWF 00.................... odp[pom] = odp[pom] & 127; //smazani nejvysiho bitu01AB: MOVLW 2601AC: ADDWF 51,W01AD: MOVWF 5701AE: MOVLW 2601AF: ADDWF 51,W01B0: MOVWF 0401B1: MOVF 00,W01B2: ANDLW 7F01B3: MOVWF 5901B4: MOVF 57,W01B5: MOVWF 0401B6: MOVF 59,W01B7: MOVWF 00.................... odkl2 = odkl; //ulozeni odlk na dalsi pruchod01B8: MOVF 54,W01B9: MOVWF 55.................... pom3++; //inkrementace citace rotace01BA: INCF 53,F.................... if (pom3 == 8) //kazdy 8my znak01BB: MOVF 53,W01BC: SUBLW 0801BD: BTFSS 03.201BE: GOTO 1C7.................... {.................... pom3 = 0; //smaz citac01BF: CLRF 53.................... odp[pom+1] = odkl2; //uloz 8my znak vznikly z "prenosu"01C0: MOVLW 0101C1: ADDWF 51,W01C2: ADDLW 2601C3: MOVWF 0401C4: MOVF 55,W01C5: MOVWF 00.................... maskovadlo = 0; //smaz maskovadlo01C6: CLRF 56.................... }.................... }01C7: INCF 51,F01C8: GOTO 172.................... odp[pom]='\0';01C9: MOVLW 2601CA: ADDWF 51,W01CB: MOVWF 0401CC: CLRF 00.................... }01CD: BCF 0A.301CE: BCF 0A.401CF: GOTO 47A (RETURN)........................................ void read_time().................... {.................... unsigned int8 n;............................................................ fprintf(MOBIL,"AT+CCLK?\r");*01FC: CLRF 5201FD: MOVF 52,W01FE: CALL 01301FF: IORLW 000200: BTFSC 03.20201: GOTO 2060202: INCF 52,F0203: MOVWF 530204: CALL 0640205: GOTO 1FD.................... while(fgetc(MOBIL)!='"');0206: CALL 08C0207: MOVF 78,W0208: SUBLW 220209: BTFSS 03.2020A: GOTO 206.................... for(n=0;n<12;n++) //preskoc nedulezite informace020B: CLRF 51020C: MOVF 51,W020D: SUBLW 0B020E: BTFSS 03.0020F: GOTO 213.................... {.................... fgetc(MOBIL);0210: CALL 08C.................... }0211: INCF 51,F0212: GOTO 20C.................... odp[0]=fgetc(MOBIL);0213: CALL 08C0214: MOVF 78,W0215: MOVWF 26.................... odp[1]=fgetc(MOBIL);0216: CALL 08C0217: MOVF 78,W0218: MOVWF 27.................... odp[2]=0;0219: CLRF 28.................... }021A: BCF 0A.3021B: BCF 0A.4021C: GOTO 4F8 (RETURN)........................................ void del_sms().................... {.................... fprintf(MOBIL,"AT+CMGD=1\r"); //smaz prijatou SMSku.................... }........................................ void main().................... {*03D5: CLRF 0403D6: MOVLW 1F03D7: ANDWF 03,F03D8: BCF 20.603D9: MOVF 20,W03DA: BSF 03.503DB: MOVWF 0703DC: BCF 03.503DD: BSF 07.603DE: BSF 03.503DF: BCF 06.203E0: BCF 03.503E1: BSF 06.203E2: BSF 03.503E3: BSF 1F.003E4: BSF 1F.103E5: BSF 1F.203E6: BCF 1F.303E7: MOVLW 0703E8: MOVWF 1C.................... setup_adc_ports(NO_ANALOGS);*03F2: BSF 03.503F3: BSF 1F.003F4: BSF 1F.103F5: BSF 1F.203F6: BCF 1F.3.................... setup_adc(ADC_OFF);03F7: BCF 03.503F8: BCF 1F.0.................... setup_spi(SPI_SS_DISABLED);03F9: BCF 14.503FA: BCF 20.503FB: MOVF 20,W03FC: BSF 03.503FD: MOVWF 0703FE: BCF 03.503FF: BSF 20.40400: MOVF 20,W0401: BSF 03.50402: MOVWF 070403: BCF 03.50404: BCF 20.30405: MOVF 20,W0406: BSF 03.50407: MOVWF 070408: MOVLW 010409: BCF 03.5040A: MOVWF 14040B: MOVLW 00040C: BSF 03.5040D: MOVWF 14.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);040E: MOVF 01,W040F: ANDLW C70410: IORLW 080411: MOVWF 01.................... setup_timer_1(T1_DISABLED);0412: BCF 03.50413: CLRF 10.................... setup_timer_2(T2_DIV_BY_4,255,1);0414: MOVLW 000415: MOVWF 780416: IORLW 050417: MOVWF 120418: MOVLW FF0419: BSF 03.5041A: MOVWF 12.................... setup_ccp1(CCP_PWM);041B: BCF 03.5041C: BCF 20.2041D: MOVF 20,W041E: BSF 03.5041F: MOVWF 070420: BCF 03.50421: BCF 07.20422: MOVLW 0C0423: MOVWF 17.................... setup_ccp2(CCP_PWM);0424: BCF 20.10425: MOVF 20,W0426: BSF 03.50427: MOVWF 070428: BCF 03.50429: BCF 07.1042A: MOVLW 0C042B: MOVWF 1D.................... setup_comparator(NC_NC_NC_NC);042C: MOVLW 07042D: BSF 03.5042E: MOVWF 1C042F: MOVF 05,W0430: CLRWDT0431: MOVLW 0E0432: MOVWF 770433: DECFSZ 77,F0434: GOTO 4330435: NOP0436: NOP0437: MOVF 1C,W0438: BCF 03.50439: BCF 0D.6.................... setup_vref(FALSE);043A: BSF 03.5043B: CLRF 1D.................... setup_wdt(WDT_2304MS);043C: MOVLW 0F043D: MOVWF 77043E: MOVLW 07043F: BCF 03.50440: CLRF 010441: MOVLW 810442: MOVWF 040443: MOVF 00,W0444: ANDLW F00445: IORLW 070446: MOVWF 000447: CLRWDT0448: MOVF 00,W0449: ANDLW F7044A: BTFSC 77.3044B: ANDLW F0044C: IORWF 77,W044D: MOVWF 00........................................ set_pwm1_duty(0);044E: CLRF 15.................... set_pwm2_duty(0);044F: CLRF 1B........................................ while(TRUE).................... {.................... int status;.................... char *ptr;.................... int time;........................................ restart_wdt();0450: CLRWDT........................................ output_low(PIN_A4) ;0451: BSF 03.50452: BCF 05.40453: BCF 03.50454: BCF 05.4.................... delay_ms(150);0455: MOVLW 960456: MOVWF 520457: CALL 04E.................... output_high(PIN_A4);0458: BSF 03.50459: BCF 05.4045A: BCF 03.5045B: BSF 05.4.................... delay_ms(150);045C: MOVLW 96045D: MOVWF 52045E: CALL 04E.................... output_low(PIN_A4) ;045F: BSF 03.50460: BCF 05.40461: BCF 03.50462: BCF 05.4.................... delay_ms(150);0463: MOVLW 960464: MOVWF 520465: CALL 04E.................... output_high(PIN_A4);0466: BSF 03.50467: BCF 05.40468: BCF 03.50469: BSF 05.4.................... delay_ms(150);046A: MOVLW 96046B: MOVWF 52046C: CALL 04E............................................................ if(check_new_sms()) // Je odpoved "OK"?046D: GOTO 0B6046E: MOVF 78,F046F: BTFSC 03.20470: GOTO 479.................... {.................... // printf(lcd_putc,"736 655 250");.................... delay_ms(1000);0471: MOVLW 040472: MOVWF 510473: MOVLW FA0474: MOVWF 520475: CALL 04E0476: DECFSZ 51,F0477: GOTO 473.................... }.................... else0478: GOTO 4F7.................... {.................... read_sms();0479: GOTO 0E2........................................ /* if (odp[0] == 'A' || odp[0] == 'a').................... {.................... set_pwm1_duty(500);.................... set_pwm2_duty(500);.................... Delay_ms(10000);.................... fprintf(VRTULE,"JACK[BARmk"); // "JACK BAR :)".................... Delay_ms(2000);.................... fprintf(VRTULE,"JACK[BARmk"); // "JACK BAR :)".................... Delay_ms(5000);.................... set_pwm1_duty(0);.................... set_pwm2_duty(0);.................... }*/........................................ /* if (odp[1] == 'h').................... {.................... set_pwm1_duty(500);.................... set_pwm2_duty(500);.................... Delay_ms(10000);.................... fprintf(VRTULE,"[ERROR[d[["); // " ERROR 3 ".................... Delay_ms(2000);.................... fprintf(VRTULE,"[ERROR[d[["); // " ERROR 3 ".................... Delay_ms(2000);.................... fprintf(VRTULE,"[OVERFLOW["); // " OVERFLOW ".................... Delay_ms(2000);.................... fprintf(VRTULE,"[OVERFLOW[");.................... Delay_ms(5000);.................... set_pwm1_duty(0);.................... set_pwm2_duty(0);.................... }*/........................................ if (odp[2] == 'o')047A: MOVF 28,W047B: SUBLW 6F047C: BTFSS 03.2047D: GOTO 4F7.................... {.................... set_pwm1_duty(500);047E: MOVLW 7D047F: MOVWF 150480: MOVF 17,W0481: ANDLW CF0482: MOVWF 17.................... set_pwm2_duty(500);0483: MOVLW 7D0484: MOVWF 1B0485: MOVF 1D,W0486: ANDLW CF0487: MOVWF 1D.................... Delay_ms(10000);0488: MOVLW 280489: MOVWF 51048A: MOVLW FA048B: MOVWF 52048C: CALL 04E048D: DECFSZ 51,F048E: GOTO 48A.................... fprintf(VRTULE,"[ERROR[e[["); // " ERROR 4 "048F: CLRF 510490: MOVF 51,W0491: CALL 0210492: IORLW 000493: BTFSC 03.20494: GOTO 4990495: INCF 51,F0496: MOVWF 520497: CALL 1D00498: GOTO 490.................... Delay_ms(2000);0499: MOVLW 08049A: MOVWF 51049B: MOVLW FA049C: MOVWF 52049D: CALL 04E049E: DECFSZ 51,F049F: GOTO 49B.................... fprintf(VRTULE,"[ERROR[e[["); // " ERROR 4 "04A0: CLRF 5104A1: MOVF 51,W04A2: CALL 02104A3: IORLW 0004A4: BTFSC 03.204A5: GOTO 4AA04A6: INCF 51,F04A7: MOVWF 5204A8: CALL 1D004A9: GOTO 4A1.................... Delay_ms(2000);04AA: MOVLW 0804AB: MOVWF 5104AC: MOVLW FA04AD: MOVWF 5204AE: CALL 04E04AF: DECFSZ 51,F04B0: GOTO 4AC.................... fprintf(VRTULE,"[OPAKUJTE["); // " OPAKUJTE "04B1: CLRF 5104B2: MOVF 51,W04B3: CALL 03004B4: IORLW 0004B5: BTFSC 03.204B6: GOTO 4BB04B7: INCF 51,F04B8: MOVWF 5204B9: CALL 1D004BA: GOTO 4B2.................... Delay_ms(2000);04BB: MOVLW 0804BC: MOVWF 5104BD: MOVLW FA04BE: MOVWF 5204BF: CALL 04E04C0: DECFSZ 51,F04C1: GOTO 4BD.................... fprintf(VRTULE,"[OPAKUJTE[");04C2: CLRF 5104C3: MOVF 51,W04C4: CALL 03004C5: IORLW 0004C6: BTFSC 03.204C7: GOTO 4CC04C8: INCF 51,F04C9: MOVWF 5204CA: CALL 1D004CB: GOTO 4C3.................... Delay_ms(2000);04CC: MOVLW 0804CD: MOVWF 5104CE: MOVLW FA04CF: MOVWF 5204D0: CALL 04E04D1: DECFSZ 51,F04D2: GOTO 4CE.................... fprintf(VRTULE,"[[VOLBU[[["); // " VOLBU "04D3: CLRF 5104D4: MOVF 51,W04D5: CALL 03F04D6: IORLW 0004D7: BTFSC 03.204D8: GOTO 4DD04D9: INCF 51,F04DA: MOVWF 5204DB: CALL 1D004DC: GOTO 4D4.................... Delay_ms(2000);04DD: MOVLW 0804DE: MOVWF 5104DF: MOVLW FA04E0: MOVWF 5204E1: CALL 04E04E2: DECFSZ 51,F04E3: GOTO 4DF.................... fprintf(VRTULE,"[[VOLBU[[[");04E4: CLRF 5104E5: MOVF 51,W04E6: CALL 03F04E7: IORLW 0004E8: BTFSC 03.204E9: GOTO 4EE04EA: INCF 51,F04EB: MOVWF 5204EC: CALL 1D004ED: GOTO 4E5.................... Delay_ms(3000);04EE: MOVLW 0C04EF: MOVWF 5104F0: MOVLW FA04F1: MOVWF 5204F2: CALL 04E04F3: DECFSZ 51,F04F4: GOTO 4F0.................... set_pwm1_duty(0);04F5: CLRF 15.................... set_pwm2_duty(0);04F6: CLRF 1B.................... }.................... }.................... read_time();04F7: GOTO 1FC.................... time=strtoul(odp,&ptr,10);04F8: MOVLW 2604F9: MOVWF 5104FA: MOVLW 4F04FB: MOVWF 5204FC: MOVLW 0A04FD: MOVWF 5304FE: GOTO 24F04FF: MOVF 78,W0500: MOVWF 50.................... if((time >= 30 && time <= 35) || (time >= 0 && time <= 5))0501: MOVF 50,W0502: SUBLW 1D0503: BTFSC 03.00504: GOTO 5090505: MOVF 50,W0506: SUBLW 230507: BTFSC 03.00508: GOTO 50D0509: MOVF 50,W050A: SUBLW 05050B: BTFSS 03.0050C: GOTO 518.................... {.................... set_pwm1_duty(500);050D: MOVLW 7D050E: MOVWF 15050F: MOVF 17,W0510: ANDLW CF0511: MOVWF 17.................... set_pwm2_duty(500);0512: MOVLW 7D0513: MOVWF 1B0514: MOVF 1D,W0515: ANDLW CF0516: MOVWF 1D.................... }.................... else0517: GOTO 51A.................... {.................... set_pwm1_duty(0);0518: CLRF 15.................... set_pwm2_duty(0);0519: CLRF 1B.................... }........................................ delay_ms(1000);051A: MOVLW 04051B: MOVWF 51051C: MOVLW FA051D: MOVWF 52051E: CALL 04E051F: DECFSZ 51,F0520: GOTO 51C.................... }0521: GOTO 450.................... }0522: SLEEPConfiguration Fuses:Word 1: 3F3A HS NOWDT NOPUT NODEBUG NOPROTECT NOBROWNOUT NOLVP NOCPD NOWRT