Rev 6 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download
CCS PCM C Compiler, Version 3.221, 27853 12-III-06 16:36
Filename: D:\KAKLIK\programy\PIC_C\hack\hack.LST
ROM used: 1587 words (41%)
Largest free fragment is 1792
RAM used: 41 (11%) at main() level
51 (14%) worst case
Stack: 3 worst case (2 in main + 1 for interrupts)
*
0000: NOP
0001: MOVLW 00
0002: MOVWF 0A
0003: GOTO 342
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 21
0008: MOVF 7F,W
0009: MOVWF 20
000A: MOVF 0A,W
000B: MOVWF 28
000C: CLRF 0A
000D: SWAPF 20,F
000E: MOVF 04,W
000F: MOVWF 22
0010: MOVF 77,W
0011: MOVWF 23
0012: MOVF 78,W
0013: MOVWF 24
0014: MOVF 79,W
0015: MOVWF 25
0016: MOVF 7A,W
0017: MOVWF 26
0018: MOVF 7B,W
0019: MOVWF 27
001A: BCF 03.7
001B: BCF 03.5
001C: MOVLW 8C
001D: MOVWF 04
001E: BTFSS 00.0
001F: GOTO 022
0020: BTFSC 0C.0
0021: GOTO 03B
0022: MOVLW 8C
0023: MOVWF 04
0024: BTFSS 00.1
0025: GOTO 028
0026: BTFSC 0C.1
0027: GOTO 03D
0028: MOVF 22,W
0029: MOVWF 04
002A: MOVF 23,W
002B: MOVWF 77
002C: MOVF 24,W
002D: MOVWF 78
002E: MOVF 25,W
002F: MOVWF 79
0030: MOVF 26,W
0031: MOVWF 7A
0032: MOVF 27,W
0033: MOVWF 7B
0034: MOVF 28,W
0035: MOVWF 0A
0036: SWAPF 21,W
0037: MOVWF 03
0038: SWAPF 7F,F
0039: SWAPF 7F,W
003A: RETFIE
003B: BCF 0A.3
003C: GOTO 0E0
003D: BCF 0A.3
003E: 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 42
00E7: MOVWF 04
00E8: BCF 03.7
00E9: MOVF 00,W
00EA: BTFSC 03.2
00EB: GOTO 0FD
00EC: MOVLW 01
00ED: MOVWF 78
00EE: MOVLW BF
00EF: MOVWF 77
00F0: CLRWDT
00F1: DECFSZ 77,F
00F2: GOTO 0F0
00F3: DECFSZ 78,F
00F4: GOTO 0EE
00F5: MOVLW 4A
00F6: MOVWF 77
00F7: DECFSZ 77,F
00F8: GOTO 0F7
00F9: NOP
00FA: CLRWDT
00FB: DECFSZ 00,F
00FC: GOTO 0EC
00FD: 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.5
00FF: BCF 06.3
0100: BCF 03.5
0101: BCF 06.3
0102: MOVLW 08
0103: MOVWF 78
0104: NOP
0105: NOP
0106: NOP
0107: BSF 78.7
0108: GOTO 118
0109: BCF 78.7
010A: RRF 4C,F
010B: BTFSC 03.0
010C: BSF 06.3
010D: BTFSS 03.0
010E: BCF 06.3
010F: BSF 78.6
0110: GOTO 118
0111: BCF 78.6
0112: DECFSZ 78,F
0113: GOTO 10A
0114: NOP
0115: NOP
0116: NOP
0117: BSF 06.3
0118: MOVLW 01
0119: MOVWF 77
011A: CLRF 04
011B: DECFSZ 04,F
011C: GOTO 11B
011D: DECFSZ 77,F
011E: GOTO 11A
011F: MOVLW 0D
0120: MOVWF 04
0121: DECFSZ 04,F
0122: GOTO 121
0123: NOP
0124: NOP
0125: BTFSC 78.7
0126: GOTO 109
0127: BTFSC 78.6
0128: GOTO 111
0129: RETLW 00
012A: MOVF 04,W
012B: MOVWF 78
012C: MOVLW 08
012D: MOVWF 77
012E: BSF 03.5
012F: BSF 06.2
0130: BCF 03.5
0131: BTFSS 06.2
0132: GOTO 135
0133: BSF 03.5
0134: GOTO 130
0135: CLRF 41
0136: BSF 77.7
0137: GOTO 148
0138: BCF 77.7
0139: GOTO 148
013A: BCF 03.0
013B: BTFSC 06.2
013C: BSF 03.0
013D: RRF 41,F
013E: BSF 77.6
013F: GOTO 148
0140: BCF 77.6
0141: DECFSZ 77,F
0142: GOTO 13A
0143: MOVF 78,W
0144: MOVWF 04
0145: MOVF 41,W
0146: MOVWF 78
0147: GOTO 15D
0148: MOVLW 01
0149: MOVWF 04
014A: MOVLW 00
014B: BTFSC 77.7
014C: MOVLW 55
014D: MOVWF 78
014E: DECFSZ 78,F
014F: GOTO 14E
0150: DECFSZ 04,F
0151: GOTO 14A
0152: MOVLW 0D
0153: BTFSC 77.7
0154: MOVLW 03
0155: MOVWF 78
0156: DECFSZ 78,F
0157: GOTO 156
0158: BTFSC 77.7
0159: GOTO 138
015A: BTFSC 77.6
015B: GOTO 140
015C: GOTO 13A
015D: BCF 0A.3
015E: 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 29
035A: 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 0A
0245: MOVWF 46
.................... result = 0;
0246: CLRF 44
0247: CLRF 43
....................
.................... if (!s)
0248: MOVF 41,W
0249: IORWF 42,W
024A: BTFSS 03.2
024B: GOTO 250
.................... return 0;
024C: MOVLW 00
024D: MOVWF 78
024E: MOVWF 79
024F: GOTO 341
.................... c = s[index++];
0250: MOVF 47,W
0251: INCF 47,F
0252: ADDWF 41,W
0253: MOVWF 04
0254: BCF 03.7
0255: BTFSC 42.0
0256: BSF 03.7
0257: MOVF 00,W
0258: MOVWF 48
....................
.................... // increase index if either positive or negative sign is detected
.................... if (c == '-')
0259: MOVF 48,W
025A: SUBLW 2D
025B: BTFSS 03.2
025C: GOTO 269
.................... {
.................... sign = 1; // Set the sign to negative
025D: MOVLW 01
025E: MOVWF 45
.................... c = s[index++];
025F: MOVF 47,W
0260: INCF 47,F
0261: ADDWF 41,W
0262: MOVWF 04
0263: BCF 03.7
0264: BTFSC 42.0
0265: BSF 03.7
0266: MOVF 00,W
0267: MOVWF 48
.................... }
.................... else if (c == '+')
0268: GOTO 276
0269: MOVF 48,W
026A: SUBLW 2B
026B: BTFSS 03.2
026C: GOTO 276
.................... {
.................... c = s[index++];
026D: MOVF 47,W
026E: INCF 47,F
026F: ADDWF 41,W
0270: MOVWF 04
0271: BCF 03.7
0272: BTFSC 42.0
0273: BSF 03.7
0274: MOVF 00,W
0275: MOVWF 48
.................... }
....................
.................... if (c >= '0' && c <= '9')
0276: MOVF 48,W
0277: SUBLW 2F
0278: BTFSC 03.0
0279: GOTO 332
027A: MOVF 48,W
027B: SUBLW 39
027C: BTFSS 03.0
027D: GOTO 332
.................... {
.................... if (c == '0' && (s[index] == 'x' || s[index] == 'X'))
027E: MOVF 48,W
027F: SUBLW 30
0280: BTFSS 03.2
0281: GOTO 2A2
0282: MOVF 47,W
0283: ADDWF 41,W
0284: MOVWF 04
0285: BCF 03.7
0286: BTFSC 42.0
0287: BSF 03.7
0288: MOVF 00,W
0289: SUBLW 78
028A: BTFSC 03.2
028B: GOTO 296
028C: MOVF 47,W
028D: ADDWF 41,W
028E: MOVWF 04
028F: BCF 03.7
0290: BTFSC 42.0
0291: BSF 03.7
0292: MOVF 00,W
0293: SUBLW 58
0294: BTFSS 03.2
0295: GOTO 2A2
.................... {
.................... base = 16;
0296: MOVLW 10
0297: MOVWF 46
.................... index++;
0298: INCF 47,F
.................... c = s[index++];
0299: MOVF 47,W
029A: INCF 47,F
029B: ADDWF 41,W
029C: MOVWF 04
029D: BCF 03.7
029E: BTFSC 42.0
029F: BSF 03.7
02A0: MOVF 00,W
02A1: MOVWF 48
.................... }
....................
.................... // The number is a decimal number
.................... if (base == 10)
02A2: MOVF 46,W
02A3: SUBLW 0A
02A4: BTFSS 03.2
02A5: GOTO 2C9
.................... {
.................... while (c >= '0' && c <= '9')
.................... {
02A6: MOVF 48,W
02A7: SUBLW 2F
02A8: BTFSC 03.0
02A9: GOTO 2C8
02AA: MOVF 48,W
02AB: SUBLW 39
02AC: BTFSS 03.0
02AD: GOTO 2C8
.................... result = 10*result + (c - '0');
02AE: CLRF 4A
02AF: MOVLW 0A
02B0: MOVWF 49
02B1: MOVF 44,W
02B2: MOVWF 4C
02B3: MOVF 43,W
02B4: MOVWF 4B
02B5: GOTO 22C
02B6: MOVLW 30
02B7: SUBWF 48,W
02B8: ADDWF 78,W
02B9: MOVWF 43
02BA: MOVF 79,W
02BB: MOVWF 44
02BC: BTFSC 03.0
02BD: INCF 44,F
.................... c = s[index++];
02BE: MOVF 47,W
02BF: INCF 47,F
02C0: ADDWF 41,W
02C1: MOVWF 04
02C2: BCF 03.7
02C3: BTFSC 42.0
02C4: BSF 03.7
02C5: MOVF 00,W
02C6: MOVWF 48
.................... }
02C7: GOTO 2A6
.................... }
.................... else if (base == 16) // The number is a hexa number
02C8: GOTO 332
02C9: MOVF 46,W
02CA: SUBLW 10
02CB: BTFSS 03.2
02CC: GOTO 332
.................... {
.................... c = toupper(c);
02CD: MOVF 48,W
02CE: SUBLW 60
02CF: BTFSC 03.0
02D0: GOTO 2D8
02D1: MOVF 48,W
02D2: SUBLW 7A
02D3: BTFSS 03.0
02D4: GOTO 2D8
02D5: MOVF 48,W
02D6: ANDLW DF
02D7: GOTO 2D9
02D8: MOVF 48,W
02D9: MOVWF 48
.................... while ( (c >= '0' && c <= '9') || (c >= 'A' && c <='F'))
.................... {
02DA: MOVF 48,W
02DB: SUBLW 2F
02DC: BTFSC 03.0
02DD: GOTO 2E2
02DE: MOVF 48,W
02DF: SUBLW 39
02E0: BTFSC 03.0
02E1: GOTO 2EA
02E2: MOVF 48,W
02E3: SUBLW 40
02E4: BTFSC 03.0
02E5: GOTO 332
02E6: MOVF 48,W
02E7: SUBLW 46
02E8: BTFSS 03.0
02E9: GOTO 332
.................... if (c >= '0' && c <= '9')
02EA: MOVF 48,W
02EB: SUBLW 2F
02EC: BTFSC 03.0
02ED: GOTO 307
02EE: MOVF 48,W
02EF: SUBLW 39
02F0: BTFSS 03.0
02F1: GOTO 307
.................... result = (result << 4) + (c - '0');
02F2: RLF 43,W
02F3: MOVWF 49
02F4: RLF 44,W
02F5: MOVWF 4A
02F6: RLF 49,F
02F7: RLF 4A,F
02F8: RLF 49,F
02F9: RLF 4A,F
02FA: RLF 49,F
02FB: RLF 4A,F
02FC: MOVLW F0
02FD: ANDWF 49,F
02FE: MOVLW 30
02FF: SUBWF 48,W
0300: ADDWF 49,W
0301: MOVWF 43
0302: MOVF 4A,W
0303: MOVWF 44
0304: BTFSC 03.0
0305: INCF 44,F
.................... else
0306: GOTO 31C
.................... result = (result << 4) + (c - 'A' + 10);
0307: RLF 43,W
0308: MOVWF 49
0309: RLF 44,W
030A: MOVWF 4A
030B: RLF 49,F
030C: RLF 4A,F
030D: RLF 49,F
030E: RLF 4A,F
030F: RLF 49,F
0310: RLF 4A,F
0311: MOVLW F0
0312: ANDWF 49,F
0313: MOVLW 41
0314: SUBWF 48,W
0315: ADDLW 0A
0316: ADDWF 49,W
0317: MOVWF 43
0318: MOVF 4A,W
0319: MOVWF 44
031A: BTFSC 03.0
031B: INCF 44,F
....................
.................... c = s[index++];c = toupper(c);
031C: MOVF 47,W
031D: INCF 47,F
031E: ADDWF 41,W
031F: MOVWF 04
0320: BCF 03.7
0321: BTFSC 42.0
0322: BSF 03.7
0323: MOVF 00,W
0324: MOVWF 48
0325: SUBLW 60
0326: BTFSC 03.0
0327: GOTO 32F
0328: MOVF 48,W
0329: SUBLW 7A
032A: BTFSS 03.0
032B: GOTO 32F
032C: MOVF 48,W
032D: ANDLW DF
032E: GOTO 330
032F: MOVF 48,W
0330: MOVWF 48
.................... }
0331: GOTO 2DA
.................... }
.................... }
....................
.................... if (base == 10 && sign == 1)
0332: MOVF 46,W
0333: SUBLW 0A
0334: BTFSS 03.2
0335: GOTO 33D
0336: DECFSZ 45,W
0337: GOTO 33D
.................... result = -result;
0338: COMF 43,F
0339: COMF 44,F
033A: INCF 43,F
033B: BTFSC 03.2
033C: INCF 44,F
....................
.................... return(result);
033D: MOVF 43,W
033E: MOVWF 78
033F: MOVF 44,W
0340: 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 01
035C: MOVWF 2B
035D: CLRF 2C
035E: CLRF 2D
035F: 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.0
00E1: BCF 0A.3
00E2: GOTO 028
.................... #int_TIMER2
.................... TIMER2_isr()
.................... {
....................
.................... }
....................
00E3: BCF 0C.1
00E4: BCF 0A.3
00E5: GOTO 028
.................... void main()
.................... {
*
0342: CLRF 04
0343: BCF 03.7
0344: MOVLW 1F
0345: ANDWF 03,F
0346: BSF 03.5
0347: BCF 1F.4
0348: BCF 1F.5
0349: MOVF 1B,W
034A: ANDLW 80
034B: MOVWF 1B
034C: MOVLW 07
034D: MOVWF 1C
034E: MOVF 05,W
034F: CLRWDT
0350: MOVF 1C,W
0351: BCF 03.5
0352: BCF 0D.6
0353: MOVLW 60
0354: BSF 03.5
0355: MOVWF 0F
0356: BCF 06.3
0357: BCF 03.5
0358: 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.5
0361: BCF 1F.4
0362: BCF 1F.5
0363: MOVF 1B,W
0364: ANDLW 80
0365: MOVWF 1B
.................... setup_adc(ADC_OFF);
0366: BCF 03.5
0367: BCF 1F.0
.................... setup_spi(FALSE);
0368: BCF 14.5
0369: BSF 03.5
036A: BCF 06.2
036B: BSF 06.1
036C: BCF 06.4
036D: MOVLW 00
036E: BCF 03.5
036F: MOVWF 14
0370: BSF 03.5
0371: MOVWF 14
.................... setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);
0372: MOVF 01,W
0373: ANDLW C7
0374: IORLW 28
0375: MOVWF 01
.................... setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);
0376: MOVLW 87
0377: BCF 03.5
0378: MOVWF 10
.................... // setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
.................... setup_timer_2(T2_DISABLED,0,1);
0379: MOVLW 00
037A: MOVWF 78
037B: MOVWF 12
037C: MOVLW 00
037D: BSF 03.5
037E: MOVWF 12
.................... setup_comparator(NC_NC_NC_NC);
037F: MOVLW 07
0380: MOVWF 1C
0381: MOVF 05,W
0382: CLRWDT
0383: MOVLW 02
0384: MOVWF 77
0385: DECFSZ 77,F
0386: GOTO 385
0387: NOP
0388: NOP
0389: MOVF 1C,W
038A: BCF 03.5
038B: BCF 0D.6
.................... setup_vref(FALSE);
038C: BSF 03.5
038D: CLRF 1D
.................... // enable_interrupts(INT_TIMER1);
.................... // enable_interrupts(INT_TIMER2);
.................... // enable_interrupts(GLOBAL);
....................
.................... setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator
038E: MOVLW 62
038F: MOVWF 0F
....................
.................... delay_ms(100);
0390: MOVLW 64
0391: BCF 03.5
0392: MOVWF 42
0393: CALL 0E6
.................... printf("\n\r\n\r%s", ver);
0394: CLRF 41
0395: MOVF 41,W
0396: CALL 04E
0397: INCF 41,F
0398: MOVWF 77
0399: MOVWF 4C
039A: CALL 0FE
039B: MOVLW 04
039C: SUBWF 41,W
039D: BTFSS 03.2
039E: GOTO 395
039F: CLRF 42
03A0: MOVF 42,W
03A1: CALL 03F
03A2: IORLW 00
03A3: BTFSC 03.2
03A4: GOTO 3A9
03A5: INCF 42,F
03A6: MOVWF 4C
03A7: CALL 0FE
03A8: GOTO 3A0
.................... output_low(SYNC);
03A9: BSF 03.5
03AA: BCF 06.4
03AB: BCF 03.5
03AC: BCF 06.4
.................... output_low(HACK);
03AD: BSF 03.5
03AE: BCF 06.5
03AF: BCF 03.5
03B0: BCF 06.5
.................... ticks=1;
03B1: CLRF 3F
03B2: MOVLW 01
03B3: MOVWF 3E
.................... prescale=0;
03B4: CLRF 3D
03B5: CLRF 3C
....................
.................... while(true)
.................... {
.................... printf("\n\r>");
03B6: MOVLW 0A
03B7: MOVWF 4C
03B8: CALL 0FE
03B9: MOVLW 0D
03BA: MOVWF 4C
03BB: CALL 0FE
03BC: MOVLW 3E
03BD: MOVWF 4C
03BE: CALL 0FE
.................... n=0;
03BF: CLRF 40
.................... do
.................... {
.................... ch=getchar();
03C0: GOTO 12A
03C1: MOVF 78,W
03C2: MOVWF 31
.................... printf("%c",ch);
03C3: MOVF 31,W
03C4: MOVWF 4C
03C5: CALL 0FE
.................... string[n++]=ch;
03C6: MOVF 40,W
03C7: INCF 40,F
03C8: ADDLW 32
03C9: MOVWF 04
03CA: BCF 03.7
03CB: MOVF 31,W
03CC: MOVWF 00
.................... } while((13 != ch) && (n < 10));
03CD: MOVF 31,W
03CE: SUBLW 0D
03CF: BTFSC 03.2
03D0: GOTO 3D5
03D1: MOVF 40,W
03D2: SUBLW 09
03D3: BTFSC 03.0
03D4: GOTO 3C0
.................... string[n]=0;
03D5: MOVLW 32
03D6: ADDWF 40,W
03D7: MOVWF 04
03D8: BCF 03.7
03D9: CLRF 00
.................... printf("\n\r");
03DA: MOVLW 0A
03DB: MOVWF 4C
03DC: CALL 0FE
03DD: MOVLW 0D
03DE: MOVWF 4C
03DF: CALL 0FE
.................... switch(string[0])
.................... {
03E0: MOVF 32,W
03E1: XORLW 67
03E2: BTFSC 03.2
03E3: GOTO 3F1
03E4: XORLW 15
03E5: BTFSC 03.2
03E6: GOTO 460
03E7: XORLW 1A
03E8: BTFSC 03.2
03E9: GOTO 4E9
03EA: XORLW 01
03EB: BTFSC 03.2
03EC: GOTO 571
03ED: XORLW 19
03EE: BTFSC 03.2
03EF: GOTO 5A8
03F0: GOTO 5EB
.................... case 'g': // GO
.................... printf("%Lue4 + %Lu GO", prescale, ticks);
03F1: MOVLW 10
03F2: MOVWF 04
03F3: MOVF 3D,W
03F4: MOVWF 44
03F5: MOVF 3C,W
03F6: MOVWF 43
03F7: CALL 15F
03F8: MOVLW 03
03F9: MOVWF 41
03FA: MOVF 41,W
03FB: CALL 059
03FC: INCF 41,F
03FD: MOVWF 77
03FE: MOVWF 4C
03FF: CALL 0FE
0400: MOVLW 08
0401: SUBWF 41,W
0402: BTFSS 03.2
0403: GOTO 3FA
0404: MOVLW 10
0405: MOVWF 04
0406: MOVF 3F,W
0407: MOVWF 44
0408: MOVF 3E,W
0409: MOVWF 43
040A: CALL 15F
040B: MOVLW 20
040C: MOVWF 4C
040D: CALL 0FE
040E: MOVLW 47
040F: MOVWF 4C
0410: CALL 0FE
0411: MOVLW 4F
0412: MOVWF 4C
0413: CALL 0FE
.................... for(i=0; i<prescale; i++) { set_timer1(0); while ( get_timer1() < 10000 ) ; };
0414: CLRF 30
0415: CLRF 2F
0416: MOVF 30,W
0417: SUBWF 3D,W
0418: BTFSS 03.0
0419: GOTO 43C
041A: BTFSS 03.2
041B: GOTO 420
041C: MOVF 3C,W
041D: SUBWF 2F,W
041E: BTFSC 03.0
041F: GOTO 43C
0420: CLRF 0F
0421: CLRF 0E
0422: MOVF 0F,W
0423: MOVWF 7A
0424: MOVF 0E,W
0425: MOVWF 77
0426: MOVF 0F,W
0427: SUBWF 7A,W
0428: BTFSS 03.2
0429: GOTO 422
042A: MOVF 77,W
042B: MOVWF 41
042C: MOVF 7A,W
042D: MOVWF 42
042E: MOVF 42,W
042F: SUBLW 27
0430: BTFSS 03.0
0431: GOTO 438
0432: BTFSS 03.2
0433: GOTO 422
0434: MOVF 41,W
0435: SUBLW 0F
0436: BTFSC 03.0
0437: GOTO 422
0438: INCF 2F,F
0439: BTFSC 03.2
043A: INCF 30,F
043B: GOTO 416
.................... set_timer1(0); while ( get_timer1() < ticks ) ;
043C: CLRF 0F
043D: CLRF 0E
043E: MOVF 0F,W
043F: MOVWF 7A
0440: MOVF 0E,W
0441: MOVWF 77
0442: MOVF 0F,W
0443: SUBWF 7A,W
0444: BTFSS 03.2
0445: GOTO 43E
0446: MOVF 77,W
0447: MOVWF 41
0448: MOVF 7A,W
0449: MOVWF 42
044A: MOVF 42,W
044B: SUBWF 3F,W
044C: BTFSS 03.0
044D: GOTO 454
044E: BTFSS 03.2
044F: GOTO 43E
0450: MOVF 3E,W
0451: SUBWF 41,W
0452: BTFSS 03.0
0453: GOTO 43E
.................... output_high(SYNC);
0454: BSF 03.5
0455: BCF 06.4
0456: BCF 03.5
0457: BSF 06.4
.................... delay_ms(1);
0458: MOVLW 01
0459: MOVWF 42
045A: CALL 0E6
.................... output_low(SYNC);
045B: BSF 03.5
045C: BCF 06.4
045D: BCF 03.5
045E: 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,W
0462: INCF 40,F
0463: MOVWF 41
0464: MOVLW 10
0465: MOVWF 04
0466: MOVF 3D,W
0467: MOVWF 44
0468: MOVF 3C,W
0469: MOVWF 43
046A: CALL 15F
046B: MOVLW 03
046C: MOVWF 42
046D: MOVF 42,W
046E: CALL 06C
046F: INCF 42,F
0470: MOVWF 77
0471: MOVWF 4C
0472: CALL 0FE
0473: MOVLW 08
0474: SUBWF 42,W
0475: BTFSS 03.2
0476: GOTO 46D
0477: MOVLW 10
0478: MOVWF 04
0479: MOVF 3F,W
047A: MOVWF 44
047B: MOVF 3E,W
047C: MOVWF 43
047D: CALL 15F
047E: MOVLW 0B
047F: MOVWF 43
0480: MOVF 43,W
0481: CALL 06C
0482: INCF 43,F
0483: MOVWF 77
0484: MOVWF 4C
0485: CALL 0FE
0486: MOVLW 13
0487: SUBWF 43,W
0488: BTFSS 03.2
0489: GOTO 480
048A: MOVF 41,W
048B: MOVWF 44
048C: MOVLW 18
048D: MOVWF 45
048E: GOTO 1DE
048F: MOVLW 0A
0490: MOVWF 4C
0491: CALL 0FE
0492: MOVLW 0D
0493: MOVWF 4C
0494: CALL 0FE
.................... for(i=0; i<prescale; i++) { set_timer1(0); while ( get_timer1() < 10000 ) ; };
0495: CLRF 30
0496: CLRF 2F
0497: MOVF 30,W
0498: SUBWF 3D,W
0499: BTFSS 03.0
049A: GOTO 4BD
049B: BTFSS 03.2
049C: GOTO 4A1
049D: MOVF 3C,W
049E: SUBWF 2F,W
049F: BTFSC 03.0
04A0: GOTO 4BD
04A1: CLRF 0F
04A2: CLRF 0E
04A3: MOVF 0F,W
04A4: MOVWF 7A
04A5: MOVF 0E,W
04A6: MOVWF 77
04A7: MOVF 0F,W
04A8: SUBWF 7A,W
04A9: BTFSS 03.2
04AA: GOTO 4A3
04AB: MOVF 77,W
04AC: MOVWF 41
04AD: MOVF 7A,W
04AE: MOVWF 42
04AF: MOVF 42,W
04B0: SUBLW 27
04B1: BTFSS 03.0
04B2: GOTO 4B9
04B3: BTFSS 03.2
04B4: GOTO 4A3
04B5: MOVF 41,W
04B6: SUBLW 0F
04B7: BTFSC 03.0
04B8: GOTO 4A3
04B9: INCF 2F,F
04BA: BTFSC 03.2
04BB: INCF 30,F
04BC: GOTO 497
.................... set_timer1(0); while ( get_timer1() < ticks ) ;
04BD: CLRF 0F
04BE: CLRF 0E
04BF: MOVF 0F,W
04C0: MOVWF 7A
04C1: MOVF 0E,W
04C2: MOVWF 77
04C3: MOVF 0F,W
04C4: SUBWF 7A,W
04C5: BTFSS 03.2
04C6: GOTO 4BF
04C7: MOVF 77,W
04C8: MOVWF 41
04C9: MOVF 7A,W
04CA: MOVWF 42
04CB: MOVF 42,W
04CC: SUBWF 3F,W
04CD: BTFSS 03.0
04CE: GOTO 4D5
04CF: BTFSS 03.2
04D0: GOTO 4BF
04D1: MOVF 3E,W
04D2: SUBWF 41,W
04D3: BTFSS 03.0
04D4: GOTO 4BF
.................... output_high(SYNC);
04D5: BSF 03.5
04D6: BCF 06.4
04D7: BCF 03.5
04D8: BSF 06.4
.................... delay_ms(20);
04D9: MOVLW 14
04DA: MOVWF 42
04DB: CALL 0E6
.................... output_low(SYNC);
04DC: BSF 03.5
04DD: BCF 06.4
04DE: BCF 03.5
04DF: BCF 06.4
.................... delay_ms(2000);
04E0: MOVLW 08
04E1: MOVWF 41
04E2: MOVLW FA
04E3: MOVWF 42
04E4: CALL 0E6
04E5: DECFSZ 41,F
04E6: GOTO 4E2
.................... };
04E7: GOTO 461
.................... break;
04E8: GOTO 61A
....................
.................... case 'h': // HACK
.................... printf("%Lue4 + %Lu HACK", prescale, ticks);
04E9: MOVLW 10
04EA: MOVWF 04
04EB: MOVF 3D,W
04EC: MOVWF 44
04ED: MOVF 3C,W
04EE: MOVWF 43
04EF: CALL 15F
04F0: MOVLW 03
04F1: MOVWF 41
04F2: MOVF 41,W
04F3: CALL 088
04F4: INCF 41,F
04F5: MOVWF 77
04F6: MOVWF 4C
04F7: CALL 0FE
04F8: MOVLW 08
04F9: SUBWF 41,W
04FA: BTFSS 03.2
04FB: GOTO 4F2
04FC: MOVLW 10
04FD: MOVWF 04
04FE: MOVF 3F,W
04FF: MOVWF 44
0500: MOVF 3E,W
0501: MOVWF 43
0502: CALL 15F
0503: MOVLW 0B
0504: MOVWF 42
0505: MOVF 42,W
0506: CALL 088
0507: INCF 42,F
0508: MOVWF 77
0509: MOVWF 4C
050A: CALL 0FE
050B: MOVLW 10
050C: SUBWF 42,W
050D: BTFSS 03.2
050E: GOTO 505
.................... for(i=0; i<prescale; i++) { set_timer1(0); while ( get_timer1() < 10000 ) ; };
050F: CLRF 30
0510: CLRF 2F
0511: MOVF 30,W
0512: SUBWF 3D,W
0513: BTFSS 03.0
0514: GOTO 537
0515: BTFSS 03.2
0516: GOTO 51B
0517: MOVF 3C,W
0518: SUBWF 2F,W
0519: BTFSC 03.0
051A: GOTO 537
051B: CLRF 0F
051C: CLRF 0E
051D: MOVF 0F,W
051E: MOVWF 7A
051F: MOVF 0E,W
0520: MOVWF 77
0521: MOVF 0F,W
0522: SUBWF 7A,W
0523: BTFSS 03.2
0524: GOTO 51D
0525: MOVF 77,W
0526: MOVWF 41
0527: MOVF 7A,W
0528: MOVWF 42
0529: MOVF 42,W
052A: SUBLW 27
052B: BTFSS 03.0
052C: GOTO 533
052D: BTFSS 03.2
052E: GOTO 51D
052F: MOVF 41,W
0530: SUBLW 0F
0531: BTFSC 03.0
0532: GOTO 51D
0533: INCF 2F,F
0534: BTFSC 03.2
0535: INCF 30,F
0536: GOTO 511
.................... set_timer1(0); while ( get_timer1() < ticks ) ;
0537: CLRF 0F
0538: CLRF 0E
0539: MOVF 0F,W
053A: MOVWF 7A
053B: MOVF 0E,W
053C: MOVWF 77
053D: MOVF 0F,W
053E: SUBWF 7A,W
053F: BTFSS 03.2
0540: GOTO 539
0541: MOVF 77,W
0542: MOVWF 41
0543: MOVF 7A,W
0544: MOVWF 42
0545: MOVF 42,W
0546: SUBWF 3F,W
0547: BTFSS 03.0
0548: GOTO 54F
0549: BTFSS 03.2
054A: GOTO 539
054B: MOVF 3E,W
054C: SUBWF 41,W
054D: BTFSS 03.0
054E: GOTO 539
.................... output_high(SYNC);
054F: BSF 03.5
0550: BCF 06.4
0551: BCF 03.5
0552: BSF 06.4
.................... output_low(CLOCK);
0553: BSF 03.5
0554: BCF 06.6
0555: BCF 03.5
0556: BCF 06.6
.................... delay_ms(10);
0557: MOVLW 0A
0558: MOVWF 42
0559: CALL 0E6
.................... output_high(HACK);
055A: BSF 03.5
055B: BCF 06.5
055C: BCF 03.5
055D: BSF 06.5
.................... delay_ms(10000);
055E: MOVLW 28
055F: MOVWF 41
0560: MOVLW FA
0561: MOVWF 42
0562: CALL 0E6
0563: DECFSZ 41,F
0564: GOTO 560
.................... output_low(HACK);
0565: BSF 03.5
0566: BCF 06.5
0567: BCF 03.5
0568: BCF 06.5
.................... output_low(SYNC);
0569: BSF 03.5
056A: BCF 06.4
056B: BCF 03.5
056C: BCF 06.4
.................... input(CLOCK);
056D: BSF 03.5
056E: BSF 06.6
.................... break;
056F: BCF 03.5
0570: GOTO 61A
....................
.................... case 'i': // Info
.................... printf("%s\n\r", ver);
0571: CLRF 41
0572: MOVF 41,W
0573: CALL 03F
0574: IORLW 00
0575: BTFSC 03.2
0576: GOTO 57B
0577: INCF 41,F
0578: MOVWF 4C
0579: CALL 0FE
057A: GOTO 572
057B: MOVLW 0A
057C: MOVWF 4C
057D: CALL 0FE
057E: MOVLW 0D
057F: MOVWF 4C
0580: CALL 0FE
.................... printf("%Lue4 + %Lu ticks", prescale, ticks);
0581: MOVLW 10
0582: MOVWF 04
0583: MOVF 3D,W
0584: MOVWF 44
0585: MOVF 3C,W
0586: MOVWF 43
0587: CALL 15F
0588: MOVLW 03
0589: MOVWF 41
058A: MOVF 41,W
058B: CALL 09D
058C: INCF 41,F
058D: MOVWF 77
058E: MOVWF 4C
058F: CALL 0FE
0590: MOVLW 08
0591: SUBWF 41,W
0592: BTFSS 03.2
0593: GOTO 58A
0594: MOVLW 10
0595: MOVWF 04
0596: MOVF 3F,W
0597: MOVWF 44
0598: MOVF 3E,W
0599: MOVWF 43
059A: CALL 15F
059B: MOVLW 0B
059C: MOVWF 42
059D: MOVF 42,W
059E: CALL 09D
059F: INCF 42,F
05A0: MOVWF 77
05A1: MOVWF 4C
05A2: CALL 0FE
05A3: MOVLW 11
05A4: SUBWF 42,W
05A5: BTFSS 03.2
05A6: GOTO 59D
.................... break;
05A7: GOTO 61A
....................
.................... case 'p':
.................... if (isdigit(string[1]))
05A8: MOVF 33,W
05A9: SUBLW 2F
05AA: BTFSC 03.0
05AB: GOTO 5DF
05AC: MOVF 33,W
05AD: SUBLW 39
05AE: BTFSS 03.0
05AF: GOTO 5DF
.................... {
.................... prescale=atol(string+1);
05B0: CLRF 42
05B1: MOVLW 33
05B2: MOVWF 41
05B3: CALL 242
05B4: MOVF 79,W
05B5: MOVWF 3D
05B6: MOVF 78,W
05B7: MOVWF 3C
.................... printf("%Lu x 10000 prescale", prescale);
05B8: MOVLW 10
05B9: MOVWF 04
05BA: MOVF 3D,W
05BB: MOVWF 44
05BC: MOVF 3C,W
05BD: MOVWF 43
05BE: CALL 15F
05BF: MOVLW 03
05C0: MOVWF 41
05C1: MOVF 41,W
05C2: CALL 0B3
05C3: INCF 41,F
05C4: MOVWF 77
05C5: MOVWF 4C
05C6: CALL 0FE
05C7: MOVLW 07
05C8: SUBWF 41,W
05C9: BTFSS 03.2
05CA: GOTO 5C1
05CB: MOVLW 04
05CC: MOVWF 42
05CD: MOVLW 30
05CE: MOVWF 4C
05CF: CALL 0FE
05D0: DECFSZ 42,F
05D1: GOTO 5CD
05D2: MOVLW 07
05D3: MOVWF 43
05D4: MOVF 43,W
05D5: CALL 0B3
05D6: INCF 43,F
05D7: MOVWF 77
05D8: MOVWF 4C
05D9: CALL 0FE
05DA: MOVLW 10
05DB: SUBWF 43,W
05DC: BTFSS 03.2
05DD: GOTO 5D4
.................... }
.................... else
05DE: GOTO 5EA
.................... printf("Error");
05DF: CLRF 41
05E0: MOVF 41,W
05E1: CALL 0C8
05E2: INCF 41,F
05E3: MOVWF 77
05E4: MOVWF 4C
05E5: CALL 0FE
05E6: MOVLW 05
05E7: SUBWF 41,W
05E8: BTFSS 03.2
05E9: GOTO 5E0
.................... break;
05EA: GOTO 61A
....................
.................... default: // fine ticks number
.................... if (isdigit(string[0]))
05EB: MOVF 32,W
05EC: SUBLW 2F
05ED: BTFSC 03.0
05EE: GOTO 60F
05EF: MOVF 32,W
05F0: SUBLW 39
05F1: BTFSS 03.0
05F2: GOTO 60F
.................... {
.................... ticks=atol(string);
05F3: CLRF 42
05F4: MOVLW 32
05F5: MOVWF 41
05F6: CALL 242
05F7: MOVF 79,W
05F8: MOVWF 3F
05F9: MOVF 78,W
05FA: MOVWF 3E
.................... printf("%Lu ticks", ticks);
05FB: MOVLW 10
05FC: MOVWF 04
05FD: MOVF 3F,W
05FE: MOVWF 44
05FF: MOVF 3E,W
0600: MOVWF 43
0601: CALL 15F
0602: MOVLW 03
0603: MOVWF 41
0604: MOVF 41,W
0605: CALL 0D2
0606: INCF 41,F
0607: MOVWF 77
0608: MOVWF 4C
0609: CALL 0FE
060A: MOVLW 09
060B: SUBWF 41,W
060C: BTFSS 03.2
060D: GOTO 604
.................... }
.................... else
060E: GOTO 61A
.................... printf("Error");
060F: CLRF 41
0610: MOVF 41,W
0611: CALL 0C8
0612: INCF 41,F
0613: MOVWF 77
0614: MOVWF 4C
0615: CALL 0FE
0616: MOVLW 05
0617: SUBWF 41,W
0618: BTFSS 03.2
0619: GOTO 610
.................... };
....................
.................... };
061A: GOTO 3B6
....................
.................... while(true)
.................... {
.................... output_low(PIN_B4);
061B: BSF 03.5
061C: BCF 06.4
061D: BCF 03.5
061E: BCF 06.4
.................... delay_ms(300);
061F: MOVLW 02
0620: MOVWF 41
0621: MOVLW 96
0622: MOVWF 42
0623: CALL 0E6
0624: DECFSZ 41,F
0625: GOTO 621
.................... output_high(PIN_B4);
0626: BSF 03.5
0627: BCF 06.4
0628: BCF 03.5
0629: BSF 06.4
.................... delay_ms(300);
062A: MOVLW 02
062B: MOVWF 41
062C: MOVLW 96
062D: MOVWF 42
062E: CALL 0E6
062F: DECFSZ 41,F
0630: GOTO 62C
.................... }
0631: GOTO 61B
.................... }
....................
0632: GOTO 632
Configuration Fuses:
Word 1: 3731 NOWDT PUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT DEBUG CCPB0 NOPROTECT INTRC
Word 2: 3FFC NOFCMEN NOIESO