Subversion Repositories svnkaklik

Compare Revisions

No changes between revisions

Ignore whitespace Rev 6 → Rev 410

/programy/C/PIC_C/hack/hack.BAK
0,0 → 1,11
#include <16F88.h>
#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)
//#use rs232(baud=2400,xmit=PIN_B3)
//#use rs232(DEBUGGER)
#use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8)
 
/programy/C/PIC_C/hack/hack.HEX
0,0 → 1,202
:10000000000000308A00422BFF00030E8301A10094
:100010007F08A0000A08A8008A01A00E0408A20018
:100020007708A3007808A4007908A5007A08A6003C
:100030007B08A700831383128C308400001C2228C5
:100040000C183B288C308400801C28288C183D28F4
:10005000220884002308F7002408F8002508F90086
:100060002608FA002708FB0028088A00210E8300D2
:10007000FF0E7F0E09008A11E0288A11E3280A107A
:100080008A100A1182074834413443344B342034F7
:10009000763431342E343034003400340A108A106F
:1000A0000A1182070A340D340A340D3425347334AE
:1000B00000340A108A100A11820725344C34753432
:1000C0006534343420342B34203425344C347534A6
:1000D000203447344F3400340A108A100A11820742
:1000E00025344C3475346534343420342B34203486
:1000F00025344C347534203452344534503445342E
:10010000413454342034253475340A340D340034E9
:100110000A108A100A11820725344C34753465346C
:10012000343420342B34203425344C34753420348A
:100130004834413443344B3400340A108A100A11D5
:10014000820725344C3475346534343420342B34F0
:10015000203425344C347534203474346934633499
:100160006B34733400340A108A100A118207253464
:100170004C347534203478342034313420347034A5
:10018000723465347334633461346C3465340034F0
:100190000A108A100A1182074534723472346F349F
:1001A000723400340A108A100A11820725344C3444
:1001B000753420347434693463346B3473340034EC
:1001C0000C108A1128288C108A11282842308400AB
:1001D000831300080319FD280130F800BF30F70031
:1001E0006400F70BF028F80BEE284A30F700F70B05
:1001F000F72800006400800BEC2800348316861179
:10020000831286110830F800000000000000F81783
:100210001829F813CC0C03188615031C86117817BF
:1002200018297813F80B0A29000000000000861531
:100230000130F7008401840B1B29F70B1A290D30BC
:100240008400840B212900000000F81B0929781B79
:10025000112900340408F8000830F7008316061549
:100260008312061D352983163029C101F717482945
:10027000F7134829031006190314C10C77174829EE
:100280007713F70B3A29780884004108F8005D29B4
:10029000013084000030F71B5530F800F80B4E2970
:1002A000840B4A290D30F71B0330F800F80B562950
:1002B000F71B3829771B40293A298A11C12BCB011A
:1002C0000408CA004B10831B4B14440EF038C600C0
:1002D000C607E23EC700323EC90044080F39C707CF
:1002E000C707C907E93EC800C807C807430E0F394A
:1002F000C807C907C80DC90DC909C90D43080F3979
:10030000C907C60D0730C5000A30C907C803031C5A
:100310008529C807C703031C8929C707C603031C0F
:100320008D29C607C503031C91294530840083131A
:1003300007304A058407493004020319C12900081F
:10034000F700031DA9294A1ABF29CA19AB29203071
:10035000AC290830CA003030F707C4010408C300D4
:100360004410831B44147708C5007708CC00FE2096
:10037000430884008313441883174508F700840A50
:100380009B290008F7003030F7077708CC00FE20E3
:1003900000344708F80146020318D1294608F7003F
:1003A000DD29F7010830C800C60DF70D47087702B0
:1003B0000318F700F80DC80BD42900344513C512F3
:1003C0004408C6006430C700C9217708C400780813
:1003D000031D082AC51A082AC519162A451BF6291D
:1003E0004518F6294519F629C51B162A451C022A67
:1003F000C51B162A451B022A4518162A4519022A2A
:10040000C51B162A2030451E3030CC00FE20162A8F
:10041000C516C51F122A78088000F8002D30CC00C0
:10042000FE20C51330307807CC00FE20451B212A62
:100430004408C6000A30C700C9217708C400451720
:10044000E729C51F262A2D30CC00FE203030440776
:10045000CC00FE208A118F2C1030F700FA01CD015C
:10046000CA0CC90C031C3A2A4B08FA070318CD0A18
:100470004C08CD07CD0CFA0CF90CF80CF70B302A10
:100480008A11B62AC701C5010A30C600C401C301DA
:1004900041084204031D502A0030F800F900412BA6
:1004A0004708C70A410784008313421883170008CE
:1004B000C80048082D3C031D692A0130C5004708C3
:1004C000C70A410784008313421883170008C80035
:1004D000762A48082B3C031D762A4708C70A41079D
:1004E00084008313421883170008C80048082F3C73
:1004F0000318322B4808393C031C322B4808303C87
:10050000031DA22A4708410784008313421883175A
:100510000008783C0319962A470841078400831392
:10052000421883170008583C031DA22A1030C60049
:10053000C70A4708C70A4107840083134218831774
:100540000008C80046080A3C031DC92A48082F3C79
:100550000318C82A4808393C031CC82ACA010A30B3
:10056000C9004408CC004308CB002C2A3030480294
:100570007807C3007908C4000318C40A4708C70AEB
:10058000410784008313421883170008C800A62A75
:10059000322B4608103C031D322B4808603C0318E0
:1005A000D82A48087A3C031CD82A4808DF39D92AB7
:1005B0004808C80048082F3C0318E22A4808393C7C
:1005C0000318EA2A4808403C0318322B4808463CE6
:1005D000031C322B48082F3C0318072B4808393CD2
:1005E000031C072B430DC900440DCA00C90DCA0DD9
:1005F000C90DCA0DC90DCA0DF030C9053030480209
:100600004907C3004A08C4000318C40A1C2B430D41
:10061000C900440DCA00C90DCA0DC90DCA0DC90DC6
:10062000CA0DF030C905413048020A3E4907C300EF
:100630004A08C4000318C40A4708C70A41078400CF
:100640008313421883170008C800603C03182F2B3F
:1006500048087A3C031C2F2B4808DF39302B480808
:10066000C800DA2A46080A3C031D3D2B450B3D2BEA
:10067000C309C409C30A0319C40A4308F80044089B
:10068000F9000034840183131F30830583161F1281
:100690009F121B0880399B0007309C0005086400EE
:1006A0001C0883120D13603083168F00861183128D
:1006B0008615A901AA010130AB00AC01AD01AE0164
:1006C00083161F129F121B0880399B0083121F1074
:1006D00094128316061186140612003083129400B9
:1006E000831694000108C7392838810087308312A7
:1006F00090000030F800920000308316920007301E
:100700009C00050864000230F700F70B852B000001
:1007100000001C0883120D1383169D0162308F00A8
:1007200064308312C200E620C10141084E20C10A94
:10073000F700CC00FE2004304102031D952BC201BE
:1007400042083F2000380319A92BC20ACC00FE2022
:10075000A02B8316061283120612831686128312AA
:100760008612BF010130BE00BD01BC010A30CC00C1
:10077000FE200D30CC00FE203E30CC00FE20C0011B
:100780002A297808B1003108CC00FE204008C00AB0
:10079000323E840083133108800031080D3C031978
:1007A000D52B4008093C0318C02B32304007840089
:1007B000831380010A30CC00FE200D30CC00FE20D7
:1007C0003208673A0319F12B153A0319602C1A3ACB
:1007D0000319E92C013A0319712D193A0319A82DAF
:1007E000EB2D103084003D08C4003C08C3005F219D
:1007F0000330C10041085920C10AF700CC00FE2097
:1008000008304102031DFA2B103084003F08C40059
:100810003E08C3005F212030CC00FE204730CC00D2
:10082000FE204F30CC00FE20B001AF0130083D0269
:10083000031C3C2C031D202C3C082F0203183C2CCD
:100840008F018E010F08FA000E08F7000F087A02D8
:10085000031D222C7708C1007A08C2004208273CF9
:10086000031C382C031D222C41080F3C0318222C9A
:10087000AF0A0319B00A162C8F018E010F08FA0077
:100880000E08F7000F087A02031D3E2C7708C100FE
:100890007A08C20042083F02031C542C031D3E2C60
:1008A0003E084102031C3E2C8316061283120616D4
:1008B0000130C200E62083160612831206121A2E99
:1008C000C0014008C00AC100103084003D08C400C7
:1008D0003C08C3005F210330C20042086C20C20AFA
:1008E000F700CC00FE2008304202031D6D2C1030B2
:1008F00084003F08C4003E08C3005F210B30C300E2
:1009000043086C20C30AF700CC00FE2013304302DA
:10091000031D802C4108C4001830C500DE290A30B0
:10092000CC00FE200D30CC00FE20B001AF0130081D
:100930003D02031CBD2C031DA12C3C082F020318F3
:10094000BD2C8F018E010F08FA000E08F7000F086A
:100950007A02031DA32C7708C1007A08C20042085E
:10096000273C031CB92C031DA32C41080F3C031882
:10097000A32CAF0A0319B00A972C8F018E010F0820
:10098000FA000E08F7000F087A02031DBF2C770843
:10099000C1007A08C20042083F02031CD52C031D87
:1009A000BF2C3E084102031CBF2C83160612831283
:1009B00006161430C200E6208316061283120612B1
:1009C0000830C100FA30C200E620C10BE22C612CD5
:1009D0001A2E103084003D08C4003C08C3005F217B
:1009E0000330C10041088820C10AF700CC00FE2076
:1009F00008304102031DF22C103084003F08C4006F
:100A00003E08C3005F210B30C20042088820C20AA2
:100A1000F700CC00FE2010304202031D052DB0016E
:100A2000AF0130083D02031C372D031D1B2D3C0870
:100A30002F020318372D8F018E010F08FA000E08C0
:100A4000F7000F087A02031D1D2D7708C1007A08F0
:100A5000C2004208273C031C332D031D1D2D4108F5
:100A60000F3C03181D2DAF0A0319B00A112D8F0179
:100A70008E010F08FA000E08F7000F087A02031D16
:100A8000392D7708C1007A08C20042083F02031CD2
:100A90004F2D031D392D3E084102031C392D8316AD
:100AA00006128312061683160613831206130A30E3
:100AB000C200E62083168612831286162830C100F3
:100AC000FA30C200E620C10B602D83168612831215
:100AD00086128316061283120612831606178312D5
:100AE0001A2EC10141083F20003803197B2DC10A8D
:100AF000CC00FE20722D0A30CC00FE200D30CC0040
:100B0000FE20103084003D08C4003C08C3005F2173
:100B10000330C10041089D20C10AF700CC00FE202F
:100B200008304102031D8A2D103084003F08C400A4
:100B30003E08C3005F210B30C20042089D20C20A5C
:100B4000F700CC00FE2011304202031D9D2D1A2E0D
:100B500033082F3C0318DF2D3308393C031CDF2DED
:100B6000C2013330C10042227908BD007808BC00C0
:100B7000103084003D08C4003C08C3005F210330EE
:100B8000C1004108B320C10AF700CC00FE200730A5
:100B90004102031DC12D0430C2003030CC00FE20C4
:100BA000C20BCD2D0730C3004308B320C30AF700A2
:100BB000CC00FE2010304302031DD42DEA2DC101CC
:100BC0004108C820C10AF700CC00FE2005304102D0
:100BD000031DE02D1A2E32082F3C03180F2E320869
:100BE000393C031C0F2EC2013230C1004222790869
:100BF000BF007808BE00103084003F08C4003E08E3
:100C0000C3005F210330C1004108D220C10AF700B0
:100C1000CC00FE2009304102031D042E1A2EC10112
:100C20004108C820C10AF700CC00FE20053041026F
:100C3000031D102EB62B83160612831206120230E5
:100C4000C1009630C200E620C10B212E8316061289
:100C5000831206160230C1009630C200E620C10B96
:060C60002C2E1B2E322E8B
:04400E003137FC3F0B
:00000001FF
;PIC16F88
/programy/C/PIC_C/hack/hack.LST
0,0 → 1,2662
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
/programy/C/PIC_C/hack/hack.PJT
0,0 → 1,56
[PROJECT]
Target=hack.HEX
Development_Mode=
Processor=0x688F
ToolSuite=CCS
 
