Rev 410 | Blame | Compare with Previous | Last modification | View Log | Download
CCS PCM C Compiler, Version 3.221, 27853 12-III-06 16:36Filename: D:\KAKLIK\programy\PIC_C\hack\hack.LSTROM used: 1587 words (41%)Largest free fragment is 1792RAM used: 41 (11%) at main() level51 (14%) worst caseStack: 3 worst case (2 in main + 1 for interrupts)*0000: NOP0001: MOVLW 000002: MOVWF 0A0003: GOTO 3420004: MOVWF 7F0005: SWAPF 03,W0006: CLRF 030007: MOVWF 210008: MOVF 7F,W0009: MOVWF 20000A: MOVF 0A,W000B: MOVWF 28000C: CLRF 0A000D: SWAPF 20,F000E: MOVF 04,W000F: MOVWF 220010: MOVF 77,W0011: MOVWF 230012: MOVF 78,W0013: MOVWF 240014: MOVF 79,W0015: MOVWF 250016: MOVF 7A,W0017: MOVWF 260018: MOVF 7B,W0019: MOVWF 27001A: BCF 03.7001B: BCF 03.5001C: MOVLW 8C001D: MOVWF 04001E: BTFSS 00.0001F: GOTO 0220020: BTFSC 0C.00021: GOTO 03B0022: MOVLW 8C0023: MOVWF 040024: BTFSS 00.10025: GOTO 0280026: BTFSC 0C.10027: GOTO 03D0028: MOVF 22,W0029: MOVWF 04002A: MOVF 23,W002B: MOVWF 77002C: MOVF 24,W002D: MOVWF 78002E: MOVF 25,W002F: MOVWF 790030: MOVF 26,W0031: MOVWF 7A0032: MOVF 27,W0033: MOVWF 7B0034: MOVF 28,W0035: MOVWF 0A0036: SWAPF 21,W0037: MOVWF 030038: SWAPF 7F,F0039: SWAPF 7F,W003A: RETFIE003B: BCF 0A.3003C: GOTO 0E0003D: BCF 0A.3003E: GOTO 0E3.................... #include ".\hack.h".................... #include <16F88.h>.................... //////// Standard Header file for the PIC16F88 device ////////////////.................... #device PIC16F88.................... #list........................................ #device *=16.................... #device ICD=TRUE.................... #device adc=8.................... #fuses NOWDT,INTRC , NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, DEBUG, NOPROTECT, NOFCMEN, NOIESO.................... //#fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, DEBUG, NOPROTECT, NOFCMEN, NOIESO.................... #use delay(clock=4000000,RESTART_WDT)*00E6: MOVLW 4200E7: MOVWF 0400E8: BCF 03.700E9: MOVF 00,W00EA: BTFSC 03.200EB: GOTO 0FD00EC: MOVLW 0100ED: MOVWF 7800EE: MOVLW BF00EF: MOVWF 7700F0: CLRWDT00F1: DECFSZ 77,F00F2: GOTO 0F000F3: DECFSZ 78,F00F4: GOTO 0EE00F5: MOVLW 4A00F6: MOVWF 7700F7: DECFSZ 77,F00F8: GOTO 0F700F9: NOP00FA: CLRWDT00FB: DECFSZ 00,F00FC: GOTO 0EC00FD: RETLW 00.................... //#use rs232(baud=2400,xmit=PIN_B3).................... //#use rs232(DEBUGGER).................... #use rs232(baud=1200,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8)00FE: BSF 03.500FF: BCF 06.30100: BCF 03.50101: BCF 06.30102: MOVLW 080103: MOVWF 780104: NOP0105: NOP0106: NOP0107: BSF 78.70108: GOTO 1180109: BCF 78.7010A: RRF 4C,F010B: BTFSC 03.0010C: BSF 06.3010D: BTFSS 03.0010E: BCF 06.3010F: BSF 78.60110: GOTO 1180111: BCF 78.60112: DECFSZ 78,F0113: GOTO 10A0114: NOP0115: NOP0116: NOP0117: BSF 06.30118: MOVLW 010119: MOVWF 77011A: CLRF 04011B: DECFSZ 04,F011C: GOTO 11B011D: DECFSZ 77,F011E: GOTO 11A011F: MOVLW 0D0120: MOVWF 040121: DECFSZ 04,F0122: GOTO 1210123: NOP0124: NOP0125: BTFSC 78.70126: GOTO 1090127: BTFSC 78.60128: GOTO 1110129: RETLW 00012A: MOVF 04,W012B: MOVWF 78012C: MOVLW 08012D: MOVWF 77012E: BSF 03.5012F: BSF 06.20130: BCF 03.50131: BTFSS 06.20132: GOTO 1350133: BSF 03.50134: GOTO 1300135: CLRF 410136: BSF 77.70137: GOTO 1480138: BCF 77.70139: GOTO 148013A: BCF 03.0013B: BTFSC 06.2013C: BSF 03.0013D: RRF 41,F013E: BSF 77.6013F: GOTO 1480140: BCF 77.60141: DECFSZ 77,F0142: GOTO 13A0143: MOVF 78,W0144: MOVWF 040145: MOVF 41,W0146: MOVWF 780147: GOTO 15D0148: MOVLW 010149: MOVWF 04014A: MOVLW 00014B: BTFSC 77.7014C: MOVLW 55014D: MOVWF 78014E: DECFSZ 78,F014F: GOTO 14E0150: DECFSZ 04,F0151: GOTO 14A0152: MOVLW 0D0153: BTFSC 77.70154: MOVLW 030155: MOVWF 780156: DECFSZ 78,F0157: GOTO 1560158: BTFSC 77.70159: GOTO 138015A: BTFSC 77.6015B: GOTO 140015C: GOTO 13A015D: BCF 0A.3015E: GOTO 3C1 (RETURN)............................................................ #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: 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);........................................ /* Standard template: signed long atol(char * s).................... * converts the initial portion of the string s to a signed long.................... * returns the converted value if any, 0 otherwise.................... */.................... signed long atol(char *s);........................................ /* Standard template: float strtol(char * s,char *endptr).................... * converts the initial portion of the string s to a float.................... * returns the converted value if any, 0 otherwise.................... * the final string is returned in the endptr, if endptr is not null.................... */.................... float strtod(char *s,char *endptr);........................................ /* Standard template: long strtoul(char * s,char *endptr,signed int base).................... * converts the initial portion of the string s, represented as an.................... * integral value of radix base to a signed long..................... * Returns the converted value if any, 0 otherwise.................... * the final string is returned in the endptr, if endptr is not null.................... */.................... signed long strtol(char *s,char *endptr,signed int base);........................................ /* Standard template: long strtoul(char * s,char *endptr,signed int base).................... * converts the initial portion of the string s, represented as an.................... * integral value of radix base to a unsigned long..................... * returns the converted value if any, 0 otherwise.................... * the final string is returned in the endptr, if endptr is not null.................... */.................... long strtoul(char *s,char *endptr,signed int base);........................................ //---------------------------------------------------------------------------.................... // Pseudo-random sequence generation functions.................... //---------------------------------------------------------------------------........................................ /* The rand function computes a sequence of pseudo-random integers in.................... * the range 0 to RAND_MAX.................... *.................... * Parameters:.................... * (none).................... *.................... * Returns:.................... * The pseudo-random integer.................... */.................... long rand(void);........................................ /* The srand function uses the argument as a seed for a new sequence of.................... * pseudo-random numbers to be returned by subsequent calls to rand..................... *.................... * Parameters:.................... * [in] seed: The seed value to start from. You might need to pass.................... *.................... * Returns:.................... * (none).................... *.................... * Remarks.................... * The srand function sets the starting point for generating.................... * a series of pseudorandom integers. To reinitialize the.................... * generator, use 1 as the seed argument. Any other value for.................... * seed sets the generator to a random starting point. rand.................... * retrieves the pseudorandom numbers that are generated..................... * Calling rand before any call to srand generates the same.................... * sequence as calling srand with seed passed as 1..................... * Usually, you need to pass a time here from outer source.................... * so that the numbers will be different every time you run..................... */.................... void srand(unsigned int32 seed);........................................ //---------------------------------------------------------------------------.................... // Memory management functions.................... //---------------------------------------------------------------------------........................................ // Comming soon........................................ //---------------------------------------------------------------------------.................... // Communication with the environment.................... //---------------------------------------------------------------------------........................................ /* The function returns 0 always.................... */.................... signed int system(char *string);........................................ //---------------------------------------------------------------------------.................... // Searching and sorting utilities.................... //---------------------------------------------------------------------------........................................ /* Performs a binary search of a sorted array...................... *.................... * Parameters:.................... * [in] key: Object to search for.................... * [in] base: Pointer to base of search data.................... * [in] num: Number of elements.................... * [in] width: Width of elements.................... * [in] compare: Function that compares two elements.................... *.................... * Returns:.................... * bsearch returns a pointer to an occurrence of key in the array pointed.................... * to by base. If key is not found, the function returns NULL. If the.................... * array is not in order or contains duplicate records with identical keys,.................... * the result is unpredictable..................... */.................... //void *bsearch(const void *key, const void *base, size_t num, size_t width,.................... // int (*compare)(const void *, const void *));........................................ /* Performs the shell-metzner sort (not the quick sort algorithm). The contents.................... * of the array are sorted into ascending order according to a comparison.................... * function pointed to by compar..................... *.................... * Parameters:.................... * [in] base: Pointer to base of search data.................... * [in] num: Number of elements.................... * [in] width: Width of elements.................... * [in] compare: Function that compares two elements.................... *.................... * Returns:.................... * (none).................... */.................... //void *qsort(const void *base, size_t num, size_t width,.................... // int (*compare)(const void *, const void *));........................................ //---------------------------------------------------------------------------.................... // Integer arithmetic functions.................... //---------------------------------------------------------------------------........................................ #define labs abs........................................ div_t div(signed int numer,signed int denom);.................... ldiv_t ldiv(signed long numer,signed long denom);........................................ //---------------------------------------------------------------------------.................... // Multibyte character functions.................... //---------------------------------------------------------------------------........................................ // Not supported........................................ //---------------------------------------------------------------------------.................... // Multibyte string functions.................... //---------------------------------------------------------------------------........................................ // Not supported............................................................ //---------------------------------------------------------------------------.................... // Internal implementation.................... //---------------------------------------------------------------------------........................................ #include <stddef.h>.................... ///////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2003 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ///////////////////////////////////////////////////////////////////////////........................................ #ifndef _STDDEF........................................ #define _STDDEF........................................ #if sizeof(int *)==1.................... #define ptrdiff_t int.................... #else.................... #define ptrdiff_t long.................... #endif........................................ #define size_t int.................... #define wchar_t char.................... #define NULL 0........................................ #define offsetof(s,f) (offsetofbit(s,f)/8)........................................ #endif........................................ #include <string.h>.................... ////////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2003 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ////////////////////////////////////////////////////////////////////////////........................................ #ifndef _STRING.................... #define _STRING.................... #include <stddef.h>.................... ///////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2003 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ///////////////////////////////////////////////////////////////////////////........................................ #ifndef _STDDEF........................................ #define _STDDEF........................................ #if sizeof(int *)==1.................... #define ptrdiff_t int.................... #else.................... #define ptrdiff_t long.................... #endif........................................ #define size_t int.................... #define wchar_t char.................... #define NULL 0........................................ #define offsetof(s,f) (offsetofbit(s,f)/8)........................................ #endif........................................ #include <ctype.h>.................... ////////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2003 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ////////////////////////////////////////////////////////////////////////////........................................ #ifndef _CTYPE.................... #define _CTYPE........................................ #define islower(x) isamong(x,"abcdefghijklmnopqrstuvwxyz").................... #define isupper(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZ").................... #define isalnum(x) isamong(x,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").................... #define isalpha(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").................... #define isdigit(x) isamong(x,"0123456789").................... #define isspace(x) (x==' ').................... #define isxdigit(x) isamong(x,"0123456789ABCDEFabcdef").................... #define iscntrl(x) (x<' ').................... #define isprint(x) (x>=' ').................... #define isgraph(x) (x>' ').................... #define ispunct(x) ((x>' ')&&!isalnum(x))........................................ #endif........................................................................................................................ //////////////////////////////////////////////.................... //// Uncomment the following define to ////.................... //// allow some functions to use a ////.................... //// quicker algorithm, but use more ROM ////.................... //// ////.................... //// #define FASTER_BUT_MORE_ROM ////.................... //////////////////////////////////////////////................................................................................ /*Copying functions*/.................... /* standard template:.................... void *memmove(void *s1, void *s2, size_t n)..................... Copies max of n characters safely (not following ending '\0').................... from s2 in s1; if s2 has less than n characters, appends 0 */........................................ char *memmove(void *s1,char *s2,size_t n).................... {.................... char *sc1;.................... char *sc2;.................... sc1=s1;.................... sc2=s2;.................... if(sc2<sc1 && sc1 <sc2 +n).................... for(sc1+=n,sc2+=n;0<n;--n).................... *--sc1=*--sc2;.................... else.................... for(;0<n;--n).................... *sc1++=*sc2++;.................... return s1;.................... }........................................ /* compiler ignored the name 'strcpy()'; perhaps, it's reserved?.................... Standard template: char *strcpy(char *s1, const char *s2).................... copies the string s2 including the null character to s1*/........................................ char *strcopy(char *s1, char *s2).................... {.................... char *s;........................................ for (s = s1; *s2 != 0; s++, s2++) {.................... *s = *s2;.................... }.................... *s = *s2;.................... return(s1);.................... }........................................ /* standard template:.................... char *strncpy(char *s1, const char *s2, size_t n)..................... Copies max of n characters (not following ending '\0').................... from s2 in s1; if s2 has less than n characters, appends 0 */........................................ char *strncpy(char *s1, char *s2, size_t n).................... {.................... char *s;........................................ for (s = s1; n > 0 && *s2 != '\0'; n--).................... *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;*0359: CLRF 29035A: CLRF 2A........................................ 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);.................... }........................................ 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;*0242: CLRF 47.................... sign = 0;0243: CLRF 45.................... base = 10;0244: MOVLW 0A0245: MOVWF 46.................... result = 0;0246: CLRF 440247: CLRF 43........................................ if (!s)0248: MOVF 41,W0249: IORWF 42,W024A: BTFSS 03.2024B: GOTO 250.................... return 0;024C: MOVLW 00024D: MOVWF 78024E: MOVWF 79024F: GOTO 341.................... c = s[index++];0250: MOVF 47,W0251: INCF 47,F0252: ADDWF 41,W0253: MOVWF 040254: BCF 03.70255: BTFSC 42.00256: BSF 03.70257: MOVF 00,W0258: MOVWF 48........................................ // increase index if either positive or negative sign is detected.................... if (c == '-')0259: MOVF 48,W025A: SUBLW 2D025B: BTFSS 03.2025C: GOTO 269.................... {.................... sign = 1; // Set the sign to negative025D: MOVLW 01025E: MOVWF 45.................... c = s[index++];025F: MOVF 47,W0260: INCF 47,F0261: ADDWF 41,W0262: MOVWF 040263: BCF 03.70264: BTFSC 42.00265: BSF 03.70266: MOVF 00,W0267: MOVWF 48.................... }.................... else if (c == '+')0268: GOTO 2760269: MOVF 48,W026A: SUBLW 2B026B: BTFSS 03.2026C: GOTO 276.................... {.................... c = s[index++];026D: MOVF 47,W026E: INCF 47,F026F: ADDWF 41,W0270: MOVWF 040271: BCF 03.70272: BTFSC 42.00273: BSF 03.70274: MOVF 00,W0275: MOVWF 48.................... }........................................ if (c >= '0' && c <= '9')0276: MOVF 48,W0277: SUBLW 2F0278: BTFSC 03.00279: GOTO 332027A: MOVF 48,W027B: SUBLW 39027C: BTFSS 03.0027D: GOTO 332.................... {.................... if (c == '0' && (s[index] == 'x' || s[index] == 'X'))027E: MOVF 48,W027F: SUBLW 300280: BTFSS 03.20281: GOTO 2A20282: MOVF 47,W0283: ADDWF 41,W0284: MOVWF 040285: BCF 03.70286: BTFSC 42.00287: BSF 03.70288: MOVF 00,W0289: SUBLW 78028A: BTFSC 03.2028B: GOTO 296028C: MOVF 47,W028D: ADDWF 41,W028E: MOVWF 04028F: BCF 03.70290: BTFSC 42.00291: BSF 03.70292: MOVF 00,W0293: SUBLW 580294: BTFSS 03.20295: GOTO 2A2.................... {.................... base = 16;0296: MOVLW 100297: MOVWF 46.................... index++;0298: INCF 47,F.................... c = s[index++];0299: MOVF 47,W029A: INCF 47,F029B: ADDWF 41,W029C: MOVWF 04029D: BCF 03.7029E: BTFSC 42.0029F: BSF 03.702A0: MOVF 00,W02A1: MOVWF 48.................... }........................................ // The number is a decimal number.................... if (base == 10)02A2: MOVF 46,W02A3: SUBLW 0A02A4: BTFSS 03.202A5: GOTO 2C9.................... {.................... while (c >= '0' && c <= '9').................... {02A6: MOVF 48,W02A7: SUBLW 2F02A8: BTFSC 03.002A9: GOTO 2C802AA: MOVF 48,W02AB: SUBLW 3902AC: BTFSS 03.002AD: GOTO 2C8.................... result = 10*result + (c - '0');02AE: CLRF 4A02AF: MOVLW 0A02B0: MOVWF 4902B1: MOVF 44,W02B2: MOVWF 4C02B3: MOVF 43,W02B4: MOVWF 4B02B5: GOTO 22C02B6: MOVLW 3002B7: SUBWF 48,W02B8: ADDWF 78,W02B9: MOVWF 4302BA: MOVF 79,W02BB: MOVWF 4402BC: BTFSC 03.002BD: INCF 44,F.................... c = s[index++];02BE: MOVF 47,W02BF: INCF 47,F02C0: ADDWF 41,W02C1: MOVWF 0402C2: BCF 03.702C3: BTFSC 42.002C4: BSF 03.702C5: MOVF 00,W02C6: MOVWF 48.................... }02C7: GOTO 2A6.................... }.................... else if (base == 16) // The number is a hexa number02C8: GOTO 33202C9: MOVF 46,W02CA: SUBLW 1002CB: BTFSS 03.202CC: GOTO 332.................... {.................... c = toupper(c);02CD: MOVF 48,W02CE: SUBLW 6002CF: BTFSC 03.002D0: GOTO 2D802D1: MOVF 48,W02D2: SUBLW 7A02D3: BTFSS 03.002D4: GOTO 2D802D5: MOVF 48,W02D6: ANDLW DF02D7: GOTO 2D902D8: MOVF 48,W02D9: MOVWF 48.................... while ( (c >= '0' && c <= '9') || (c >= 'A' && c <='F')).................... {02DA: MOVF 48,W02DB: SUBLW 2F02DC: BTFSC 03.002DD: GOTO 2E202DE: MOVF 48,W02DF: SUBLW 3902E0: BTFSC 03.002E1: GOTO 2EA02E2: MOVF 48,W02E3: SUBLW 4002E4: BTFSC 03.002E5: GOTO 33202E6: MOVF 48,W02E7: SUBLW 4602E8: BTFSS 03.002E9: GOTO 332.................... if (c >= '0' && c <= '9')02EA: MOVF 48,W02EB: SUBLW 2F02EC: BTFSC 03.002ED: GOTO 30702EE: MOVF 48,W02EF: SUBLW 3902F0: BTFSS 03.002F1: GOTO 307.................... result = (result << 4) + (c - '0');02F2: RLF 43,W02F3: MOVWF 4902F4: RLF 44,W02F5: MOVWF 4A02F6: RLF 49,F02F7: RLF 4A,F02F8: RLF 49,F02F9: RLF 4A,F02FA: RLF 49,F02FB: RLF 4A,F02FC: MOVLW F002FD: ANDWF 49,F02FE: MOVLW 3002FF: SUBWF 48,W0300: ADDWF 49,W0301: MOVWF 430302: MOVF 4A,W0303: MOVWF 440304: BTFSC 03.00305: INCF 44,F.................... else0306: GOTO 31C.................... result = (result << 4) + (c - 'A' + 10);0307: RLF 43,W0308: MOVWF 490309: RLF 44,W030A: MOVWF 4A030B: RLF 49,F030C: RLF 4A,F030D: RLF 49,F030E: RLF 4A,F030F: RLF 49,F0310: RLF 4A,F0311: MOVLW F00312: ANDWF 49,F0313: MOVLW 410314: SUBWF 48,W0315: ADDLW 0A0316: ADDWF 49,W0317: MOVWF 430318: MOVF 4A,W0319: MOVWF 44031A: BTFSC 03.0031B: INCF 44,F........................................ c = s[index++];c = toupper(c);031C: MOVF 47,W031D: INCF 47,F031E: ADDWF 41,W031F: MOVWF 040320: BCF 03.70321: BTFSC 42.00322: BSF 03.70323: MOVF 00,W0324: MOVWF 480325: SUBLW 600326: BTFSC 03.00327: GOTO 32F0328: MOVF 48,W0329: SUBLW 7A032A: BTFSS 03.0032B: GOTO 32F032C: MOVF 48,W032D: ANDLW DF032E: GOTO 330032F: MOVF 48,W0330: MOVWF 48.................... }0331: GOTO 2DA.................... }.................... }........................................ if (base == 10 && sign == 1)0332: MOVF 46,W0333: SUBLW 0A0334: BTFSS 03.20335: GOTO 33D0336: DECFSZ 45,W0337: GOTO 33D.................... result = -result;0338: COMF 43,F0339: COMF 44,F033A: INCF 43,F033B: BTFSC 03.2033C: INCF 44,F........................................ return(result);033D: MOVF 43,W033E: MOVWF 78033F: MOVF 44,W0340: MOVWF 79.................... }0341: RETLW 00........................................ /* 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);.................... }........................................ 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;*035B: MOVLW 01035C: MOVWF 2B035D: CLRF 2C035E: CLRF 2D035F: CLRF 2E........................................ 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 SYNC PIN_B4 // Spousteni oscyloskopu.................... #define HACK PIN_B5 // Zkratovani napajeni SmartCard.................... #define CLOCK PIN_B6 // Hodiny ze SmartCard........................................ #int_TIMER1.................... TIMER1_isr().................... {........................................ }....................*00E0: BCF 0C.000E1: BCF 0A.300E2: GOTO 028.................... #int_TIMER2.................... TIMER2_isr().................... {........................................ }....................00E3: BCF 0C.100E4: BCF 0A.300E5: GOTO 028.................... void main().................... {*0342: CLRF 040343: BCF 03.70344: MOVLW 1F0345: ANDWF 03,F0346: BSF 03.50347: BCF 1F.40348: BCF 1F.50349: MOVF 1B,W034A: ANDLW 80034B: MOVWF 1B034C: MOVLW 07034D: MOVWF 1C034E: MOVF 05,W034F: CLRWDT0350: MOVF 1C,W0351: BCF 03.50352: BCF 0D.60353: MOVLW 600354: BSF 03.50355: MOVWF 0F0356: BCF 06.30357: BCF 03.50358: BSF 06.3.................... unsigned int16 i;.................... char ch;.................... char string[10];.................... const char ver[]={"HACK v1.0\0"};.................... unsigned int16 prescale;.................... unsigned int16 ticks;.................... int n;........................................ setup_adc_ports(NO_ANALOGS|VSS_VDD);*0360: BSF 03.50361: BCF 1F.40362: BCF 1F.50363: MOVF 1B,W0364: ANDLW 800365: MOVWF 1B.................... setup_adc(ADC_OFF);0366: BCF 03.50367: BCF 1F.0.................... setup_spi(FALSE);0368: BCF 14.50369: BSF 03.5036A: BCF 06.2036B: BSF 06.1036C: BCF 06.4036D: MOVLW 00036E: BCF 03.5036F: MOVWF 140370: BSF 03.50371: MOVWF 14.................... setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);0372: MOVF 01,W0373: ANDLW C70374: IORLW 280375: MOVWF 01.................... setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);0376: MOVLW 870377: BCF 03.50378: MOVWF 10.................... // setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);.................... setup_timer_2(T2_DISABLED,0,1);0379: MOVLW 00037A: MOVWF 78037B: MOVWF 12037C: MOVLW 00037D: BSF 03.5037E: MOVWF 12.................... setup_comparator(NC_NC_NC_NC);037F: MOVLW 070380: MOVWF 1C0381: MOVF 05,W0382: CLRWDT0383: MOVLW 020384: MOVWF 770385: DECFSZ 77,F0386: GOTO 3850387: NOP0388: NOP0389: MOVF 1C,W038A: BCF 03.5038B: BCF 0D.6.................... setup_vref(FALSE);038C: BSF 03.5038D: CLRF 1D.................... // enable_interrupts(INT_TIMER1);.................... // enable_interrupts(INT_TIMER2);.................... // enable_interrupts(GLOBAL);........................................ setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator038E: MOVLW 62038F: MOVWF 0F........................................ delay_ms(100);0390: MOVLW 640391: BCF 03.50392: MOVWF 420393: CALL 0E6.................... printf("\n\r\n\r%s", ver);0394: CLRF 410395: MOVF 41,W0396: CALL 04E0397: INCF 41,F0398: MOVWF 770399: MOVWF 4C039A: CALL 0FE039B: MOVLW 04039C: SUBWF 41,W039D: BTFSS 03.2039E: GOTO 395039F: CLRF 4203A0: MOVF 42,W03A1: CALL 03F03A2: IORLW 0003A3: BTFSC 03.203A4: GOTO 3A903A5: INCF 42,F03A6: MOVWF 4C03A7: CALL 0FE03A8: GOTO 3A0.................... output_low(SYNC);03A9: BSF 03.503AA: BCF 06.403AB: BCF 03.503AC: BCF 06.4.................... output_low(HACK);03AD: BSF 03.503AE: BCF 06.503AF: BCF 03.503B0: BCF 06.5.................... ticks=1;03B1: CLRF 3F03B2: MOVLW 0103B3: MOVWF 3E.................... prescale=0;03B4: CLRF 3D03B5: CLRF 3C........................................ while(true).................... {.................... printf("\n\r>");03B6: MOVLW 0A03B7: MOVWF 4C03B8: CALL 0FE03B9: MOVLW 0D03BA: MOVWF 4C03BB: CALL 0FE03BC: MOVLW 3E03BD: MOVWF 4C03BE: CALL 0FE.................... n=0;03BF: CLRF 40.................... do.................... {.................... ch=getchar();03C0: GOTO 12A03C1: MOVF 78,W03C2: MOVWF 31.................... printf("%c",ch);03C3: MOVF 31,W03C4: MOVWF 4C03C5: CALL 0FE.................... string[n++]=ch;03C6: MOVF 40,W03C7: INCF 40,F03C8: ADDLW 3203C9: MOVWF 0403CA: BCF 03.703CB: MOVF 31,W03CC: MOVWF 00.................... } while((13 != ch) && (n < 10));03CD: MOVF 31,W03CE: SUBLW 0D03CF: BTFSC 03.203D0: GOTO 3D503D1: MOVF 40,W03D2: SUBLW 0903D3: BTFSC 03.003D4: GOTO 3C0.................... string[n]=0;03D5: MOVLW 3203D6: ADDWF 40,W03D7: MOVWF 0403D8: BCF 03.703D9: CLRF 00.................... printf("\n\r");03DA: MOVLW 0A03DB: MOVWF 4C03DC: CALL 0FE03DD: MOVLW 0D03DE: MOVWF 4C03DF: CALL 0FE.................... switch(string[0]).................... {03E0: MOVF 32,W03E1: XORLW 6703E2: BTFSC 03.203E3: GOTO 3F103E4: XORLW 1503E5: BTFSC 03.203E6: GOTO 46003E7: XORLW 1A03E8: BTFSC 03.203E9: GOTO 4E903EA: XORLW 0103EB: BTFSC 03.203EC: GOTO 57103ED: XORLW 1903EE: BTFSC 03.203EF: GOTO 5A803F0: GOTO 5EB.................... case 'g': // GO.................... printf("%Lue4 + %Lu GO", prescale, ticks);03F1: MOVLW 1003F2: MOVWF 0403F3: MOVF 3D,W03F4: MOVWF 4403F5: MOVF 3C,W03F6: MOVWF 4303F7: CALL 15F03F8: MOVLW 0303F9: MOVWF 4103FA: MOVF 41,W03FB: CALL 05903FC: INCF 41,F03FD: MOVWF 7703FE: MOVWF 4C03FF: CALL 0FE0400: MOVLW 080401: SUBWF 41,W0402: BTFSS 03.20403: GOTO 3FA0404: MOVLW 100405: MOVWF 040406: MOVF 3F,W0407: MOVWF 440408: MOVF 3E,W0409: MOVWF 43040A: CALL 15F040B: MOVLW 20040C: MOVWF 4C040D: CALL 0FE040E: MOVLW 47040F: MOVWF 4C0410: CALL 0FE0411: MOVLW 4F0412: MOVWF 4C0413: CALL 0FE.................... for(i=0; i<prescale; i++) { set_timer1(0); while ( get_timer1() < 10000 ) ; };0414: CLRF 300415: CLRF 2F0416: MOVF 30,W0417: SUBWF 3D,W0418: BTFSS 03.00419: GOTO 43C041A: BTFSS 03.2041B: GOTO 420041C: MOVF 3C,W041D: SUBWF 2F,W041E: BTFSC 03.0041F: GOTO 43C0420: CLRF 0F0421: CLRF 0E0422: MOVF 0F,W0423: MOVWF 7A0424: MOVF 0E,W0425: MOVWF 770426: MOVF 0F,W0427: SUBWF 7A,W0428: BTFSS 03.20429: GOTO 422042A: MOVF 77,W042B: MOVWF 41042C: MOVF 7A,W042D: MOVWF 42042E: MOVF 42,W042F: SUBLW 270430: BTFSS 03.00431: GOTO 4380432: BTFSS 03.20433: GOTO 4220434: MOVF 41,W0435: SUBLW 0F0436: BTFSC 03.00437: GOTO 4220438: INCF 2F,F0439: BTFSC 03.2043A: INCF 30,F043B: GOTO 416.................... set_timer1(0); while ( get_timer1() < ticks ) ;043C: CLRF 0F043D: CLRF 0E043E: MOVF 0F,W043F: MOVWF 7A0440: MOVF 0E,W0441: MOVWF 770442: MOVF 0F,W0443: SUBWF 7A,W0444: BTFSS 03.20445: GOTO 43E0446: MOVF 77,W0447: MOVWF 410448: MOVF 7A,W0449: MOVWF 42044A: MOVF 42,W044B: SUBWF 3F,W044C: BTFSS 03.0044D: GOTO 454044E: BTFSS 03.2044F: GOTO 43E0450: MOVF 3E,W0451: SUBWF 41,W0452: BTFSS 03.00453: GOTO 43E.................... output_high(SYNC);0454: BSF 03.50455: BCF 06.40456: BCF 03.50457: BSF 06.4.................... delay_ms(1);0458: MOVLW 010459: MOVWF 42045A: CALL 0E6.................... output_low(SYNC);045B: BSF 03.5045C: BCF 06.4045D: BCF 03.5045E: BCF 06.4.................... break;045F: GOTO 61A........................................ case 'r': // REPEAT.................... n=0;0460: CLRF 40.................... while(true).................... {.................... printf("%Lue4 + %Lu REPEAT %u\n\r", prescale, ticks, n++);0461: MOVF 40,W0462: INCF 40,F0463: MOVWF 410464: MOVLW 100465: MOVWF 040466: MOVF 3D,W0467: MOVWF 440468: MOVF 3C,W0469: MOVWF 43046A: CALL 15F046B: MOVLW 03046C: MOVWF 42046D: MOVF 42,W046E: CALL 06C046F: INCF 42,F0470: MOVWF 770471: MOVWF 4C0472: CALL 0FE0473: MOVLW 080474: SUBWF 42,W0475: BTFSS 03.20476: GOTO 46D0477: MOVLW 100478: MOVWF 040479: MOVF 3F,W047A: MOVWF 44047B: MOVF 3E,W047C: MOVWF 43047D: CALL 15F047E: MOVLW 0B047F: MOVWF 430480: MOVF 43,W0481: CALL 06C0482: INCF 43,F0483: MOVWF 770484: MOVWF 4C0485: CALL 0FE0486: MOVLW 130487: SUBWF 43,W0488: BTFSS 03.20489: GOTO 480048A: MOVF 41,W048B: MOVWF 44048C: MOVLW 18048D: MOVWF 45048E: GOTO 1DE048F: MOVLW 0A0490: MOVWF 4C0491: CALL 0FE0492: MOVLW 0D0493: MOVWF 4C0494: CALL 0FE.................... for(i=0; i<prescale; i++) { set_timer1(0); while ( get_timer1() < 10000 ) ; };0495: CLRF 300496: CLRF 2F0497: MOVF 30,W0498: SUBWF 3D,W0499: BTFSS 03.0049A: GOTO 4BD049B: BTFSS 03.2049C: GOTO 4A1049D: MOVF 3C,W049E: SUBWF 2F,W049F: BTFSC 03.004A0: GOTO 4BD04A1: CLRF 0F04A2: CLRF 0E04A3: MOVF 0F,W04A4: MOVWF 7A04A5: MOVF 0E,W04A6: MOVWF 7704A7: MOVF 0F,W04A8: SUBWF 7A,W04A9: BTFSS 03.204AA: GOTO 4A304AB: MOVF 77,W04AC: MOVWF 4104AD: MOVF 7A,W04AE: MOVWF 4204AF: MOVF 42,W04B0: SUBLW 2704B1: BTFSS 03.004B2: GOTO 4B904B3: BTFSS 03.204B4: GOTO 4A304B5: MOVF 41,W04B6: SUBLW 0F04B7: BTFSC 03.004B8: GOTO 4A304B9: INCF 2F,F04BA: BTFSC 03.204BB: INCF 30,F04BC: GOTO 497.................... set_timer1(0); while ( get_timer1() < ticks ) ;04BD: CLRF 0F04BE: CLRF 0E04BF: MOVF 0F,W04C0: MOVWF 7A04C1: MOVF 0E,W04C2: MOVWF 7704C3: MOVF 0F,W04C4: SUBWF 7A,W04C5: BTFSS 03.204C6: GOTO 4BF04C7: MOVF 77,W04C8: MOVWF 4104C9: MOVF 7A,W04CA: MOVWF 4204CB: MOVF 42,W04CC: SUBWF 3F,W04CD: BTFSS 03.004CE: GOTO 4D504CF: BTFSS 03.204D0: GOTO 4BF04D1: MOVF 3E,W04D2: SUBWF 41,W04D3: BTFSS 03.004D4: GOTO 4BF.................... output_high(SYNC);04D5: BSF 03.504D6: BCF 06.404D7: BCF 03.504D8: BSF 06.4.................... delay_ms(20);04D9: MOVLW 1404DA: MOVWF 4204DB: CALL 0E6.................... output_low(SYNC);04DC: BSF 03.504DD: BCF 06.404DE: BCF 03.504DF: BCF 06.4.................... delay_ms(2000);04E0: MOVLW 0804E1: MOVWF 4104E2: MOVLW FA04E3: MOVWF 4204E4: CALL 0E604E5: DECFSZ 41,F04E6: GOTO 4E2.................... };04E7: GOTO 461.................... break;04E8: GOTO 61A........................................ case 'h': // HACK.................... printf("%Lue4 + %Lu HACK", prescale, ticks);04E9: MOVLW 1004EA: MOVWF 0404EB: MOVF 3D,W04EC: MOVWF 4404ED: MOVF 3C,W04EE: MOVWF 4304EF: CALL 15F04F0: MOVLW 0304F1: MOVWF 4104F2: MOVF 41,W04F3: CALL 08804F4: INCF 41,F04F5: MOVWF 7704F6: MOVWF 4C04F7: CALL 0FE04F8: MOVLW 0804F9: SUBWF 41,W04FA: BTFSS 03.204FB: GOTO 4F204FC: MOVLW 1004FD: MOVWF 0404FE: MOVF 3F,W04FF: MOVWF 440500: MOVF 3E,W0501: MOVWF 430502: CALL 15F0503: MOVLW 0B0504: MOVWF 420505: MOVF 42,W0506: CALL 0880507: INCF 42,F0508: MOVWF 770509: MOVWF 4C050A: CALL 0FE050B: MOVLW 10050C: SUBWF 42,W050D: BTFSS 03.2050E: GOTO 505.................... for(i=0; i<prescale; i++) { set_timer1(0); while ( get_timer1() < 10000 ) ; };050F: CLRF 300510: CLRF 2F0511: MOVF 30,W0512: SUBWF 3D,W0513: BTFSS 03.00514: GOTO 5370515: BTFSS 03.20516: GOTO 51B0517: MOVF 3C,W0518: SUBWF 2F,W0519: BTFSC 03.0051A: GOTO 537051B: CLRF 0F051C: CLRF 0E051D: MOVF 0F,W051E: MOVWF 7A051F: MOVF 0E,W0520: MOVWF 770521: MOVF 0F,W0522: SUBWF 7A,W0523: BTFSS 03.20524: GOTO 51D0525: MOVF 77,W0526: MOVWF 410527: MOVF 7A,W0528: MOVWF 420529: MOVF 42,W052A: SUBLW 27052B: BTFSS 03.0052C: GOTO 533052D: BTFSS 03.2052E: GOTO 51D052F: MOVF 41,W0530: SUBLW 0F0531: BTFSC 03.00532: GOTO 51D0533: INCF 2F,F0534: BTFSC 03.20535: INCF 30,F0536: GOTO 511.................... set_timer1(0); while ( get_timer1() < ticks ) ;0537: CLRF 0F0538: CLRF 0E0539: MOVF 0F,W053A: MOVWF 7A053B: MOVF 0E,W053C: MOVWF 77053D: MOVF 0F,W053E: SUBWF 7A,W053F: BTFSS 03.20540: GOTO 5390541: MOVF 77,W0542: MOVWF 410543: MOVF 7A,W0544: MOVWF 420545: MOVF 42,W0546: SUBWF 3F,W0547: BTFSS 03.00548: GOTO 54F0549: BTFSS 03.2054A: GOTO 539054B: MOVF 3E,W054C: SUBWF 41,W054D: BTFSS 03.0054E: GOTO 539.................... output_high(SYNC);054F: BSF 03.50550: BCF 06.40551: BCF 03.50552: BSF 06.4.................... output_low(CLOCK);0553: BSF 03.50554: BCF 06.60555: BCF 03.50556: BCF 06.6.................... delay_ms(10);0557: MOVLW 0A0558: MOVWF 420559: CALL 0E6.................... output_high(HACK);055A: BSF 03.5055B: BCF 06.5055C: BCF 03.5055D: BSF 06.5.................... delay_ms(10000);055E: MOVLW 28055F: MOVWF 410560: MOVLW FA0561: MOVWF 420562: CALL 0E60563: DECFSZ 41,F0564: GOTO 560.................... output_low(HACK);0565: BSF 03.50566: BCF 06.50567: BCF 03.50568: BCF 06.5.................... output_low(SYNC);0569: BSF 03.5056A: BCF 06.4056B: BCF 03.5056C: BCF 06.4.................... input(CLOCK);056D: BSF 03.5056E: BSF 06.6.................... break;056F: BCF 03.50570: GOTO 61A........................................ case 'i': // Info.................... printf("%s\n\r", ver);0571: CLRF 410572: MOVF 41,W0573: CALL 03F0574: IORLW 000575: BTFSC 03.20576: GOTO 57B0577: INCF 41,F0578: MOVWF 4C0579: CALL 0FE057A: GOTO 572057B: MOVLW 0A057C: MOVWF 4C057D: CALL 0FE057E: MOVLW 0D057F: MOVWF 4C0580: CALL 0FE.................... printf("%Lue4 + %Lu ticks", prescale, ticks);0581: MOVLW 100582: MOVWF 040583: MOVF 3D,W0584: MOVWF 440585: MOVF 3C,W0586: MOVWF 430587: CALL 15F0588: MOVLW 030589: MOVWF 41058A: MOVF 41,W058B: CALL 09D058C: INCF 41,F058D: MOVWF 77058E: MOVWF 4C058F: CALL 0FE0590: MOVLW 080591: SUBWF 41,W0592: BTFSS 03.20593: GOTO 58A0594: MOVLW 100595: MOVWF 040596: MOVF 3F,W0597: MOVWF 440598: MOVF 3E,W0599: MOVWF 43059A: CALL 15F059B: MOVLW 0B059C: MOVWF 42059D: MOVF 42,W059E: CALL 09D059F: INCF 42,F05A0: MOVWF 7705A1: MOVWF 4C05A2: CALL 0FE05A3: MOVLW 1105A4: SUBWF 42,W05A5: BTFSS 03.205A6: GOTO 59D.................... break;05A7: GOTO 61A........................................ case 'p':.................... if (isdigit(string[1]))05A8: MOVF 33,W05A9: SUBLW 2F05AA: BTFSC 03.005AB: GOTO 5DF05AC: MOVF 33,W05AD: SUBLW 3905AE: BTFSS 03.005AF: GOTO 5DF.................... {.................... prescale=atol(string+1);05B0: CLRF 4205B1: MOVLW 3305B2: MOVWF 4105B3: CALL 24205B4: MOVF 79,W05B5: MOVWF 3D05B6: MOVF 78,W05B7: MOVWF 3C.................... printf("%Lu x 10000 prescale", prescale);05B8: MOVLW 1005B9: MOVWF 0405BA: MOVF 3D,W05BB: MOVWF 4405BC: MOVF 3C,W05BD: MOVWF 4305BE: CALL 15F05BF: MOVLW 0305C0: MOVWF 4105C1: MOVF 41,W05C2: CALL 0B305C3: INCF 41,F05C4: MOVWF 7705C5: MOVWF 4C05C6: CALL 0FE05C7: MOVLW 0705C8: SUBWF 41,W05C9: BTFSS 03.205CA: GOTO 5C105CB: MOVLW 0405CC: MOVWF 4205CD: MOVLW 3005CE: MOVWF 4C05CF: CALL 0FE05D0: DECFSZ 42,F05D1: GOTO 5CD05D2: MOVLW 0705D3: MOVWF 4305D4: MOVF 43,W05D5: CALL 0B305D6: INCF 43,F05D7: MOVWF 7705D8: MOVWF 4C05D9: CALL 0FE05DA: MOVLW 1005DB: SUBWF 43,W05DC: BTFSS 03.205DD: GOTO 5D4.................... }.................... else05DE: GOTO 5EA.................... printf("Error");05DF: CLRF 4105E0: MOVF 41,W05E1: CALL 0C805E2: INCF 41,F05E3: MOVWF 7705E4: MOVWF 4C05E5: CALL 0FE05E6: MOVLW 0505E7: SUBWF 41,W05E8: BTFSS 03.205E9: GOTO 5E0.................... break;05EA: GOTO 61A........................................ default: // fine ticks number.................... if (isdigit(string[0]))05EB: MOVF 32,W05EC: SUBLW 2F05ED: BTFSC 03.005EE: GOTO 60F05EF: MOVF 32,W05F0: SUBLW 3905F1: BTFSS 03.005F2: GOTO 60F.................... {.................... ticks=atol(string);05F3: CLRF 4205F4: MOVLW 3205F5: MOVWF 4105F6: CALL 24205F7: MOVF 79,W05F8: MOVWF 3F05F9: MOVF 78,W05FA: MOVWF 3E.................... printf("%Lu ticks", ticks);05FB: MOVLW 1005FC: MOVWF 0405FD: MOVF 3F,W05FE: MOVWF 4405FF: MOVF 3E,W0600: MOVWF 430601: CALL 15F0602: MOVLW 030603: MOVWF 410604: MOVF 41,W0605: CALL 0D20606: INCF 41,F0607: MOVWF 770608: MOVWF 4C0609: CALL 0FE060A: MOVLW 09060B: SUBWF 41,W060C: BTFSS 03.2060D: GOTO 604.................... }.................... else060E: GOTO 61A.................... printf("Error");060F: CLRF 410610: MOVF 41,W0611: CALL 0C80612: INCF 41,F0613: MOVWF 770614: MOVWF 4C0615: CALL 0FE0616: MOVLW 050617: SUBWF 41,W0618: BTFSS 03.20619: GOTO 610.................... };........................................ };061A: GOTO 3B6........................................ while(true).................... {.................... output_low(PIN_B4);061B: BSF 03.5061C: BCF 06.4061D: BCF 03.5061E: BCF 06.4.................... delay_ms(300);061F: MOVLW 020620: MOVWF 410621: MOVLW 960622: MOVWF 420623: CALL 0E60624: DECFSZ 41,F0625: GOTO 621.................... output_high(PIN_B4);0626: BSF 03.50627: BCF 06.40628: BCF 03.50629: BSF 06.4.................... delay_ms(300);062A: MOVLW 02062B: MOVWF 41062C: MOVLW 96062D: MOVWF 42062E: CALL 0E6062F: DECFSZ 41,F0630: GOTO 62C.................... }0631: GOTO 61B.................... }....................0632: GOTO 632Configuration Fuses:Word 1: 3731 NOWDT PUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT DEBUG CCPB0 NOPROTECT INTRCWord 2: 3FFC NOFCMEN NOIESO