CCS PCM C Compiler, Version 3.245, 27853 11-V-08 00:17Filename: D:\MLAB_E\projekty\Ovladani_mobilnim_telefonem\SW\final\main.lstROM used: 275 words (3%)Largest free fragment is 2048RAM used: 52 (30%) at main() level56 (32%) worst caseStack: 1 locations*0000: MOVLW 000001: MOVWF 0A0002: GOTO 0570003: 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)0013: MOVLW 520014: MOVWF 040015: MOVF 00,W0016: BTFSC 03.20017: GOTO 0280018: MOVLW 050019: MOVWF 78001A: MOVLW BF001B: MOVWF 77001C: CLRWDT001D: DECFSZ 77,F001E: GOTO 01C001F: DECFSZ 78,F0020: GOTO 01A0021: MOVLW F90022: MOVWF 770023: DECFSZ 77,F0024: GOTO 0230025: CLRWDT0026: DECFSZ 00,F0027: GOTO 0180028: RETLW 00.................... #use rs232(STREAM=MOBIL,baud=19200,force_sw,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)*006B: MOVLW FF006C: BCF 03.5006D: MOVWF 20.................... #use rs232(STREAM=VRTULE,baud=600,parity=N,xmit=PIN_B2,rcv=PIN_B4,bits=8)*0029: BSF 03.5002A: BCF 06.2002B: BCF 03.5002C: BCF 06.2002D: MOVLW 08002E: MOVWF 78002F: NOP0030: NOP0031: NOP0032: BSF 78.70033: GOTO 0430034: BCF 78.70035: RRF 52,F0036: BTFSC 03.00037: BSF 06.20038: BTFSS 03.00039: BCF 06.2003A: BSF 78.6003B: GOTO 043003C: BCF 78.6003D: DECFSZ 78,F003E: GOTO 035003F: NOP0040: NOP0041: NOP0042: BSF 06.20043: MOVLW 090044: MOVWF 770045: CLRF 040046: DECFSZ 04,F0047: GOTO 0460048: DECFSZ 77,F0049: GOTO 045004A: MOVLW F0004B: MOVWF 04004C: DECFSZ 04,F004D: GOTO 04C004E: NOP004F: NOP0050: BTFSC 78.70051: GOTO 0340052: BTFSC 78.60053: GOTO 03C0054: BCF 0A.30055: BCF 0A.40056: GOTO 102 (RETURN)................................................................................ #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;.................... 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;*006E: 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;.................... char sign;.................... char digits[]="0123456789abcdefghijklmnopqstuvwxyz";.................... for(sc=s;isspace(*sc);++sc);.................... sign=*sc=='-'||*sc=='+'?*sc++:'+';.................... if(sign=='-').................... {.................... if (endptr).................... {.................... *((char *)endptr)=s;.................... }.................... return 0;.................... }........................................ 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 (endptr).................... *((char *)endptr)=sc;.................... return x;.................... }............................................................ signed long strtol(char *s,char *endptr,signed int base).................... {.................... char *sc,*s1,*sd;.................... signed long x=0;.................... char sign;.................... char digits[]="0123456789abcdefghijklmnopqstuvwxyz";.................... for(sc=s;isspace(*sc);++sc);.................... sign=*sc=='-'||*sc=='+'?*sc++:'+';.................... if (base <0 || base ==1|| base >36) // invalid base.................... {.................... 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;006F: MOVLW 010070: MOVWF 220071: CLRF 230072: CLRF 240073: 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).................... while(fgetc(MOBIL)!=0x0A); // predkoc prvni radek odpovedi.................... odp[0]=fgetc(MOBIL); // Nacti prvni dva znaky druheho radku odpovedi.................... odp[1]=fgetc(MOBIL);.................... while(fgetc(MOBIL)!=0x0A); // Preskoc zbytek radku........................................ if(odp[0] == 'O' && odp[1] == 'K') return 1;.................... else return 0;.................... }........................................ read_sms().................... {.................... int pom,pom2,pom3,odkl,odkl2,maskovadlo;.................... for(pom=0;pom<54;pom++) //preskoc nedulezite informace.................... {.................... fgetc(MOBIL);.................... }........................................ //gets(odp); //uloz zakodovany text SMS........................................ odp[0]=fgetc(MOBIL);.................... odp[1]=fgetc(MOBIL);.................... odp[2]=fgetc(MOBIL);.................... odp[3]=fgetc(MOBIL);.................... odp[4]=fgetc(MOBIL);.................... odp[5]=fgetc(MOBIL);.................... odp[6]=fgetc(MOBIL);.................... odp[7]=fgetc(MOBIL);........................................ /*lcd_gotoxy(1,1);.................... printf(lcd_putc,"\f%s\n",odp);*/........................................ if(odp[0]==0) odp[1]='0'; // Prevod z ASCII do BIN.................... odp[0]=odp[0] - '0';.................... odp[1]=odp[1] - '0';.................... if(odp[0]>9) odp[0]=odp[0]-7;.................... if(odp[1]>9) odp[1]=odp[1]-7;.................... odp[0]=odp[0] << 4;.................... odp[0] |= odp[1];........................................ if(odp[2]==0) odp[3]='0';.................... odp[2]=odp[2] - '0';.................... odp[3]=odp[3] - '0';.................... if(odp[2]>9) odp[2]=odp[2]-7;.................... if(odp[3]>9) odp[3]=odp[3]-7;.................... odp[2]=odp[2] << 4;.................... odp[2] |= odp[3];........................................ if(odp[4]==0) odp[5]='0';.................... odp[4]=odp[4] - '0';.................... odp[5]=odp[5] - '0';.................... if(odp[4]>9) odp[4]=odp[4]-7;.................... if(odp[5]>9) odp[5]=odp[5]-7;.................... odp[4]=odp[4] << 4;.................... odp[4] |= odp[5];........................................ if(odp[6]==0) odp[7]='0';.................... odp[6]=odp[6] - '0';.................... odp[7]=odp[7] - '0';.................... if(odp[6]>9) odp[6]=odp[6]-7;.................... if(odp[7]>9) odp[7]=odp[7]-7;.................... odp[6]=odp[6] << 4;.................... odp[6] |= odp[7];........................................ odp[1]=odp[2];.................... odp[2]=odp[4];.................... odp[3]=odp[6];.................... odp[4]=odp[5]=odp[6]=0;........................................ /*lcd_gotoxy(1,2);.................... printf(lcd_putc,"%u %u %u %u",odp[0],odp[1],odp[2]odp[3]); */........................................ pom3=0;.................... for (pom = 0; pom < 4;pom++).................... {.................... maskovadlo = maskovadlo >> 1; //rotace promene urcene pro maskovani.................... maskovadlo = maskovadlo | 0x80;.................... odkl = odp[pom] & maskovadlo; //odlozeni "prenosu" do odkl pomoci maskovadla.................... odp[pom] = odp[pom] << pom3; //rotace znaku.................... for (pom2 = 0; pom2 < (8-pom3);pom2++) //rotace odkl2.................... {.................... odkl2 = odkl2 >> 1;.................... odkl2 = odkl2 & 127;.................... }.................... odp[pom] = odp[pom] | odkl2; //pridani odkl2 ke znaku.................... odp[pom] = odp[pom] & 127; //smazani nejvysiho bitu.................... odkl2 = odkl; //ulozeni odlk na dalsi pruchod.................... pom3++; //inkrementace citace rotace.................... if (pom3 == 8) //kazdy 8my znak.................... {.................... pom3 = 0; //smaz citac.................... odp[pom+1] = odkl2; //uloz 8my znak vznikly z "prenosu".................... maskovadlo = 0; //smaz maskovadlo.................... }.................... }.................... odp[pom]='\0';.................... }........................................ void read_time().................... {.................... unsigned int8 n;............................................................ fprintf(MOBIL,"AT+CCLK?\r");.................... while(fgetc(MOBIL)!='"');.................... for(n=0;n<12;n++) //preskoc nedulezite informace.................... {.................... fgetc(MOBIL);.................... }.................... odp[0]=fgetc(MOBIL);.................... odp[1]=fgetc(MOBIL);.................... odp[2]=0;.................... }........................................ void del_sms().................... {.................... fprintf(MOBIL,"AT+CMGD=1\r"); //smaz prijatou SMSku.................... }........................................ void main().................... {*0057: CLRF 040058: MOVLW 1F0059: ANDWF 03,F005A: BCF 20.6005B: MOVF 20,W005C: BSF 03.5005D: MOVWF 07005E: BCF 03.5005F: BSF 07.60060: BSF 03.50061: BCF 06.20062: BCF 03.50063: BSF 06.20064: BSF 03.50065: BSF 1F.00066: BSF 1F.10067: BSF 1F.20068: BCF 1F.30069: MOVLW 07006A: MOVWF 1C.................... setup_adc_ports(NO_ANALOGS);*0074: BSF 03.50075: BSF 1F.00076: BSF 1F.10077: BSF 1F.20078: BCF 1F.3.................... setup_adc(ADC_OFF);0079: BCF 03.5007A: BCF 1F.0.................... setup_spi(SPI_SS_DISABLED);007B: BCF 14.5007C: BCF 20.5007D: MOVF 20,W007E: BSF 03.5007F: MOVWF 070080: BCF 03.50081: BSF 20.40082: MOVF 20,W0083: BSF 03.50084: MOVWF 070085: BCF 03.50086: BCF 20.30087: MOVF 20,W0088: BSF 03.50089: MOVWF 07008A: MOVLW 01008B: BCF 03.5008C: MOVWF 14008D: MOVLW 00008E: BSF 03.5008F: MOVWF 14.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);0090: MOVF 01,W0091: ANDLW C70092: IORLW 080093: MOVWF 01.................... setup_timer_1(T1_DISABLED);0094: BCF 03.50095: CLRF 10.................... setup_timer_2(T2_DIV_BY_4,255,1);0096: MOVLW 000097: MOVWF 780098: IORLW 050099: MOVWF 12009A: MOVLW FF009B: BSF 03.5009C: MOVWF 12.................... setup_ccp1(CCP_PWM);009D: BCF 03.5009E: BCF 20.2009F: MOVF 20,W00A0: BSF 03.500A1: MOVWF 0700A2: BCF 03.500A3: BCF 07.200A4: MOVLW 0C00A5: MOVWF 17.................... setup_ccp2(CCP_PWM);00A6: BCF 20.100A7: MOVF 20,W00A8: BSF 03.500A9: MOVWF 0700AA: BCF 03.500AB: BCF 07.100AC: MOVLW 0C00AD: MOVWF 1D.................... setup_comparator(NC_NC_NC_NC);00AE: MOVLW 0700AF: BSF 03.500B0: MOVWF 1C00B1: MOVF 05,W00B2: CLRWDT00B3: MOVLW 0E00B4: MOVWF 7700B5: DECFSZ 77,F00B6: GOTO 0B500B7: NOP00B8: NOP00B9: MOVF 1C,W00BA: BCF 03.500BB: BCF 0D.6.................... setup_vref(FALSE);00BC: BSF 03.500BD: CLRF 1D.................... setup_wdt(WDT_2304MS);00BE: MOVLW 0F00BF: MOVWF 7700C0: MOVLW 0700C1: BCF 03.500C2: CLRF 0100C3: MOVLW 8100C4: MOVWF 0400C5: MOVF 00,W00C6: ANDLW F000C7: IORLW 0700C8: MOVWF 0000C9: CLRWDT00CA: MOVF 00,W00CB: ANDLW F700CC: BTFSC 77.300CD: ANDLW F000CE: IORWF 77,W00CF: MOVWF 00........................................ set_pwm1_duty(0);00D0: CLRF 15.................... set_pwm2_duty(0);00D1: CLRF 1B........................................ while(TRUE).................... {.................... int status;.................... char *ptr;.................... int time;........................................ restart_wdt();00D2: CLRWDT........................................ output_low(PIN_A4) ;00D3: BSF 03.500D4: BCF 05.400D5: BCF 03.500D6: BCF 05.4.................... delay_ms(150);00D7: MOVLW 9600D8: MOVWF 5200D9: CALL 013.................... output_high(PIN_A4);00DA: BSF 03.500DB: BCF 05.400DC: BCF 03.500DD: BSF 05.4.................... delay_ms(150);00DE: MOVLW 9600DF: MOVWF 5200E0: CALL 013.................... output_low(PIN_A4) ;00E1: BSF 03.500E2: BCF 05.400E3: BCF 03.500E4: BCF 05.4.................... delay_ms(150);00E5: MOVLW 9600E6: MOVWF 5200E7: CALL 013.................... output_high(PIN_A4);00E8: BSF 03.500E9: BCF 05.400EA: BCF 03.500EB: BSF 05.4.................... delay_ms(150);00EC: MOVLW 9600ED: MOVWF 5200EE: CALL 013............................................................ set_pwm1_duty(500);00EF: MOVLW 7D00F0: MOVWF 1500F1: MOVF 17,W00F2: ANDLW CF00F3: MOVWF 17.................... set_pwm2_duty(500);00F4: MOVLW 7D00F5: MOVWF 1B00F6: MOVF 1D,W00F7: ANDLW CF00F8: MOVWF 1D........................................ fprintf(VRTULE,"ABABABABAB");00F9: CLRF 5100FA: MOVF 51,W00FB: CALL 00400FC: IORLW 0000FD: BTFSC 03.200FE: GOTO 10300FF: INCF 51,F0100: MOVWF 520101: GOTO 0290102: GOTO 0FA........................................ Delay_ms(5000);0103: MOVLW 140104: MOVWF 510105: MOVLW FA0106: MOVWF 520107: CALL 0130108: DECFSZ 51,F0109: GOTO 105............................................................ /* if(check_new_sms()) // Je odpoved "OK"?.................... {.................... // printf(lcd_putc,"736 655 250");.................... delay_ms(1000);.................... }.................... else.................... {.................... read_sms();........................................ if (odp[0] == 'A' || odp[0] == 'a').................... {.................... set_pwm1_duty(500);.................... set_pwm2_duty(500);.................... Delay_ms(5000);.................... fprintf(VRTULE,"ABABABABAB");.................... Delay_ms(20000);.................... set_pwm1_duty(0);.................... set_pwm2_duty(0);.................... }........................................ if (odp[0] == 118 && odp[1] == 121 && odp[2] == 112 && odp[3]== 49).................... {.................... fprintf(VRTULE,"");.................... }........................................ if (odp[0] == 97 && odp[1] == 104 && odp[2] == 111 && odp[3]== 106).................... {.................... fprintf(VRTULE,"");.................... }.................... }.................... /* read_time();.................... time=strtoul(odp,&ptr,10);.................... if((time >= 30 && time <= 35) || (time >= 0 && time <= 5)).................... {.................... set_pwm1_duty(500);.................... set_pwm2_duty(500);.................... }.................... else.................... {.................... set_pwm1_duty(0);.................... set_pwm2_duty(0);.................... }*/........................................ delay_ms(1000);010A: MOVLW 04010B: MOVWF 51010C: MOVLW FA010D: MOVWF 52010E: CALL 013010F: DECFSZ 51,F0110: GOTO 10C.................... }0111: GOTO 0D2.................... }0112: SLEEPConfiguration Fuses:Word 1: 3F3A HS NOWDT NOPUT NODEBUG NOPROTECT NOBROWNOUT NOLVP NOCPD NOWRT