[Directories]
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\Drivers;
Library=
LinkerScript=
 
[Target Data]
FileList=hack.c;
BuildTool=C-COMPILER
OptionString=+FM
AdditionalOptionString=
BuildRequired=1
 
[hack.c]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=hack.c
 
[Windows]
0=0000 hack.c 0 0 796 451 3 0
 
[Opened Files]
1=D:\KAKLIK\programy\PIC_C\hack\hack.c
2=C:\Program Files\PICC\devices\16F88.h
3=D:\KAKLIK\programy\PIC_C\hack\hack.h
4=C:\Program Files\PICC\Drivers\stdlib.h
5=C:\Program Files\PICC\Drivers\stddef.h
6=C:\Program Files\PICC\Drivers\string.h
7=C:\Program Files\PICC\Drivers\ctype.h
8=
[debugperif]
selected=Analog/Digital Conv
[debugram]
autoread=1
[debugeedata]
autoread=1
[debugbreak]
count=0
[pcwdebug]
watchcol0=75
[debugwatch]
count=0
[debugexpr]
expr=
sideeffects=0
/programy/C/PIC_C/hack/hack.SYM
0,0 → 1,107
015-016 CCP_1
015 CCP_1_LOW
016 CCP_1_HIGH
020 @INTERRUPT_AREA
021 @INTERRUPT_AREA
022 @INTERRUPT_AREA
023 @INTERRUPT_AREA
024 @INTERRUPT_AREA
025 @INTERRUPT_AREA
026 @INTERRUPT_AREA
027 @INTERRUPT_AREA
028 @INTERRUPT_AREA
029-02A strtok.save
02B-02E _Randseed
02F-030 main.i
031 main.ch
032-03B main.string
03C-03D main.prescale
03E-03F main.ticks
040 main.n
041-042 atol.s
041 @GETCH_1_.@SCRATCH
041 main.@SCRATCH
042 @delay_ms1.P1
042 main.@SCRATCH
043-044 atol.result
043-044 @PRINTF_LU_1200_51_50.P1
043 main.@SCRATCH
044 @PRINTF_U_1200_51_50.P1
045 @PRINTF_U_1200_51_50.P1
045 atol.sign
045 @PRINTF_LU_1200_51_50.@SCRATCH
046 atol.base
046 @DIV88.P1
046 @PRINTF_LU_1200_51_50.@SCRATCH
047 @DIV88.P1
047 atol.index
047 @PRINTF_LU_1200_51_50.@SCRATCH
048 atol.c
048 @PRINTF_LU_1200_51_50.@SCRATCH
048 @DIV88.@SCRATCH
049-04A @MUL1616.P1
049 atol.@SCRATCH
049 @PRINTF_LU_1200_51_50.@SCRATCH
04A atol.@SCRATCH
04A @PRINTF_LU_1200_51_50.@SCRATCH
04B-04C @MUL1616.P1
04B atol.@SCRATCH
04B @PRINTF_LU_1200_51_50.@SCRATCH
04C @PUTCHAR_1_.P1
04D @MUL1616.@SCRATCH
077 @SCRATCH
078 @SCRATCH
078 _RETURN_
079 @SCRATCH
07A @SCRATCH
07B @SCRATCH
09C.6 C1OUT
09C.7 C2OUT
 
00E6 @delay_ms1
00FE @PUTCHAR_1_
012A @GETCH_1_
022C @MUL1616
0242 atol
00E0 TIMER1_isr
00E3 TIMER2_isr
003F @const290
0342 main
004E @const11193
0059 @const11223
015F @PRINTF_LU_1200_51_50
006C @const11259
01C9 @DIV88
01DE @PRINTF_U_1200_51_50
0088 @const11300
009D @const11330
00B3 @const11344
00C8 @const11352
00D2 @const11365
0342 @cinit
 
Project Files:
D:\KAKLIK\programy\PIC_C\hack\hack.c
D:\KAKLIK\programy\PIC_C\hack\hack.h
C:\Program Files\PICC\devices\16F88.h
C:\Program Files\PICC\Drivers\stdlib.h
C:\Program Files\PICC\Drivers\stddef.h
C:\Program Files\PICC\Drivers\string.h
C:\Program Files\PICC\Drivers\ctype.h
 
Compiler Settings:
Processor: PIC16F88
Pointer Size: 16
ADC Range: 0-255
Opt Level: 9
Short,Int,Long: 1,8,16
ICD Provisions: Yes
 
Output Files:
Errors: D:\KAKLIK\programy\PIC_C\hack\hack.err
INHX8: D:\KAKLIK\programy\PIC_C\hack\hack.HEX
Symbols: D:\KAKLIK\programy\PIC_C\hack\hack.SYM
List: D:\KAKLIK\programy\PIC_C\hack\hack.LST
Debug/COFF: D:\KAKLIK\programy\PIC_C\hack\hack.cof
Call Tree: D:\KAKLIK\programy\PIC_C\hack\hack.tre
Statistics: D:\KAKLIK\programy\PIC_C\hack\hack.sta
/programy/C/PIC_C/hack/hack.c
0,0 → 1,137
#include ".\hack.h"
#include <stdlib.h>
 
#define SYNC PIN_B4 // Spousteni oscyloskopu
#define HACK PIN_B5 // Zkratovani napajeni SmartCard
#define CLOCK PIN_B6 // Hodiny ze SmartCard
 
#int_TIMER1
TIMER1_isr()
{
 
}
 
#int_TIMER2
TIMER2_isr()
{
 
}
 
void main()
{
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);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);
setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);
// setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
// enable_interrupts(INT_TIMER1);
// enable_interrupts(INT_TIMER2);
// enable_interrupts(GLOBAL);
 
setup_oscillator(OSC_4MHZ|OSC_INTRC); // 4 MHz interni RC oscilator
 
delay_ms(100);
printf("\n\r\n\r%s", ver);
output_low(SYNC);
output_low(HACK);
ticks=1;
prescale=0;
 
while(true)
{
printf("\n\r>");
n=0;
do
{
ch=getchar();
printf("%c",ch);
string[n++]=ch;
} while((13 != ch) && (n < 10));
string[n]=0;
printf("\n\r");
switch(string[0])
{
case 'g': // GO
printf("%Lue4 + %Lu GO", prescale, ticks);
for(i=0; i<prescale; i++) { set_timer1(0); while ( get_timer1() < 10000 ) ; };
set_timer1(0); while ( get_timer1() < ticks ) ;
output_high(SYNC);
delay_ms(1);
output_low(SYNC);
break;
 
case 'r': // REPEAT
n=0;
while(true)
{
printf("%Lue4 + %Lu REPEAT %u\n\r", prescale, ticks, n++);
for(i=0; i<prescale; i++) { set_timer1(0); while ( get_timer1() < 10000 ) ; };
set_timer1(0); while ( get_timer1() < ticks ) ;
output_high(SYNC);
delay_ms(20);
output_low(SYNC);
delay_ms(2000);
};
break;
 
case 'h': // HACK
printf("%Lue4 + %Lu HACK", prescale, ticks);
for(i=0; i<prescale; i++) { set_timer1(0); while ( get_timer1() < 10000 ) ; };
set_timer1(0); while ( get_timer1() < ticks ) ;
output_high(SYNC);
output_low(CLOCK);
delay_ms(10);
output_high(HACK);
delay_ms(10000);
output_low(HACK);
output_low(SYNC);
input(CLOCK);
break;
 
case 'i': // Info
printf("%s\n\r", ver);
printf("%Lue4 + %Lu ticks", prescale, ticks);
break;
 
case 'p':
if (isdigit(string[1]))
{
prescale=atol(string+1);
printf("%Lu x 10000 prescale", prescale);
}
else
printf("Error");
break;
 
default: // fine ticks number
if (isdigit(string[0]))
{
ticks=atol(string);
printf("%Lu ticks", ticks);
}
else
printf("Error");
};
 
};
 
while(true)
{
output_low(PIN_B4);
delay_ms(300);
output_high(PIN_B4);
delay_ms(300);
}
}
/programy/C/PIC_C/hack/hack.cof
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/C/PIC_C/hack/hack.err
0,0 → 1,0
No Errors
/programy/C/PIC_C/hack/hack.h
0,0 → 1,11
#include <16F88.h>
#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)
//#use rs232(baud=2400,xmit=PIN_B3)
//#use rs232(DEBUGGER)
#use rs232(baud=1200,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8)
 
/programy/C/PIC_C/hack/hack.sta
0,0 → 1,52
 
ROM used: 1587 (41%)
1587 (41%) including unused fragments
 
1 Average locations per line
3 Average locations per statement
 
RAM used: 41 (11%) at main() level
51 (14%) worst case
 
Lines Stmts % Files
----- ----- --- -----
138 101 18 D:\KAKLIK\programy\PIC_C\hack\hack.c
12 0 0 D:\KAKLIK\programy\PIC_C\hack\hack.h
275 0 0 C:\Program Files\PICC\devices\16F88.h
758 324 50 C:\Program Files\PICC\Drivers\stdlib.h
28 0 0 C:\Program Files\PICC\Drivers\stddef.h
417 126 13 C:\Program Files\PICC\Drivers\string.h
28 0 0 C:\Program Files\PICC\Drivers\ctype.h
----- -----
3312 1102 Total
 
Page ROM % RAM Functions:
---- --- --- --- ----------
0 24 2 1 @delay_ms1
0 44 3 1 @PUTCHAR_1_
0 53 3 1 @GETCH_1_
0 22 1 5 @MUL1616
0 256 16 11 atol
0 3 0 0 TIMER1_isr
0 3 0 0 TIMER2_isr
0 15 1 0 @const290
0 753 47 21 main
0 11 1 0 @const11193
0 19 1 0 @const11223
0 106 7 9 @PRINTF_LU_1200_51_50
0 28 2 0 @const11259
0 21 1 3 @DIV88
0 78 5 2 @PRINTF_U_1200_51_50
0 21 1 0 @const11300
0 22 1 0 @const11330
0 21 1 0 @const11344
0 10 1 0 @const11352
0 14 1 0 @const11365
 
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-0003E 59 0
0003F-007FF 1524 461
00800-00EFF 0 1792
 
/programy/C/PIC_C/hack/hack.tre
0,0 → 1,100
ÀÄhack
ÃÄmain 0/753 Ram=21
³ ÃÄ??0??
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@const11193 0/11 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@const290 0/15 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@GETCH_1_ 0/53 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PRINTF_LU_1200_51_50 0/106 Ram=9
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÀÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@const11223 0/19 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PRINTF_LU_1200_51_50 0/106 Ram=9
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÀÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@PRINTF_LU_1200_51_50 0/106 Ram=9
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÀÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@const11259 0/28 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PRINTF_LU_1200_51_50 0/106 Ram=9
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÀÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@const11259 0/28 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PRINTF_U_1200_51_50 0/78 Ram=2
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÃÄ@DIV88 0/21 Ram=3
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÀÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@PRINTF_LU_1200_51_50 0/106 Ram=9
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÀÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@const11300 0/21 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PRINTF_LU_1200_51_50 0/106 Ram=9
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÀÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@const11300 0/21 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÃÄ@const290 0/15 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PRINTF_LU_1200_51_50 0/106 Ram=9
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÀÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@const11330 0/22 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PRINTF_LU_1200_51_50 0/106 Ram=9
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÀÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@const11330 0/22 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄatol 0/256 Ram=11
³ ³ ÀÄ@MUL1616 0/22 Ram=5
³ ÃÄ@PRINTF_LU_1200_51_50 0/106 Ram=9
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÀÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@const11344 0/21 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@const11344 0/21 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@const11352 0/10 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄatol 0/256 Ram=11
³ ³ ÀÄ@MUL1616 0/22 Ram=5
³ ÃÄ@PRINTF_LU_1200_51_50 0/106 Ram=9
³ ³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ³ ÀÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@const11365 0/14 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@const11352 0/10 Ram=0
³ ÃÄ@PUTCHAR_1_ 0/44 Ram=1
³ ÃÄ@delay_ms1 0/24 Ram=1
³ ÀÄ@delay_ms1 0/24 Ram=1
ÃÄTIMER1_isr 0/3 Ram=0
ÀÄTIMER2_isr 0/3 Ram=0