Line 1... |
Line 1... |
1 |
CCS PCM C Compiler, Version 3.245, 27853 08-V-08 23:27 |
1 |
CCS PCM C Compiler, Version 3.245, 27853 11-V-08 00:17 |
2 |
|
2 |
|
3 |
Filename: D:\MLAB_E\projekty\Ovladani_mobilnim_telefonem\SW\final\main.lst |
3 |
Filename: D:\MLAB_E\projekty\Ovladani_mobilnim_telefonem\SW\final\main.lst |
4 |
|
4 |
|
5 |
ROM used: 1505 words (18%) |
5 |
ROM used: 275 words (3%) |
6 |
Largest free fragment is 2048 |
6 |
Largest free fragment is 2048 |
7 |
RAM used: 56 (32%) at main() level |
7 |
RAM used: 52 (30%) at main() level |
8 |
64 (37%) worst case |
8 |
56 (32%) worst case |
9 |
Stack: 4 locations |
9 |
Stack: 1 locations |
10 |
|
10 |
|
11 |
* |
11 |
* |
12 |
0000: MOVLW 00 |
12 |
0000: MOVLW 00 |
13 |
0001: MOVWF 0A |
13 |
0001: MOVWF 0A |
14 |
0002: GOTO 29D |
14 |
0002: GOTO 057 |
15 |
0003: NOP |
15 |
0003: NOP |
16 |
.................... #include ".\main.h" |
16 |
.................... #include ".\main.h" |
17 |
.................... #include <16F876A.h> |
17 |
.................... #include <16F876A.h> |
18 |
.................... //////// Standard Header file for the PIC16F876A device //////////////// |
18 |
.................... //////// Standard Header file for the PIC16F876A device //////////////// |
19 |
.................... #device PIC16F876A |
19 |
.................... #device PIC16F876A |
Line 30... |
Line 30... |
30 |
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
30 |
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
31 |
.................... #FUSES NOCPD //No EE protection |
31 |
.................... #FUSES NOCPD //No EE protection |
32 |
.................... #FUSES NOWRT //Program memory not write protected |
32 |
.................... #FUSES NOWRT //Program memory not write protected |
33 |
.................... |
33 |
.................... |
34 |
.................... #use delay(clock=18432000,RESTART_WDT) |
34 |
.................... #use delay(clock=18432000,RESTART_WDT) |
35 |
* |
- |
|
36 |
0126: MOVLW 52 |
35 |
0013: MOVLW 52 |
37 |
0127: MOVWF 04 |
36 |
0014: MOVWF 04 |
38 |
0128: MOVF 00,W |
37 |
0015: MOVF 00,W |
39 |
0129: BTFSC 03.2 |
38 |
0016: BTFSC 03.2 |
40 |
012A: GOTO 13B |
39 |
0017: GOTO 028 |
41 |
012B: MOVLW 05 |
40 |
0018: MOVLW 05 |
42 |
012C: MOVWF 78 |
41 |
0019: MOVWF 78 |
43 |
012D: MOVLW BF |
42 |
001A: MOVLW BF |
44 |
012E: MOVWF 77 |
43 |
001B: MOVWF 77 |
45 |
012F: CLRWDT |
44 |
001C: CLRWDT |
46 |
0130: DECFSZ 77,F |
45 |
001D: DECFSZ 77,F |
47 |
0131: GOTO 12F |
46 |
001E: GOTO 01C |
48 |
0132: DECFSZ 78,F |
47 |
001F: DECFSZ 78,F |
49 |
0133: GOTO 12D |
48 |
0020: GOTO 01A |
50 |
0134: MOVLW F9 |
49 |
0021: MOVLW F9 |
51 |
0135: MOVWF 77 |
50 |
0022: MOVWF 77 |
52 |
0136: DECFSZ 77,F |
51 |
0023: DECFSZ 77,F |
53 |
0137: GOTO 136 |
52 |
0024: GOTO 023 |
54 |
0138: CLRWDT |
53 |
0025: CLRWDT |
55 |
0139: DECFSZ 00,F |
54 |
0026: DECFSZ 00,F |
56 |
013A: GOTO 12B |
55 |
0027: GOTO 018 |
57 |
013B: RETLW 00 |
56 |
0028: RETLW 00 |
58 |
* |
- |
|
59 |
0153: MOVLW 04 |
- |
|
60 |
0154: SUBWF 58,F |
- |
|
61 |
0155: BTFSS 03.0 |
- |
|
62 |
0156: GOTO 16B |
- |
|
63 |
0157: MOVLW 58 |
- |
|
64 |
0158: MOVWF 04 |
- |
|
65 |
0159: MOVLW F8 |
- |
|
66 |
015A: ANDWF 00,F |
- |
|
67 |
015B: BCF 03.0 |
- |
|
68 |
015C: RRF 00,F |
- |
|
69 |
015D: RRF 00,F |
- |
|
70 |
015E: RRF 00,F |
- |
|
71 |
015F: MOVF 00,W |
- |
|
72 |
0160: BTFSC 03.2 |
- |
|
73 |
0161: GOTO 16B |
- |
|
74 |
0162: MOVLW 0A |
- |
|
75 |
0163: MOVWF 77 |
- |
|
76 |
0164: DECFSZ 77,F |
- |
|
77 |
0165: GOTO 164 |
- |
|
78 |
0166: NOP |
- |
|
79 |
0167: NOP |
- |
|
80 |
0168: CLRWDT |
- |
|
81 |
0169: DECFSZ 00,F |
- |
|
82 |
016A: GOTO 162 |
- |
|
83 |
016B: BCF 0A.3 |
- |
|
84 |
016C: BCF 0A.4 |
- |
|
85 |
016D: GOTO 183 (RETURN) |
- |
|
86 |
.................... #use rs232(STREAM=MOBIL,baud=19200,force_sw,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) |
57 |
.................... #use rs232(STREAM=MOBIL,baud=19200,force_sw,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) |
87 |
* |
58 |
* |
88 |
01C3: BCF 20.6 |
- |
|
89 |
01C4: MOVF 20,W |
- |
|
90 |
01C5: BSF 03.5 |
- |
|
91 |
01C6: MOVWF 07 |
- |
|
92 |
01C7: BCF 03.5 |
- |
|
93 |
01C8: BCF 07.6 |
- |
|
94 |
01C9: MOVLW 08 |
- |
|
95 |
01CA: MOVWF 78 |
- |
|
96 |
01CB: NOP |
- |
|
97 |
01CC: NOP |
- |
|
98 |
01CD: NOP |
- |
|
99 |
01CE: BSF 78.7 |
- |
|
100 |
01CF: GOTO 1DF |
- |
|
101 |
01D0: BCF 78.7 |
- |
|
102 |
01D1: RRF 51,F |
- |
|
103 |
01D2: BTFSC 03.0 |
- |
|
104 |
01D3: BSF 07.6 |
- |
|
105 |
01D4: BTFSS 03.0 |
- |
|
106 |
01D5: BCF 07.6 |
- |
|
107 |
01D6: BSF 78.6 |
- |
|
108 |
01D7: GOTO 1DF |
- |
|
109 |
01D8: BCF 78.6 |
- |
|
110 |
01D9: DECFSZ 78,F |
- |
|
111 |
01DA: GOTO 1D1 |
- |
|
112 |
01DB: NOP |
- |
|
113 |
01DC: NOP |
- |
|
114 |
01DD: NOP |
- |
|
115 |
01DE: BSF 07.6 |
- |
|
116 |
01DF: MOVLW 49 |
- |
|
117 |
01E0: MOVWF 04 |
- |
|
118 |
01E1: DECFSZ 04,F |
- |
|
119 |
01E2: GOTO 1E1 |
- |
|
120 |
01E3: NOP |
- |
|
121 |
01E4: NOP |
- |
|
122 |
01E5: NOP |
- |
|
123 |
01E6: BTFSC 78.7 |
- |
|
124 |
01E7: GOTO 1D0 |
- |
|
125 |
01E8: BTFSC 78.6 |
- |
|
126 |
01E9: GOTO 1D8 |
- |
|
127 |
01EA: BCF 0A.3 |
- |
|
128 |
01EB: BCF 0A.4 |
- |
|
129 |
01EC: GOTO 324 (RETURN) |
- |
|
130 |
01ED: MOVLW 08 |
- |
|
131 |
01EE: MOVWF 77 |
- |
|
132 |
01EF: BSF 20.7 |
- |
|
133 |
01F0: MOVF 20,W |
- |
|
134 |
01F1: BSF 03.5 |
- |
|
135 |
01F2: MOVWF 07 |
- |
|
136 |
01F3: BCF 03.5 |
- |
|
137 |
01F4: BTFSS 07.7 |
- |
|
138 |
01F5: GOTO 1F8 |
- |
|
139 |
01F6: BSF 03.5 |
- |
|
140 |
01F7: GOTO 1F3 |
- |
|
141 |
01F8: CLRF 50 |
- |
|
142 |
01F9: BSF 77.7 |
- |
|
143 |
01FA: GOTO 209 |
- |
|
144 |
01FB: BCF 77.7 |
- |
|
145 |
01FC: GOTO 209 |
- |
|
146 |
01FD: BCF 03.0 |
- |
|
147 |
01FE: BTFSC 07.7 |
- |
|
148 |
01FF: BSF 03.0 |
- |
|
149 |
0200: RRF 50,F |
- |
|
150 |
0201: BSF 77.6 |
- |
|
151 |
0202: GOTO 209 |
- |
|
152 |
0203: BCF 77.6 |
- |
|
153 |
0204: DECFSZ 77,F |
- |
|
154 |
0205: GOTO 1FD |
- |
|
155 |
0206: MOVF 50,W |
- |
|
156 |
0207: MOVWF 78 |
- |
|
157 |
0208: GOTO 216 |
- |
|
158 |
0209: MOVLW 49 |
- |
|
159 |
020A: BTFSC 77.7 |
- |
|
160 |
020B: MOVLW 14 |
- |
|
161 |
020C: MOVWF 78 |
- |
|
162 |
020D: DECFSZ 78,F |
- |
|
163 |
020E: GOTO 20D |
- |
|
164 |
020F: NOP |
- |
|
165 |
0210: NOP |
- |
|
166 |
0211: BTFSC 77.7 |
- |
|
167 |
0212: GOTO 1FB |
- |
|
168 |
0213: BTFSC 77.6 |
- |
|
169 |
0214: GOTO 203 |
- |
|
170 |
0215: GOTO 1FD |
- |
|
171 |
0216: RETLW 00 |
- |
|
172 |
* |
- |
|
173 |
02B1: MOVLW FF |
59 |
006B: MOVLW FF |
174 |
02B2: BCF 03.5 |
60 |
006C: BCF 03.5 |
175 |
02B3: MOVWF 20 |
61 |
006D: MOVWF 20 |
176 |
.................... #use rs232(STREAM=VRTULE,baud=600,parity=N,xmit=PIN_B2,rcv=PIN_B4,bits=8) |
62 |
.................... #use rs232(STREAM=VRTULE,baud=600,parity=N,xmit=PIN_B2,rcv=PIN_B4,bits=8) |
177 |
* |
63 |
* |
178 |
026F: BSF 03.5 |
64 |
0029: BSF 03.5 |
179 |
0270: BCF 06.2 |
65 |
002A: BCF 06.2 |
180 |
0271: BCF 03.5 |
66 |
002B: BCF 03.5 |
181 |
0272: BCF 06.2 |
67 |
002C: BCF 06.2 |
182 |
0273: MOVLW 08 |
68 |
002D: MOVLW 08 |
183 |
0274: MOVWF 78 |
69 |
002E: MOVWF 78 |
184 |
0275: NOP |
70 |
002F: NOP |
185 |
0276: NOP |
71 |
0030: NOP |
186 |
0277: NOP |
72 |
0031: NOP |
187 |
0278: BSF 78.7 |
73 |
0032: BSF 78.7 |
188 |
0279: GOTO 289 |
74 |
0033: GOTO 043 |
189 |
027A: BCF 78.7 |
75 |
0034: BCF 78.7 |
190 |
027B: RRF 51,F |
76 |
0035: RRF 52,F |
191 |
027C: BTFSC 03.0 |
77 |
0036: BTFSC 03.0 |
192 |
027D: BSF 06.2 |
78 |
0037: BSF 06.2 |
193 |
027E: BTFSS 03.0 |
79 |
0038: BTFSS 03.0 |
194 |
027F: BCF 06.2 |
80 |
0039: BCF 06.2 |
195 |
0280: BSF 78.6 |
81 |
003A: BSF 78.6 |
196 |
0281: GOTO 289 |
82 |
003B: GOTO 043 |
197 |
0282: BCF 78.6 |
83 |
003C: BCF 78.6 |
198 |
0283: DECFSZ 78,F |
84 |
003D: DECFSZ 78,F |
199 |
0284: GOTO 27B |
85 |
003E: GOTO 035 |
200 |
0285: NOP |
86 |
003F: NOP |
201 |
0286: NOP |
87 |
0040: NOP |
202 |
0287: NOP |
88 |
0041: NOP |
203 |
0288: BSF 06.2 |
89 |
0042: BSF 06.2 |
204 |
0289: MOVLW 09 |
90 |
0043: MOVLW 09 |
205 |
028A: MOVWF 77 |
91 |
0044: MOVWF 77 |
206 |
028B: CLRF 04 |
92 |
0045: CLRF 04 |
207 |
028C: DECFSZ 04,F |
93 |
0046: DECFSZ 04,F |
208 |
028D: GOTO 28C |
94 |
0047: GOTO 046 |
209 |
028E: DECFSZ 77,F |
95 |
0048: DECFSZ 77,F |
210 |
028F: GOTO 28B |
96 |
0049: GOTO 045 |
211 |
0290: MOVLW F0 |
97 |
004A: MOVLW F0 |
212 |
0291: MOVWF 04 |
98 |
004B: MOVWF 04 |
213 |
0292: DECFSZ 04,F |
99 |
004C: DECFSZ 04,F |
214 |
0293: GOTO 292 |
100 |
004D: GOTO 04C |
215 |
0294: NOP |
101 |
004E: NOP |
216 |
0295: NOP |
102 |
004F: NOP |
217 |
0296: BTFSC 78.7 |
103 |
0050: BTFSC 78.7 |
218 |
0297: GOTO 27A |
104 |
0051: GOTO 034 |
219 |
0298: BTFSC 78.6 |
105 |
0052: BTFSC 78.6 |
220 |
0299: GOTO 282 |
106 |
0053: GOTO 03C |
221 |
029A: BCF 0A.3 |
107 |
0054: BCF 0A.3 |
222 |
029B: BCF 0A.4 |
108 |
0055: BCF 0A.4 |
223 |
029C: GOTO 514 (RETURN) |
109 |
0056: GOTO 102 (RETURN) |
224 |
.................... |
110 |
.................... |
225 |
.................... |
111 |
.................... |
226 |
.................... |
112 |
.................... |
227 |
.................... #define LCD_RS PIN_B1 // rizeni registru LCD displeje |
113 |
.................... #define LCD_RS PIN_B1 // rizeni registru LCD displeje |
228 |
.................... #define LCD_E PIN_B0 // enable LCD displeje |
114 |
.................... #define LCD_E PIN_B0 // enable LCD displeje |
229 |
.................... #define LCD_DATA_LSB PIN_C0 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
115 |
.................... #define LCD_DATA_LSB PIN_C0 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
230 |
.................... #define zar1 PIN_A3 |
116 |
.................... |
231 |
.................... |
117 |
.................... |
232 |
.................... #bit SPEN=0x18.7 |
118 |
.................... #bit SPEN=0x18.7 |
233 |
.................... #bit RCIF=0x0C.5 |
119 |
.................... #bit RCIF=0x0C.5 |
234 |
.................... |
120 |
.................... |
235 |
.................... #include "mylcd.c" |
121 |
.................... #include <stdio.h> |
- |
|
122 |
.................... /////////////////////////////////////////////////////////////////////////// |
- |
|
123 |
.................... //// (C) Copyright 1996,2003 Custom Computer Services //// |
- |
|
124 |
.................... //// This source code may only be used by licensed users of the CCS C //// |
236 |
.................... // LCD modul pro ovladani dvouradkoveho LCD modulu se standardnim Hitachi radicem |
125 |
.................... //// compiler. This source code may only be distributed to other //// |
- |
|
126 |
.................... //// licensed users of the CCS C compiler. No other use, reproduction //// |
- |
|
127 |
.................... //// or distribution is permitted without written permission. //// |
- |
|
128 |
.................... //// Derivative programs created using this software in object code //// |
- |
|
129 |
.................... //// form are not restricted in any way. //// |
- |
|
130 |
.................... /////////////////////////////////////////////////////////////////////////// |
237 |
.................... // (c)miho 2002 |
131 |
.................... |
238 |
.................... // |
132 |
.................... #ifndef _STDIO |
239 |
.................... // Historie: |
133 |
.................... #define _STDIO |
240 |
.................... // |
134 |
.................... #include <string.h> |
- |
|
135 |
.................... //////////////////////////////////////////////////////////////////////////// |
- |
|
136 |
.................... //// (C) Copyright 1996,2003 Custom Computer Services //// |
- |
|
137 |
.................... //// This source code may only be used by licensed users of the CCS C //// |
241 |
.................... // 0.0 Uvodni verze se snadnou definici portu LCD displeje |
138 |
.................... //// compiler. This source code may only be distributed to other //// |
- |
|
139 |
.................... //// licensed users of the CCS C compiler. No other use, reproduction //// |
- |
|
140 |
.................... //// or distribution is permitted without written permission. //// |
- |
|
141 |
.................... //// Derivative programs created using this software in object code //// |
- |
|
142 |
.................... //// form are not restricted in any way. //// |
- |
|
143 |
.................... //////////////////////////////////////////////////////////////////////////// |
242 |
.................... // |
144 |
.................... |
243 |
.................... // |
145 |
.................... #ifndef _STRING |
244 |
.................... // Funkce: |
146 |
.................... #define _STRING |
245 |
.................... // |
147 |
.................... #include <stddef.h> |
246 |
.................... // lcd_init() inicializuje LCD displej a porty, nutno volat jako prvni |
148 |
.................... /////////////////////////////////////////////////////////////////////////// |
247 |
.................... // |
- |
|
248 |
.................... // lcd_putc(c) zapis snaku do lcd displeje, zpracovava nasledujici ridici znaky |
149 |
.................... //// (C) Copyright 1996,2003 Custom Computer Services //// |
249 |
.................... // \f = \x0C - nova stranka - smazani displeje |
150 |
.................... //// This source code may only be used by licensed users of the CCS C //// |
250 |
.................... // \n = \x0A - odradkovani (prechod na druhou radku) |
151 |
.................... //// compiler. This source code may only be distributed to other //// |
251 |
.................... // \b = \x08 - backspace - posunuti kurzoru o 1 pozici zpet |
152 |
.................... //// licensed users of the CCS C compiler. No other use, reproduction //// |
252 |
.................... // \r = \x0D - goto home to position 1,1 |
153 |
.................... //// or distribution is permitted without written permission. //// |
253 |
.................... // \0 .. \7 - definovatelne znaky v pozicich 0 az 7 v CGRAM |
154 |
.................... //// Derivative programs created using this software in object code //// |
254 |
.................... // \20 .. \27 - alternativne zapsane znaky (oktalove) v pozicich 0 az 7 CGRAM |
155 |
.................... //// form are not restricted in any way. //// |
255 |
.................... // Pozor na to, ze funkce printf konci tisk pokud narazi na \0 (konec retezce) |
156 |
.................... /////////////////////////////////////////////////////////////////////////// |
- |
|
157 |
.................... |
- |
|
158 |
.................... #ifndef _STDDEF |
- |
|
159 |
.................... |
- |
|
160 |
.................... #define _STDDEF |
256 |
.................... // |
161 |
.................... |
- |
|
162 |
.................... #if sizeof(int *)==1 |
257 |
.................... // lcd_gotoxy(x,y) presune kurzor na uvedenou adresu |
163 |
.................... #define ptrdiff_t int |
- |
|
164 |
.................... #else |
258 |
.................... // nekontroluje parametry |
165 |
.................... #define ptrdiff_t long |
- |
|
166 |
.................... #endif |
259 |
.................... // |
167 |
.................... |
- |
|
168 |
.................... #define size_t int |
260 |
.................... // lcd_cursor_on zapne kurzor |
169 |
.................... #define wchar_t char |
- |
|
170 |
.................... #define NULL 0 |
- |
|
171 |
.................... |
261 |
.................... // lcd_cursor_off vypne kurzor |
172 |
.................... #define offsetof(s,f) (offsetofbit(s,f)/8) |
- |
|
173 |
.................... |
- |
|
174 |
.................... #endif |
262 |
.................... // |
175 |
.................... |
- |
|
176 |
.................... #include <ctype.h> |
- |
|
177 |
.................... //////////////////////////////////////////////////////////////////////////// |
263 |
.................... // lcd_define_char(Index, Def) Makro, ktere definuje znaky od pozice Index obsahem definicniho |
178 |
.................... //// (C) Copyright 1996,2003 Custom Computer Services //// |
264 |
.................... // retezce Def. Kazdych 8 znaku retezce Def definuje dalsi znak v CGRAM. |
179 |
.................... //// This source code may only be used by licensed users of the CCS C //// |
265 |
.................... // Kapacita CGRAM je celkem 8 znaku s indexem 0 az 7. |
180 |
.................... //// compiler. This source code may only be distributed to other //// |
266 |
.................... // Na konci se provede lcd_gotoxy(1,1). |
181 |
.................... //// licensed users of the CCS C compiler. No other use, reproduction //// |
- |
|
182 |
.................... //// or distribution is permitted without written permission. //// |
267 |
.................... // Na konci teto knihovny je priklad pouziti definovanych znaku |
183 |
.................... //// Derivative programs created using this software in object code //// |
- |
|
184 |
.................... //// form are not restricted in any way. //// |
- |
|
185 |
.................... //////////////////////////////////////////////////////////////////////////// |
268 |
.................... // |
186 |
.................... |
- |
|
187 |
.................... #ifndef _CTYPE |
269 |
.................... // Definice portu: |
188 |
.................... #define _CTYPE |
270 |
.................... // |
189 |
.................... |
271 |
.................... // #DEFINE LCD_RS PIN_B2 // rizeni registru LCD displeje |
190 |
.................... #define islower(x) isamong(x,"abcdefghijklmnopqrstuvwxyz") |
272 |
.................... // #DEFINE LCD_E PIN_B1 // enable LCD displeje |
191 |
.................... #define isupper(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZ") |
273 |
.................... // #DEFINE LCD_DATA_LSB PIN_C2 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
192 |
.................... #define isalnum(x) isamong(x,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") |
- |
|
193 |
.................... #define isalpha(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") |
- |
|
194 |
.................... #define isdigit(x) isamong(x,"0123456789") |
- |
|
195 |
.................... #define isspace(x) (x==' ') |
- |
|
196 |
.................... #define isxdigit(x) isamong(x,"0123456789ABCDEFabcdef") |
- |
|
197 |
.................... #define iscntrl(x) (x<' ') |
- |
|
198 |
.................... #define isprint(x) (x>=' ') |
- |
|
199 |
.................... #define isgraph(x) (x>' ') |
- |
|
200 |
.................... #define ispunct(x) ((x>' ')&&!isalnum(x)) |
- |
|
201 |
.................... |
- |
|
202 |
.................... #endif |
274 |
.................... |
203 |
.................... |
275 |
.................... |
204 |
.................... |
276 |
.................... |
205 |
.................... |
277 |
.................... |
206 |
.................... |
278 |
.................... // Privatni sekce, cist jen v pripade, ze neco nefunguje |
- |
|
279 |
.................... |
207 |
.................... |
- |
|
208 |
.................... ////////////////////////////////////////////// |
- |
|
209 |
.................... //// Uncomment the following define to //// |
- |
|
210 |
.................... //// allow some functions to use a //// |
- |
|
211 |
.................... //// quicker algorithm, but use more ROM //// |
- |
|
212 |
.................... //// //// |
- |
|
213 |
.................... //// #define FASTER_BUT_MORE_ROM //// |
- |
|
214 |
.................... ////////////////////////////////////////////// |
- |
|
215 |
.................... |
- |
|
216 |
.................... |
- |
|
217 |
.................... |
- |
|
218 |
.................... /*Copying functions*/ |
- |
|
219 |
.................... /* standard template: |
- |
|
220 |
.................... void *memmove(void *s1, void *s2, size_t n). |
- |
|
221 |
.................... Copies max of n characters safely (not following ending '\0') |
- |
|
222 |
.................... from s2 in s1; if s2 has less than n characters, appends 0 */ |
280 |
.................... |
223 |
.................... |
- |
|
224 |
.................... char *memmove(void *s1,char *s2,size_t n) |
- |
|
225 |
.................... { |
- |
|
226 |
.................... char *sc1; |
- |
|
227 |
.................... char *sc2; |
- |
|
228 |
.................... sc1=s1; |
- |
|
229 |
.................... sc2=s2; |
- |
|
230 |
.................... if(sc2<sc1 && sc1 <sc2 +n) |
- |
|
231 |
.................... for(sc1+=n,sc2+=n;0<n;--n) |
- |
|
232 |
.................... *--sc1=*--sc2; |
- |
|
233 |
.................... else |
- |
|
234 |
.................... for(;0<n;--n) |
- |
|
235 |
.................... *sc1++=*sc2++; |
- |
|
236 |
.................... return s1; |
- |
|
237 |
.................... } |
- |
|
238 |
.................... |
- |
|
239 |
.................... /* compiler ignored the name 'strcpy()'; perhaps, it's reserved? |
- |
|
240 |
.................... Standard template: char *strcpy(char *s1, const char *s2) |
- |
|
241 |
.................... copies the string s2 including the null character to s1*/ |
281 |
.................... |
242 |
.................... |
- |
|
243 |
.................... char *strcopy(char *s1, char *s2) |
- |
|
244 |
.................... { |
- |
|
245 |
.................... char *s; |
282 |
.................... |
246 |
.................... |
283 |
.................... // Generovane defince portu pro ucely teto knihovny aby kod generoval spravne IO operace a soucasne |
247 |
.................... for (s = s1; *s2 != 0; s++, s2++) { |
284 |
.................... // bylo mozne jednoduse deklarovat pripojene piny LCD displeje pri pouziti teto knihovny. Problem spociva |
248 |
.................... *s = *s2; |
- |
|
249 |
.................... } |
- |
|
250 |
.................... *s = *s2; |
285 |
.................... // v tom, ze se musi spravne ridit smery portu a soucasne datovy port zabira jen 4 bity ze zadaneho portu |
251 |
.................... return(s1); |
286 |
.................... // |
252 |
.................... } |
- |
|
253 |
.................... |
287 |
.................... #DEFINE LCD_SHIFT (LCD_DATA_LSB&7) // pocet bitu posuvu dataoveho kanalu v datovem portu |
254 |
.................... /* standard template: |
288 |
.................... #DEFINE LCD_PORT (LCD_DATA_LSB>>3) // adresa LCD datoveho portu |
255 |
.................... char *strncpy(char *s1, const char *s2, size_t n). |
289 |
.................... #DEFINE LCD_TRIS (LCD_PORT+0x80) // adresa prislusneho TRIS registru |
256 |
.................... Copies max of n characters (not following ending '\0') |
290 |
.................... #DEFINE LCD_MASK (0xF<<LCD_SHIFT) // maska platnych bitu |
257 |
.................... from s2 in s1; if s2 has less than n characters, appends 0 */ |
291 |
.................... // |
258 |
.................... |
292 |
.................... #IF LCD_SHIFT>4 // kontrola mezi |
259 |
.................... char *strncpy(char *s1, char *s2, size_t n) |
293 |
.................... #ERROR LCD data port LSB bit not in range 0..4 |
260 |
.................... { |
294 |
.................... #ENDIF |
261 |
.................... char *s; |
295 |
.................... |
262 |
.................... |
- |
|
263 |
.................... for (s = s1; n > 0 && *s2 != '\0'; n--) |
- |
|
264 |
.................... *s++ = *s2++; |
- |
|
265 |
.................... for (; n > 0; n--) |
- |
|
266 |
.................... *s++ = '\0'; |
296 |
.................... |
267 |
.................... |
297 |
.................... // Definice konstant pro LCD display |
268 |
.................... return(s1); |
298 |
.................... // |
269 |
.................... } |
299 |
.................... #define LCD_CURSOR_ON_ 0x0E // kurzor jako blikajici radka pod znakem |
- |
|
300 |
.................... #define LCD_CURSOR_OFF_ 0x0C // zadny kurzor |
- |
|
301 |
.................... #define LCD_LINE_2 0x40 // adresa 1. znaku 2. radky |
270 |
.................... /***********************************************************/ |
302 |
.................... |
271 |
.................... |
- |
|
272 |
.................... /*concatenation functions*/ |
- |
|
273 |
.................... /* standard template: char *strcat(char *s1, const char *s2) |
- |
|
274 |
.................... appends s2 to s1*/ |
303 |
.................... |
275 |
.................... |
304 |
.................... // Definice rezimu LCD displeje |
- |
|
305 |
.................... // |
- |
|
306 |
.................... BYTE const LCD_INIT_STRING[4] = |
276 |
.................... char *strcat(char *s1, char *s2) |
307 |
.................... { |
277 |
.................... { |
- |
|
278 |
.................... char *s; |
- |
|
279 |
.................... |
308 |
.................... 0x28, // intrfejs 4 bity, 2 radky, font 5x7 |
280 |
.................... for (s = s1; *s != '\0'; ++s); |
309 |
.................... LCD_CURSOR_OFF_, // display on, kurzor off, |
281 |
.................... while(*s2 != '\0') |
- |
|
282 |
.................... { |
310 |
.................... 0x01, // clear displeje |
283 |
.................... *s = *s2; |
- |
|
284 |
.................... ++s; |
311 |
.................... 0x06 // inkrement pozice kurzoru (posun kurzoru doprava) |
285 |
.................... ++s2; |
312 |
.................... }; |
286 |
.................... } |
313 |
.................... |
287 |
.................... |
- |
|
288 |
.................... *s = '\0'; |
- |
|
289 |
.................... return(s1); |
- |
|
290 |
.................... } |
- |
|
291 |
.................... /* standard template: char *strncat(char *s1, char *s2,size_t n) |
- |
|
292 |
.................... appends not more than n characters from s2 to s1*/ |
314 |
.................... |
293 |
.................... |
315 |
.................... // Odesle nibble do displeje (posle data a klikne signalem e) |
- |
|
316 |
.................... // |
- |
|
317 |
.................... void lcd_send_nibble( BYTE n ) |
294 |
.................... char *strncat(char *s1, char *s2, size_t n) |
318 |
.................... { |
295 |
.................... { |
319 |
.................... *LCD_PORT = (*LCD_PORT & ~LCD_MASK) | ((n << LCD_SHIFT) & LCD_MASK); // nastav datove bity portu a ostatni zachovej |
- |
|
320 |
* |
- |
|
321 |
013C: MOVF 07,W |
- |
|
322 |
013D: ANDLW F0 |
- |
|
323 |
013E: MOVWF 59 |
- |
|
324 |
013F: MOVF 58,W |
296 |
.................... char *s; |
325 |
0140: ANDLW 0F |
- |
|
326 |
0141: IORWF 59,W |
297 |
.................... |
327 |
0142: MOVWF 07 |
- |
|
328 |
.................... output_bit(LCD_E,1); // vzestupna hrana |
298 |
.................... for (s = s1; *s != '\0'; ++s); |
329 |
0143: BSF 06.0 |
- |
|
330 |
0144: BSF 03.5 |
- |
|
331 |
0145: BCF 06.0 |
- |
|
332 |
.................... delay_us(100); // pockej alespon 450ns od e nebo alespon 195ns od dat |
299 |
.................... while(*s2 != '\0' && 0<n) |
333 |
0146: CLRWDT |
- |
|
334 |
0147: MOVLW 98 |
- |
|
335 |
0148: MOVWF 77 |
- |
|
336 |
0149: DECFSZ 77,F |
- |
|
337 |
014A: GOTO 149 |
300 |
.................... { |
338 |
014B: NOP |
- |
|
339 |
014C: NOP |
- |
|
340 |
.................... output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us) |
301 |
.................... *s = *s2; |
341 |
014D: BCF 03.5 |
302 |
.................... ++s; |
342 |
014E: BCF 06.0 |
303 |
.................... ++s2; |
343 |
014F: BSF 03.5 |
304 |
.................... --n; |
344 |
0150: BCF 06.0 |
305 |
.................... } |
345 |
.................... } |
306 |
.................... |
346 |
0151: BCF 03.5 |
307 |
.................... *s = '\0'; |
347 |
0152: RETLW 00 |
308 |
.................... return(s1); |
348 |
.................... |
309 |
.................... } |
349 |
.................... |
310 |
.................... |
- |
|
311 |
.................... /***********************************************************/ |
350 |
.................... // Odesle bajt do registru LCD |
312 |
.................... |
351 |
.................... // |
313 |
.................... |
352 |
.................... // Pokud je Adr=0 .. instrukcni registr |
314 |
.................... /*comparison functions*/ |
353 |
.................... // Pokud je Adr=1 .. datovy registr |
315 |
.................... /* standard template: signed int memcmp(void *s1, void *s2). |
- |
|
316 |
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */ |
354 |
.................... // |
317 |
.................... |
355 |
.................... void lcd_send_byte( BOOLEAN Adr, BYTE n ) |
318 |
.................... signed int memcmp(void * s1,char *s2,size_t n) |
356 |
.................... { |
319 |
.................... { |
357 |
.................... output_bit(LCD_RS,Adr); // vyber registr |
- |
|
358 |
* |
- |
|
359 |
016E: MOVF 56,F |
- |
|
360 |
016F: BTFSS 03.2 |
- |
|
361 |
0170: GOTO 173 |
- |
|
362 |
0171: BCF 06.1 |
- |
|
363 |
0172: GOTO 174 |
- |
|
364 |
0173: BSF 06.1 |
- |
|
365 |
0174: BSF 03.5 |
- |
|
366 |
0175: BCF 06.1 |
- |
|
367 |
.................... swap(n); |
- |
|
368 |
0176: BCF 03.5 |
- |
|
369 |
0177: SWAPF 57,F |
- |
|
370 |
.................... lcd_send_nibble(n); // posli horni pulku bajtu |
- |
|
371 |
0178: MOVF 57,W |
- |
|
372 |
0179: MOVWF 58 |
- |
|
373 |
017A: CALL 13C |
- |
|
374 |
.................... swap(n); |
- |
|
375 |
017B: SWAPF 57,F |
- |
|
376 |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu |
- |
|
377 |
017C: MOVF 57,W |
- |
|
378 |
017D: MOVWF 58 |
- |
|
379 |
017E: CALL 13C |
- |
|
380 |
.................... delay_us(200); // minimalni doba na provedeni prikazu |
- |
|
381 |
017F: CLRWDT |
- |
|
382 |
0180: MOVLW C7 |
- |
|
383 |
0181: MOVWF 58 |
- |
|
384 |
0182: GOTO 153 |
- |
|
385 |
.................... } |
- |
|
386 |
0183: RETLW 00 |
- |
|
387 |
.................... |
- |
|
388 |
.................... |
- |
|
389 |
.................... // Provede inicializaci LCD displeje, smaze obsah a nastavi mod displeje |
- |
|
390 |
.................... // |
- |
|
391 |
.................... // Tato procedura se musi volat pred pouzitim ostatnich lcd_ procedur |
- |
|
392 |
.................... // |
- |
|
393 |
.................... void lcd_init() |
- |
|
394 |
.................... { |
- |
|
395 |
.................... |
- |
|
396 |
.................... int i; // pocitadlo cyklu |
- |
|
397 |
.................... |
- |
|
398 |
.................... delay_ms(20); // spozdeni pro provedeni startu displeje po zapnuti napajeni |
- |
|
399 |
0184: MOVLW 14 |
- |
|
400 |
0185: MOVWF 52 |
- |
|
401 |
0186: CALL 126 |
- |
|
402 |
.................... |
- |
|
403 |
.................... *LCD_TRIS = *LCD_TRIS & ~LCD_MASK; // nuluj odpovidajici bity tris registru datoveho portu LCD |
- |
|
404 |
0187: MOVLW F0 |
- |
|
405 |
0188: BSF 03.5 |
- |
|
406 |
0189: ANDWF 07,F |
- |
|
407 |
.................... |
- |
|
408 |
.................... output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav |
- |
|
409 |
018A: BCF 03.5 |
- |
|
410 |
018B: BCF 06.1 |
- |
|
411 |
018C: BSF 03.5 |
- |
|
412 |
018D: BCF 06.1 |
- |
|
413 |
.................... output_bit(LCD_E,0); // nastav jako vystup a nastav klidovy stav |
- |
|
414 |
018E: BCF 03.5 |
- |
|
415 |
018F: BCF 06.0 |
- |
|
416 |
0190: BSF 03.5 |
- |
|
417 |
0191: BCF 06.0 |
- |
|
418 |
.................... |
- |
|
419 |
.................... for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice |
- |
|
420 |
0192: BCF 03.5 |
- |
|
421 |
0193: CLRF 50 |
- |
|
422 |
0194: MOVF 50,W |
- |
|
423 |
0195: SUBLW 02 |
- |
|
424 |
0196: BTFSS 03.0 |
- |
|
425 |
0197: GOTO 1A0 |
- |
|
426 |
.................... { |
- |
|
427 |
.................... delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel |
- |
|
428 |
0198: MOVLW 02 |
- |
|
429 |
0199: MOVWF 52 |
- |
|
430 |
019A: CALL 126 |
- |
|
431 |
.................... lcd_send_nibble(3); // rezim 8 bitu |
- |
|
432 |
019B: MOVLW 03 |
- |
|
433 |
019C: MOVWF 58 |
- |
|
434 |
019D: CALL 13C |
- |
|
435 |
.................... } |
- |
|
436 |
019E: INCF 50,F |
- |
|
437 |
019F: GOTO 194 |
- |
|
438 |
.................... |
- |
|
439 |
.................... delay_us(40); // cas na zpracovani |
- |
|
440 |
01A0: CLRWDT |
- |
|
441 |
01A1: MOVLW 3C |
- |
|
442 |
01A2: MOVWF 77 |
- |
|
443 |
01A3: DECFSZ 77,F |
- |
|
444 |
01A4: GOTO 1A3 |
- |
|
445 |
01A5: NOP |
- |
|
446 |
01A6: NOP |
- |
|
447 |
.................... lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu) |
- |
|
448 |
01A7: MOVLW 02 |
- |
|
449 |
01A8: MOVWF 58 |
- |
|
450 |
01A9: CALL 13C |
- |
|
451 |
.................... delay_us(40); // cas na zpracovani |
- |
|
452 |
01AA: CLRWDT |
- |
|
453 |
01AB: MOVLW 3C |
- |
|
454 |
01AC: MOVWF 77 |
- |
|
455 |
01AD: DECFSZ 77,F |
- |
|
456 |
01AE: GOTO 1AD |
- |
|
457 |
01AF: NOP |
- |
|
458 |
01B0: NOP |
- |
|
459 |
.................... |
- |
|
460 |
.................... for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod) |
- |
|
461 |
01B1: CLRF 50 |
- |
|
462 |
01B2: MOVF 50,W |
- |
|
463 |
01B3: SUBLW 02 |
- |
|
464 |
01B4: BTFSS 03.0 |
- |
|
465 |
01B5: GOTO 1C2 |
- |
|
466 |
.................... { |
- |
|
467 |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]); |
- |
|
468 |
01B6: MOVF 50,W |
- |
|
469 |
01B7: CALL 004 |
- |
|
470 |
01B8: MOVWF 51 |
- |
|
471 |
01B9: CLRF 56 |
- |
|
472 |
01BA: MOVF 51,W |
- |
|
473 |
01BB: MOVWF 57 |
- |
|
474 |
01BC: CALL 16E |
- |
|
475 |
.................... delay_ms(2); |
320 |
.................... char *su1, *su2; |
476 |
01BD: MOVLW 02 |
- |
|
477 |
01BE: MOVWF 52 |
- |
|
478 |
01BF: CALL 126 |
- |
|
479 |
.................... } |
- |
|
480 |
01C0: INCF 50,F |
- |
|
481 |
01C1: GOTO 1B2 |
- |
|
482 |
.................... } |
- |
|
483 |
01C2: RETLW 00 |
- |
|
484 |
.................... |
- |
|
485 |
.................... |
- |
|
486 |
.................... // Proved presun kurzoru |
- |
|
487 |
.................... // |
- |
|
488 |
.................... // Pozice 1.1 je domu |
- |
|
489 |
.................... // |
- |
|
490 |
.................... #separate |
- |
|
491 |
.................... void lcd_gotoxy( BYTE x, BYTE y) |
321 |
.................... for(su1=s1, su2=s2; 0<n; ++su1, ++su2, --n) |
492 |
.................... { |
322 |
.................... { |
- |
|
323 |
.................... if(*su1!=*su2) |
- |
|
324 |
.................... return ((*su1<*su2)?-1:+1); |
- |
|
325 |
.................... } |
- |
|
326 |
.................... return 0; |
- |
|
327 |
.................... } |
- |
|
328 |
.................... |
- |
|
329 |
.................... /* standard template: int strcmp(const char *s1, const char *s2). |
- |
|
330 |
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */ |
493 |
.................... |
331 |
.................... |
- |
|
332 |
.................... signed int strcmp(char *s1, char *s2) |
- |
|
333 |
.................... { |
- |
|
334 |
.................... for (; *s1 == *s2; s1++, s2++) |
- |
|
335 |
.................... if (*s1 == '\0') |
- |
|
336 |
.................... return(0); |
- |
|
337 |
.................... return((*s1 < *s2) ? -1: 1); |
- |
|
338 |
.................... } |
- |
|
339 |
.................... /* standard template: int strcoll(const char *s1, const char *s2). |
- |
|
340 |
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */ |
- |
|
341 |
.................... |
- |
|
342 |
.................... signed int strcoll(char *s1, char *s2) |
- |
|
343 |
.................... { |
- |
|
344 |
.................... for (; *s1 == *s2; s1++, s2++) |
- |
|
345 |
.................... if (*s1 == '\0') |
- |
|
346 |
.................... return(0); |
- |
|
347 |
.................... return((*s1 < *s2) ? -1: 1); |
- |
|
348 |
.................... } |
- |
|
349 |
.................... |
- |
|
350 |
.................... /* standard template: |
- |
|
351 |
.................... int strncmp(const char *s1, const char *s2, size_t n). |
- |
|
352 |
.................... Compares max of n characters (not following 0) from s1 to s2; |
- |
|
353 |
.................... returns same as strcmp */ |
- |
|
354 |
.................... |
- |
|
355 |
.................... signed int strncmp(char *s1, char *s2, size_t n) |
- |
|
356 |
.................... { |
- |
|
357 |
.................... for (; n > 0; s1++, s2++, n--) |
- |
|
358 |
.................... if (*s1 != *s2) |
- |
|
359 |
.................... return((*s1 <*s2) ? -1: 1); |
- |
|
360 |
.................... else if (*s1 == '\0') |
- |
|
361 |
.................... return(0); |
- |
|
362 |
.................... return(0); |
- |
|
363 |
.................... } |
- |
|
364 |
.................... /* standard template: |
- |
|
365 |
.................... int strxfrm(const char *s1, const char *s2, size_t n). |
- |
|
366 |
.................... transforms maximum of n characters from s2 and places them into s1*/ |
- |
|
367 |
.................... size_t strxfrm(char *s1, char *s2, size_t n) |
- |
|
368 |
.................... { |
494 |
.................... BYTE Adr; |
369 |
.................... char *s; |
- |
|
370 |
.................... int n1; |
- |
|
371 |
.................... n1=n; |
- |
|
372 |
.................... for (s = s1; n > 0 && *s2 != '\0'; n--) |
- |
|
373 |
.................... *s++ = *s2++; |
- |
|
374 |
.................... for (; n > 0; n--) |
- |
|
375 |
.................... *s++ = '\0'; |
- |
|
376 |
.................... |
- |
|
377 |
.................... return(n1); |
- |
|
378 |
.................... } |
495 |
.................... |
379 |
.................... |
- |
|
380 |
.................... |
- |
|
381 |
.................... |
- |
|
382 |
.................... |
- |
|
383 |
.................... |
- |
|
384 |
.................... /***********************************************************/ |
- |
|
385 |
.................... /*Search functions*/ |
- |
|
386 |
.................... /* standard template: void *memchr(const char *s, int c). |
- |
|
387 |
.................... Finds first occurrence of c in n characters of s */ |
- |
|
388 |
.................... |
- |
|
389 |
.................... char *memchr(void *s,int c,size_t n) |
- |
|
390 |
.................... { |
- |
|
391 |
.................... char uc; |
- |
|
392 |
.................... char *su; |
- |
|
393 |
.................... uc=c; |
- |
|
394 |
.................... for(su=s;0<n;++su,--n) |
- |
|
395 |
.................... if(*su==uc) |
- |
|
396 |
.................... return su; |
- |
|
397 |
.................... return NULL; |
- |
|
398 |
.................... } |
- |
|
399 |
.................... |
- |
|
400 |
.................... /* standard template: char *strchr(const char *s, int c). |
- |
|
401 |
.................... Finds first occurrence of c in s */ |
- |
|
402 |
.................... |
- |
|
403 |
.................... char *strchr(char *s, int c) |
- |
|
404 |
.................... { |
- |
|
405 |
.................... for (; *s != c; s++) |
- |
|
406 |
.................... if (*s == '\0') |
- |
|
407 |
.................... return(0); |
- |
|
408 |
.................... return(s); |
- |
|
409 |
.................... } |
- |
|
410 |
.................... /* standard template: |
- |
|
411 |
.................... size_t strcspn(const char *s1, const char *s2). |
- |
|
412 |
.................... Computes length of max initial segment of s1 that |
- |
|
413 |
.................... consists entirely of characters NOT from s2*/ |
- |
|
414 |
.................... |
- |
|
415 |
.................... int *strcspn(char *s1, char *s2) |
- |
|
416 |
.................... { |
- |
|
417 |
.................... char *sc1, *sc2; |
- |
|
418 |
.................... |
- |
|
419 |
.................... for (sc1 = s1; *sc1 != 0; sc1++) |
- |
|
420 |
.................... for (sc2 = s2; *sc2 != 0; sc2++) |
- |
|
421 |
.................... if (*sc1 == *sc2) |
- |
|
422 |
.................... return(sc1 - s1); |
- |
|
423 |
.................... return(sc1 - s1); |
- |
|
424 |
.................... } |
- |
|
425 |
.................... /* standard template: |
- |
|
426 |
.................... char *strpbrk(const char *s1, const char *s2). |
- |
|
427 |
.................... Locates first occurence of any character from s2 in s1; |
- |
|
428 |
.................... returns s1 if s2 is empty string */ |
- |
|
429 |
.................... |
- |
|
430 |
.................... char *strpbrk(char *s1, char *s2) |
- |
|
431 |
.................... { |
- |
|
432 |
.................... char *sc1, *sc2; |
- |
|
433 |
.................... |
- |
|
434 |
.................... for (sc1 = s1; *sc1 != 0; sc1++) |
- |
|
435 |
.................... for (sc2 = s2; *sc2 != 0; sc2++) |
- |
|
436 |
.................... if (*sc1 == *sc2) |
- |
|
437 |
.................... return(sc1); |
496 |
.................... switch(y) |
438 |
.................... return(0); |
- |
|
439 |
.................... } |
- |
|
440 |
.................... |
- |
|
441 |
.................... |
- |
|
442 |
.................... /* standard template: char *strrchr(const char *s, int c). |
- |
|
443 |
.................... Finds last occurrence of c in s */ |
- |
|
444 |
.................... |
- |
|
445 |
.................... char *strrchr(char *s, int c) |
- |
|
446 |
.................... { |
- |
|
447 |
.................... char *p; |
- |
|
448 |
.................... |
- |
|
449 |
.................... for (p = 0; ; s++) |
497 |
.................... { |
450 |
.................... { |
498 |
* |
- |
|
499 |
0217: MOVLW 01 |
- |
|
500 |
0218: SUBWF 53,W |
- |
|
501 |
0219: ADDLW FC |
- |
|
502 |
021A: BTFSC 03.0 |
- |
|
503 |
021B: GOTO 229 |
- |
|
504 |
021C: ADDLW 04 |
- |
|
505 |
021D: GOTO 234 |
- |
|
506 |
.................... case 1: Adr=0; break; |
451 |
.................... if (*s == c) |
507 |
021E: CLRF 54 |
- |
|
508 |
021F: GOTO 229 |
- |
|
509 |
.................... case 2: Adr=0x40; break; |
452 |
.................... p = s; |
510 |
0220: MOVLW 40 |
- |
|
511 |
0221: MOVWF 54 |
- |
|
512 |
0222: GOTO 229 |
- |
|
513 |
.................... case 3: Adr=0x14; break; |
453 |
.................... if (*s == '\0') |
514 |
0223: MOVLW 14 |
- |
|
515 |
0224: MOVWF 54 |
- |
|
516 |
0225: GOTO 229 |
- |
|
517 |
.................... case 4: Adr=0x54; break; |
454 |
.................... return(p); |
518 |
0226: MOVLW 54 |
- |
|
519 |
0227: MOVWF 54 |
- |
|
520 |
0228: GOTO 229 |
- |
|
521 |
.................... } |
455 |
.................... } |
522 |
.................... Adr+=x-1; |
- |
|
523 |
0229: MOVLW 01 |
- |
|
524 |
022A: SUBWF 52,W |
- |
|
525 |
022B: ADDWF 54,F |
- |
|
526 |
.................... |
456 |
.................... } |
527 |
.................... lcd_send_byte(0,0x80|Adr); |
457 |
.................... /* computes length of max initial segment of s1 consisting |
528 |
022C: MOVF 54,W |
- |
|
529 |
022D: IORLW 80 |
- |
|
530 |
022E: MOVWF 55 |
- |
|
531 |
022F: CLRF 56 |
- |
|
532 |
0230: MOVF 55,W |
- |
|
533 |
0231: MOVWF 57 |
- |
|
534 |
0232: CALL 16E |
- |
|
535 |
.................... } |
- |
|
536 |
0233: RETLW 00 |
- |
|
537 |
.................... |
- |
|
538 |
.................... |
- |
|
539 |
.................... // Zapis znaku na displej, zpracovani ridicich znaku |
458 |
.................... entirely of characters from s2 */ |
540 |
.................... // |
459 |
.................... |
541 |
.................... #separate |
- |
|
542 |
.................... void lcd_putc( char c) |
460 |
.................... int *strspn(char *s1, char *s2) |
543 |
.................... { |
461 |
.................... { |
- |
|
462 |
.................... char *sc1, *sc2; |
- |
|
463 |
.................... |
- |
|
464 |
.................... for (sc1 = s1; *sc1 != 0; sc1++) |
- |
|
465 |
.................... for (sc2 = s2; ; sc2++) |
- |
|
466 |
.................... if (*sc2 == '\0') |
- |
|
467 |
.................... return(sc1 - s1); |
- |
|
468 |
.................... else if (*sc1 == *sc2) |
- |
|
469 |
.................... break; |
- |
|
470 |
.................... return(sc1 - s1); |
- |
|
471 |
.................... } |
- |
|
472 |
.................... /* standard template: |
- |
|
473 |
.................... char *strstr(const char *s1, const char *s2); |
- |
|
474 |
.................... Locates first occurence of character sequence s2 in s1; |
- |
|
475 |
.................... returns 0 if s2 is empty string |
- |
|
476 |
.................... |
- |
|
477 |
.................... Uncomment #define FASTER_BUT_MORE_ROM at the top of the |
- |
|
478 |
.................... file to use the faster algorithm */ |
- |
|
479 |
.................... char *strstr(char *s1, char *s2) |
- |
|
480 |
.................... { |
- |
|
481 |
.................... char *s, *t; |
- |
|
482 |
.................... |
- |
|
483 |
.................... #ifdef FASTER_BUT_MORE_ROM |
- |
|
484 |
.................... if (*s2 == '\0') |
- |
|
485 |
.................... return(s1); |
- |
|
486 |
.................... #endif |
544 |
.................... |
487 |
.................... |
545 |
.................... switch (c) |
488 |
.................... while (*s1) |
546 |
.................... { |
489 |
.................... { |
547 |
* |
- |
|
548 |
023C: MOVF 51,W |
- |
|
549 |
023D: XORLW 0C |
- |
|
550 |
023E: BTFSC 03.2 |
- |
|
551 |
023F: GOTO 24A |
- |
|
552 |
0240: XORLW 06 |
- |
|
553 |
0241: BTFSC 03.2 |
- |
|
554 |
0242: GOTO 252 |
- |
|
555 |
0243: XORLW 07 |
- |
|
556 |
0244: BTFSC 03.2 |
- |
|
557 |
0245: GOTO 258 |
- |
|
558 |
0246: XORLW 05 |
- |
|
559 |
0247: BTFSC 03.2 |
- |
|
560 |
0248: GOTO 25D |
- |
|
561 |
0249: GOTO 262 |
- |
|
562 |
.................... case '\f' : lcd_send_byte(0,1); // smaz displej |
- |
|
563 |
024A: CLRF 56 |
- |
|
564 |
024B: MOVLW 01 |
- |
|
565 |
024C: MOVWF 57 |
- |
|
566 |
024D: CALL 16E |
- |
|
567 |
.................... delay_ms(2); |
- |
|
568 |
024E: MOVLW 02 |
- |
|
569 |
024F: MOVWF 52 |
- |
|
570 |
0250: CALL 126 |
- |
|
571 |
.................... break; |
490 |
.................... for(s = s1, t = s2; *t && *s == *t; ++s, ++t); |
572 |
0251: GOTO 26E |
- |
|
573 |
.................... case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky |
- |
|
574 |
0252: MOVLW 01 |
- |
|
575 |
0253: MOVWF 52 |
- |
|
576 |
0254: MOVLW 02 |
- |
|
577 |
0255: MOVWF 53 |
- |
|
578 |
0256: CALL 217 |
- |
|
579 |
0257: GOTO 26E |
- |
|
580 |
.................... case '\r' : lcd_gotoxy(1,1); break; // presun home |
- |
|
581 |
0258: MOVLW 01 |
- |
|
582 |
0259: MOVWF 52 |
- |
|
583 |
025A: MOVWF 53 |
- |
|
584 |
025B: CALL 217 |
- |
|
585 |
025C: GOTO 26E |
- |
|
586 |
.................... case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet |
- |
|
587 |
025D: CLRF 56 |
- |
|
588 |
025E: MOVLW 10 |
- |
|
589 |
025F: MOVWF 57 |
- |
|
590 |
0260: CALL 16E |
- |
|
591 |
0261: GOTO 26E |
- |
|
592 |
.................... default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F |
- |
|
593 |
0262: MOVF 51,W |
- |
|
594 |
0263: SUBLW 1F |
- |
|
595 |
0264: BTFSS 03.0 |
- |
|
596 |
0265: GOTO 268 |
- |
|
597 |
0266: MOVLW 07 |
- |
|
598 |
0267: ANDWF 51,F |
- |
|
599 |
.................... lcd_send_byte(1,c); break; // zapis znak |
- |
|
600 |
0268: MOVLW 01 |
- |
|
601 |
0269: MOVWF 56 |
- |
|
602 |
026A: MOVF 51,W |
- |
|
603 |
026B: MOVWF 57 |
- |
|
604 |
026C: CALL 16E |
- |
|
605 |
026D: GOTO 26E |
- |
|
606 |
.................... } |
- |
|
607 |
.................... } |
- |
|
608 |
026E: RETLW 00 |
- |
|
609 |
.................... |
- |
|
610 |
.................... |
- |
|
611 |
.................... // Zapni kurzor |
- |
|
612 |
.................... // |
- |
|
613 |
.................... void lcd_cursor_on() |
- |
|
614 |
.................... { |
- |
|
615 |
.................... lcd_send_byte(0,LCD_CURSOR_ON_); |
- |
|
616 |
.................... } |
- |
|
617 |
.................... |
- |
|
618 |
.................... |
- |
|
619 |
.................... // Vypni kurzor |
- |
|
620 |
.................... // |
- |
|
621 |
.................... void lcd_cursor_off() |
- |
|
622 |
.................... { |
- |
|
623 |
.................... lcd_send_byte(0,LCD_CURSOR_OFF_); |
- |
|
624 |
.................... } |
- |
|
625 |
.................... |
- |
|
626 |
.................... |
- |
|
627 |
.................... // Definice vlastnich fontu |
- |
|
628 |
.................... // |
- |
|
629 |
.................... // Vlastnich definic muze byt jen 8 do pozic 0 az 7 pameti CGRAM radice lcd displeje |
- |
|
630 |
.................... // Pro snadne definovani jsou pripraveny nasledujici definice a na konci souboru je uveden |
- |
|
631 |
.................... // priklad pouziti definovanych znaku. |
- |
|
632 |
.................... |
- |
|
633 |
.................... |
- |
|
634 |
.................... // Pomocna procedura pro posilani ridicich dat do radice displeje |
- |
|
635 |
.................... // |
- |
|
636 |
.................... void lcd_putc2(int Data) |
- |
|
637 |
.................... { |
- |
|
638 |
.................... lcd_send_byte(1,Data); |
- |
|
639 |
.................... } |
- |
|
640 |
.................... |
- |
|
641 |
.................... |
- |
|
642 |
.................... // Pomocne definice pro programovani obsahu CGRAM |
- |
|
643 |
.................... // |
- |
|
644 |
.................... #DEFINE lcd_define_start(Code) lcd_send_byte(0,0x40+(Code<<3)); delay_ms(2) |
- |
|
645 |
.................... #DEFINE lcd_define_def(String) printf(lcd_putc2,String); |
- |
|
646 |
.................... #DEFINE lcd_define_end() lcd_send_byte(0,3); delay_ms(2) |
- |
|
647 |
.................... |
- |
|
648 |
.................... |
- |
|
649 |
.................... // Vlastni vykonne makro pro definovani fontu do pozice Index CGRAM s definicnim retezcem Def |
- |
|
650 |
.................... // |
- |
|
651 |
.................... #DEFINE lcd_define_char(Index, Def) lcd_define_start(Index); lcd_define_def(Def); lcd_define_end(); |
- |
|
652 |
.................... |
- |
|
653 |
.................... |
- |
|
654 |
.................... // Pripravene definice fontu vybranych znaku |
- |
|
655 |
.................... // V tabulce nesmi byt 00 (konec retezce v printf()), misto toho davame 80 |
- |
|
656 |
.................... // |
- |
|
657 |
.................... #DEFINE LCD_CHAR_BAT100 "\x0E\x1F\x1F\x1F\x1F\x1F\x1F\x1F" /* symbol plne baterie */ |
- |
|
658 |
.................... #DEFINE LCD_CHAR_BAT50 "\x0E\x1F\x11\x11\x13\x17\x1F\x1F" /* symbol polovicni baterie */ |
- |
|
659 |
.................... #DEFINE LCD_CHAR_BAT0 "\x0E\x1F\x11\x11\x11\x11\x11\x1F" /* symbol vybite baterie */ |
- |
|
660 |
.................... #DEFINE LCD_CHAR_LUA "\x04\x0E\x11\x11\x1F\x11\x11\x80" /* A s carkou */ |
- |
|
661 |
.................... #DEFINE LCD_CHAR_LLA "\x01\x02\x0E\x01\x1F\x11\x0F\x80" /* a s carkou */ |
- |
|
662 |
.................... #DEFINE LCD_CHAR_HUC "\x0A\x0E\x11\x10\x10\x11\x0E\x80" /* C s hackem */ |
- |
|
663 |
.................... #DEFINE LCD_CHAR_HLC "\x0A\x04\x0E\x10\x10\x11\x0E\x80" /* c s hackem */ |
- |
|
664 |
.................... #DEFINE LCD_CHAR_HUD "\x0A\x1C\x12\x11\x11\x12\x1C\x80" /* D s hackem */ |
- |
|
665 |
.................... #DEFINE LCD_CHAR_HLD "\x05\x03\x0D\x13\x11\x11\x0F\x80" /* d s hackem */ |
- |
|
666 |
.................... #DEFINE LCD_CHAR_LUE "\x04\x1F\x10\x10\x1E\x10\x1F\x80" /* E s carkou */ |
- |
|
667 |
.................... #DEFINE LCD_CHAR_LLE "\x01\x02\x0E\x11\x1F\x10\x0E\x80" /* e s carkou */ |
- |
|
668 |
.................... #DEFINE LCD_CHAR_HUE "\x0A\x1F\x10\x1E\x10\x10\x1F\x80" /* E s hackem */ |
- |
|
669 |
.................... #DEFINE LCD_CHAR_HLE "\x0A\x04\x0E\x11\x1F\x10\x0E\x80" /* e s hackem */ |
- |
|
670 |
.................... #DEFINE LCD_CHAR_LUI "\x04\x0E\x04\x04\x04\x04\x0E\x80" /* I s carkou */ |
- |
|
671 |
.................... #DEFINE LCD_CHAR_LLI "\x02\x04\x80\x0C\x04\x04\x0E\x80" /* i s carkou */ |
- |
|
672 |
.................... #DEFINE LCD_CHAR_HUN "\x0A\x15\x11\x19\x15\x13\x11\x80" /* N s hackem */ |
- |
|
673 |
.................... #DEFINE LCD_CHAR_HLN "\x0A\x04\x16\x19\x11\x11\x11\x80" /* n s hackem */ |
- |
|
674 |
.................... #DEFINE LCD_CHAR_LUO "\x04\x0E\x11\x11\x11\x11\x0E\x80" /* O s carkou */ |
- |
|
675 |
.................... #DEFINE LCD_CHAR_LLO "\x02\x04\x0E\x11\x11\x11\x0E\x80" /* o s carkou */ |
- |
|
676 |
.................... #DEFINE LCD_CHAR_HUR "\x0A\x1E\x11\x1E\x14\x12\x11\x80" /* R s hackem */ |
- |
|
677 |
.................... #DEFINE LCD_CHAR_HLR "\x0A\x04\x16\x19\x10\x10\x10\x80" /* r s hackem */ |
- |
|
678 |
.................... #DEFINE LCD_CHAR_HUS "\x0A\x0F\x10\x0E\x01\x01\x1E\x80" /* S s hackem */ |
- |
|
679 |
.................... #DEFINE LCD_CHAR_HLS "\x0A\x04\x0E\x10\x0E\x01\x1E\x80" /* s s hackem */ |
- |
|
680 |
.................... #DEFINE LCD_CHAR_HUT "\x0A\x1F\x04\x04\x04\x04\x04\x80" /* T s hackem */ |
- |
|
681 |
.................... #DEFINE LCD_CHAR_HLT "\x0A\x0C\x1C\x08\x08\x09\x06\x80" /* t s hackem */ |
- |
|
682 |
.................... #DEFINE LCD_CHAR_LUU "\x02\x15\x11\x11\x11\x11\x0E\x80" /* U s carkou */ |
- |
|
683 |
.................... #DEFINE LCD_CHAR_LLU "\x02\x04\x11\x11\x11\x13\x0D\x80" /* u s carkou */ |
- |
|
684 |
.................... #DEFINE LCD_CHAR_CUU "\x06\x17\x11\x11\x11\x11\x0E\x80" /* U s krouzkem */ |
- |
|
685 |
.................... #DEFINE LCD_CHAR_CLU "\x06\x06\x11\x11\x11\x11\x0E\x80" /* u s krouzkem */ |
- |
|
686 |
.................... #DEFINE LCD_CHAR_LUY "\x02\x15\x11\x0A\x04\x04\x04\x80" /* Y s carkou */ |
- |
|
687 |
.................... #DEFINE LCD_CHAR_LLY "\x02\x04\x11\x11\x0F\x01\x0E\x80" /* y s carkou */ |
- |
|
688 |
.................... #DEFINE LCD_CHAR_HUZ "\x0A\x1F\x01\x02\x04\x08\x1F\x80" /* Z s hackem */ |
- |
|
689 |
.................... #DEFINE LCD_CHAR_HLZ "\x0A\x04\x1F\x02\x04\x08\x1F\x80" /* z s hackem */ |
- |
|
690 |
.................... |
- |
|
691 |
.................... |
- |
|
692 |
.................... // Priklad pouziti definovanych znaku |
- |
|
693 |
.................... // |
- |
|
694 |
.................... // |
- |
|
695 |
.................... //void lcd_sample() |
- |
|
696 |
.................... //{ |
- |
|
697 |
.................... // lcd_define_char(0,LCD_CHAR_BAT50); // Priklad definice znaku baterie do pozice 0 |
- |
|
698 |
.................... // lcd_define_char(2,LCD_CHAR_HLE LCD_CHAR_LUI); // Priklad definice znaku e s hackem a I s carkou od pozice 2 |
- |
|
699 |
.................... // // vsimnete si, ze neni carka mezi retezci s definici (oba retezce definuji |
- |
|
700 |
.................... // // jediny definicni retezec) |
- |
|
701 |
.................... // printf(lcd_putc,"\fZnaky:\20\22\23"); // priklad vypisu znaku z pozice 0, 2 a 3 |
- |
|
702 |
.................... // delay_ms(1000); |
- |
|
703 |
.................... // lcd_define_char(0,LCD_CHAR_BAT0); // Predefinovani tvaru znaku v pozici 0 |
- |
|
704 |
.................... // delay_ms(1000); |
- |
|
705 |
.................... //} |
- |
|
706 |
.................... |
491 |
.................... |
- |
|
492 |
.................... if (*t == '\0') |
- |
|
493 |
.................... return s1; |
- |
|
494 |
.................... ++s1; |
- |
|
495 |
.................... #ifdef FASTER_BUT_MORE_ROM |
- |
|
496 |
.................... while(*s1 != '\0' && *s1 != *s2) |
- |
|
497 |
.................... ++s1; |
- |
|
498 |
.................... #endif |
- |
|
499 |
.................... } |
- |
|
500 |
.................... return 0; |
- |
|
501 |
.................... } |
707 |
.................... |
502 |
.................... |
- |
|
503 |
.................... /* standard template: char *strtok(char *s1, const char *s2). |
708 |
.................... void main() |
504 |
.................... |
- |
|
505 |
.................... Finds next token in s1 delimited by a character from separator |
- |
|
506 |
.................... string s2 (which can be different from call to call). First call |
- |
|
507 |
.................... starts at beginning of s1 searching for first character NOT |
- |
|
508 |
.................... contained in s2; returns 0 if none is found. |
- |
|
509 |
.................... If one is found, it is the start of first token (return value). |
- |
|
510 |
.................... Function then searches from there for a character contained in s2. |
- |
|
511 |
.................... If none is found, current token extends to end of s1, and subsequent |
- |
|
512 |
.................... searches for a token will return 0. If one is found, it is |
- |
|
513 |
.................... overwritten by '\0', which terminates current token. Function saves |
- |
|
514 |
.................... pointer to following character from which next search will start. |
- |
|
515 |
.................... Each subsequent call, with 0 as first argument, starts searching |
- |
|
516 |
.................... from saved pointer */ |
- |
|
517 |
.................... |
- |
|
518 |
.................... char *strtok(char *s1, char *s2) |
709 |
.................... { |
519 |
.................... { |
- |
|
520 |
.................... char *beg, *end; |
- |
|
521 |
.................... static char *save; |
710 |
* |
522 |
* |
711 |
029D: CLRF 04 |
523 |
006E: CLRF 21 |
712 |
029E: MOVLW 1F |
- |
|
713 |
029F: ANDWF 03,F |
- |
|
714 |
02A0: BCF 20.6 |
- |
|
715 |
02A1: MOVF 20,W |
- |
|
716 |
02A2: BSF 03.5 |
- |
|
717 |
02A3: MOVWF 07 |
- |
|
718 |
02A4: BCF 03.5 |
- |
|
719 |
02A5: BSF 07.6 |
- |
|
720 |
02A6: BSF 03.5 |
- |
|
721 |
02A7: BCF 06.2 |
- |
|
722 |
02A8: BCF 03.5 |
- |
|
723 |
02A9: BSF 06.2 |
- |
|
724 |
02AA: BSF 03.5 |
- |
|
725 |
02AB: BSF 1F.0 |
- |
|
726 |
02AC: BSF 1F.1 |
- |
|
727 |
02AD: BSF 1F.2 |
- |
|
728 |
02AE: BCF 1F.3 |
- |
|
729 |
02AF: MOVLW 07 |
- |
|
730 |
02B0: MOVWF 1C |
- |
|
731 |
.................... char odp[40]; |
- |
|
732 |
.................... int pom,pom2,pom3,odkl,odkl2,maskovadlo,status; |
- |
|
733 |
.................... |
524 |
.................... |
734 |
.................... setup_adc_ports(NO_ANALOGS); |
525 |
.................... beg = (s1)? s1: save; |
735 |
* |
- |
|
736 |
02B4: BSF 03.5 |
- |
|
737 |
02B5: BSF 1F.0 |
- |
|
738 |
02B6: BSF 1F.1 |
- |
|
739 |
02B7: BSF 1F.2 |
- |
|
740 |
02B8: BCF 1F.3 |
- |
|
741 |
.................... setup_adc(ADC_OFF); |
526 |
.................... beg += strspn(beg, s2); |
742 |
02B9: BCF 03.5 |
- |
|
743 |
02BA: BCF 1F.0 |
- |
|
744 |
.................... setup_spi(SPI_SS_DISABLED); |
527 |
.................... if (*beg == '\0') |
745 |
02BB: BCF 14.5 |
- |
|
746 |
02BC: BCF 20.5 |
- |
|
747 |
02BD: MOVF 20,W |
- |
|
748 |
02BE: BSF 03.5 |
- |
|
749 |
02BF: MOVWF 07 |
- |
|
750 |
02C0: BCF 03.5 |
- |
|
751 |
02C1: BSF 20.4 |
- |
|
752 |
02C2: MOVF 20,W |
- |
|
753 |
02C3: BSF 03.5 |
- |
|
754 |
02C4: MOVWF 07 |
- |
|
755 |
02C5: BCF 03.5 |
- |
|
756 |
02C6: BCF 20.3 |
- |
|
757 |
02C7: MOVF 20,W |
- |
|
758 |
02C8: BSF 03.5 |
- |
|
759 |
02C9: MOVWF 07 |
- |
|
760 |
02CA: MOVLW 01 |
- |
|
761 |
02CB: BCF 03.5 |
- |
|
762 |
02CC: MOVWF 14 |
- |
|
763 |
02CD: MOVLW 00 |
- |
|
764 |
02CE: BSF 03.5 |
528 |
.................... { |
765 |
02CF: MOVWF 14 |
- |
|
766 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
529 |
.................... *save = ' '; |
767 |
02D0: MOVF 01,W |
- |
|
768 |
02D1: ANDLW C7 |
- |
|
769 |
02D2: IORLW 08 |
- |
|
770 |
02D3: MOVWF 01 |
- |
|
771 |
.................... setup_timer_1(T1_DISABLED); |
530 |
.................... return(0); |
772 |
02D4: BCF 03.5 |
531 |
.................... } |
773 |
02D5: CLRF 10 |
- |
|
774 |
.................... setup_timer_2(T2_DISABLED,0,1); |
532 |
.................... end = strpbrk(beg, s2); |
775 |
02D6: MOVLW 00 |
- |
|
776 |
02D7: MOVWF 78 |
- |
|
777 |
02D8: MOVWF 12 |
- |
|
778 |
02D9: MOVLW 00 |
- |
|
779 |
02DA: BSF 03.5 |
- |
|
780 |
02DB: MOVWF 12 |
- |
|
781 |
.................... setup_comparator(NC_NC_NC_NC); |
533 |
.................... if (*end != '\0') |
782 |
02DC: MOVLW 07 |
- |
|
783 |
02DD: MOVWF 1C |
- |
|
784 |
02DE: MOVF 05,W |
- |
|
785 |
02DF: CLRWDT |
- |
|
786 |
02E0: MOVLW 0E |
- |
|
787 |
02E1: MOVWF 77 |
- |
|
788 |
02E2: DECFSZ 77,F |
- |
|
789 |
02E3: GOTO 2E2 |
534 |
.................... { |
790 |
02E4: NOP |
- |
|
791 |
02E5: NOP |
- |
|
792 |
02E6: MOVF 1C,W |
- |
|
793 |
02E7: BCF 03.5 |
- |
|
794 |
02E8: BCF 0D.6 |
535 |
.................... *end = '\0'; |
795 |
.................... setup_vref(FALSE); |
536 |
.................... end++; |
796 |
02E9: BSF 03.5 |
- |
|
797 |
02EA: CLRF 1D |
537 |
.................... } |
798 |
.................... setup_wdt(WDT_2304MS); |
538 |
.................... save = end; |
799 |
02EB: MOVLW 0F |
- |
|
800 |
02EC: MOVWF 77 |
- |
|
801 |
02ED: MOVLW 07 |
- |
|
802 |
02EE: BCF 03.5 |
- |
|
803 |
02EF: CLRF 01 |
- |
|
804 |
02F0: MOVLW 81 |
- |
|
805 |
02F1: MOVWF 04 |
- |
|
806 |
02F2: MOVF 00,W |
- |
|
807 |
02F3: ANDLW F0 |
- |
|
808 |
02F4: IORLW 07 |
- |
|
809 |
02F5: MOVWF 00 |
- |
|
810 |
02F6: CLRWDT |
- |
|
811 |
02F7: MOVF 00,W |
- |
|
812 |
02F8: ANDLW F7 |
- |
|
813 |
02F9: BTFSC 77.3 |
- |
|
814 |
02FA: ANDLW F0 |
- |
|
815 |
02FB: IORWF 77,W |
- |
|
816 |
02FC: MOVWF 00 |
- |
|
817 |
.................... lcd_init(); |
539 |
.................... return(beg); |
818 |
02FD: CALL 184 |
540 |
.................... } |
819 |
.................... |
541 |
.................... |
- |
|
542 |
.................... /*****************************************************************/ |
- |
|
543 |
.................... /*Miscellaneous functions*/ |
- |
|
544 |
.................... /* standard template |
- |
|
545 |
.................... maps error number in errnum to an error message string |
- |
|
546 |
.................... Returns: Pointer to string |
- |
|
547 |
.................... */ |
- |
|
548 |
.................... #ifdef _ERRNO |
- |
|
549 |
.................... char * strerror(int errnum) |
- |
|
550 |
.................... { |
- |
|
551 |
.................... char s[15]; |
- |
|
552 |
.................... switch( errnum) |
- |
|
553 |
.................... { |
- |
|
554 |
.................... case 0: |
- |
|
555 |
.................... strcpy(s,"no errors"); |
- |
|
556 |
.................... return s; |
- |
|
557 |
.................... case EDOM : |
- |
|
558 |
.................... strcpy(s,"domain error"); |
- |
|
559 |
.................... return s; |
- |
|
560 |
.................... case ERANGE: |
- |
|
561 |
.................... strcpy(s,"range error"); |
- |
|
562 |
.................... return s; |
- |
|
563 |
.................... } |
- |
|
564 |
.................... } |
- |
|
565 |
.................... #ENDIF |
- |
|
566 |
.................... /* standard template: size_t strlen(const char *s). |
- |
|
567 |
.................... Computes length of s1 (preceding terminating 0) */ |
- |
|
568 |
.................... |
- |
|
569 |
.................... int *strlen(char *s) |
- |
|
570 |
.................... { |
- |
|
571 |
.................... char *sc; |
- |
|
572 |
.................... |
- |
|
573 |
.................... for (sc = s; *sc != 0; sc++); |
- |
|
574 |
.................... return(sc - s); |
- |
|
575 |
.................... } |
- |
|
576 |
.................... |
- |
|
577 |
.................... /* standard template: size_t stricmp(const char *s1, const char *s2). |
- |
|
578 |
.................... Compares s1 to s2 ignoring case (upper vs. lower) */ |
- |
|
579 |
.................... |
- |
|
580 |
.................... signed int stricmp(char *s1, char *s2) |
- |
|
581 |
.................... { |
- |
|
582 |
.................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32)); |
- |
|
583 |
.................... s1++, s2++) |
- |
|
584 |
.................... if (*s1 == '\0') |
- |
|
585 |
.................... return(0); |
- |
|
586 |
.................... return((*s1 < *s2) ? -1: 1); |
- |
|
587 |
.................... } |
- |
|
588 |
.................... |
- |
|
589 |
.................... |
- |
|
590 |
.................... /* standard template: char *strlwr(char *s). |
- |
|
591 |
.................... Replaces uppercase letters by lowercase; |
- |
|
592 |
.................... returns pointer to new string s */ |
- |
|
593 |
.................... |
- |
|
594 |
.................... char *strlwr(char *s) |
- |
|
595 |
.................... { |
- |
|
596 |
.................... char *p; |
- |
|
597 |
.................... |
- |
|
598 |
.................... for (p = s; *p != '\0'; p++) |
- |
|
599 |
.................... if (*p >= 'A' && *p <='Z') |
- |
|
600 |
.................... *p += 'a' - 'A'; |
- |
|
601 |
.................... return(s); |
- |
|
602 |
.................... } |
- |
|
603 |
.................... |
- |
|
604 |
.................... |
- |
|
605 |
.................... /************************************************************/ |
- |
|
606 |
.................... |
- |
|
607 |
.................... |
- |
|
608 |
.................... #endif |
- |
|
609 |
.................... |
- |
|
610 |
.................... #ifndef getc |
- |
|
611 |
.................... #define getc getch |
- |
|
612 |
.................... #define getchar getch |
- |
|
613 |
.................... #define puts(s) {printf(s); putchar(13); putchar(10);} |
- |
|
614 |
.................... #define putc putchar |
- |
|
615 |
.................... #endif |
- |
|
616 |
.................... /* maps error number to an error message. Writes a sequence of characters to |
- |
|
617 |
.................... stderr stream thus: if s is not null then string pointed to by s follwed by |
- |
|
618 |
.................... a colon (:) and a space and the appropriate error message returned by strerror |
- |
|
619 |
.................... function with argument errno |
- |
|
620 |
.................... |
- |
|
621 |
.................... Returns: no value |
- |
|
622 |
.................... */ |
- |
|
623 |
.................... |
- |
|
624 |
.................... #ifdef _ERRNO |
- |
|
625 |
.................... void perror(char *s) |
- |
|
626 |
.................... { |
820 |
.................... while(TRUE) |
627 |
.................... if(s) |
- |
|
628 |
.................... fprintf(STDERR,"%s: ",s); |
- |
|
629 |
.................... fprintf(STDERR,"%s\r\n",strerror(errno)); |
- |
|
630 |
.................... } |
- |
|
631 |
.................... #endif |
- |
|
632 |
.................... #endif |
- |
|
633 |
.................... |
- |
|
634 |
.................... #include <string.h> |
- |
|
635 |
.................... //////////////////////////////////////////////////////////////////////////// |
- |
|
636 |
.................... //// (C) Copyright 1996,2003 Custom Computer Services //// |
- |
|
637 |
.................... //// This source code may only be used by licensed users of the CCS C //// |
- |
|
638 |
.................... //// compiler. This source code may only be distributed to other //// |
- |
|
639 |
.................... //// licensed users of the CCS C compiler. No other use, reproduction //// |
- |
|
640 |
.................... //// or distribution is permitted without written permission. //// |
- |
|
641 |
.................... //// Derivative programs created using this software in object code //// |
- |
|
642 |
.................... //// form are not restricted in any way. //// |
- |
|
643 |
.................... //////////////////////////////////////////////////////////////////////////// |
- |
|
644 |
.................... |
- |
|
645 |
.................... #ifndef _STRING |
- |
|
646 |
.................... #define _STRING |
- |
|
647 |
.................... #include <stddef.h> |
- |
|
648 |
.................... #include <ctype.h> |
- |
|
649 |
.................... |
- |
|
650 |
.................... |
- |
|
651 |
.................... |
- |
|
652 |
.................... ////////////////////////////////////////////// |
- |
|
653 |
.................... //// Uncomment the following define to //// |
- |
|
654 |
.................... //// allow some functions to use a //// |
- |
|
655 |
.................... //// quicker algorithm, but use more ROM //// |
- |
|
656 |
.................... //// //// |
- |
|
657 |
.................... //// #define FASTER_BUT_MORE_ROM //// |
- |
|
658 |
.................... ////////////////////////////////////////////// |
- |
|
659 |
.................... |
- |
|
660 |
.................... |
- |
|
661 |
.................... |
- |
|
662 |
.................... /*Copying functions*/ |
- |
|
663 |
.................... /* standard template: |
- |
|
664 |
.................... void *memmove(void *s1, void *s2, size_t n). |
- |
|
665 |
.................... Copies max of n characters safely (not following ending '\0') |
- |
|
666 |
.................... from s2 in s1; if s2 has less than n characters, appends 0 */ |
- |
|
667 |
.................... |
- |
|
668 |
.................... char *memmove(void *s1,char *s2,size_t n) |
- |
|
669 |
.................... { |
- |
|
670 |
.................... char *sc1; |
- |
|
671 |
.................... char *sc2; |
- |
|
672 |
.................... sc1=s1; |
- |
|
673 |
.................... sc2=s2; |
- |
|
674 |
.................... if(sc2<sc1 && sc1 <sc2 +n) |
- |
|
675 |
.................... for(sc1+=n,sc2+=n;0<n;--n) |
- |
|
676 |
.................... *--sc1=*--sc2; |
- |
|
677 |
.................... else |
- |
|
678 |
.................... for(;0<n;--n) |
- |
|
679 |
.................... *sc1++=*sc2++; |
- |
|
680 |
.................... return s1; |
- |
|
681 |
.................... } |
- |
|
682 |
.................... |
- |
|
683 |
.................... /* compiler ignored the name 'strcpy()'; perhaps, it's reserved? |
- |
|
684 |
.................... Standard template: char *strcpy(char *s1, const char *s2) |
- |
|
685 |
.................... copies the string s2 including the null character to s1*/ |
- |
|
686 |
.................... |
- |
|
687 |
.................... char *strcopy(char *s1, char *s2) |
- |
|
688 |
.................... { |
- |
|
689 |
.................... char *s; |
- |
|
690 |
.................... |
- |
|
691 |
.................... for (s = s1; *s2 != 0; s++, s2++) { |
- |
|
692 |
.................... *s = *s2; |
- |
|
693 |
.................... } |
- |
|
694 |
.................... *s = *s2; |
- |
|
695 |
.................... return(s1); |
- |
|
696 |
.................... } |
- |
|
697 |
.................... |
- |
|
698 |
.................... /* standard template: |
- |
|
699 |
.................... char *strncpy(char *s1, const char *s2, size_t n). |
- |
|
700 |
.................... Copies max of n characters (not following ending '\0') |
- |
|
701 |
.................... from s2 in s1; if s2 has less than n characters, appends 0 */ |
- |
|
702 |
.................... |
- |
|
703 |
.................... char *strncpy(char *s1, char *s2, size_t n) |
- |
|
704 |
.................... { |
- |
|
705 |
.................... char *s; |
- |
|
706 |
.................... |
- |
|
707 |
.................... for (s = s1; n > 0 && *s2 != '\0'; n--) |
- |
|
708 |
.................... *s++ = *s2++; |
- |
|
709 |
.................... for (; n > 0; n--) |
- |
|
710 |
.................... *s++ = '\0'; |
- |
|
711 |
.................... |
- |
|
712 |
.................... return(s1); |
- |
|
713 |
.................... } |
- |
|
714 |
.................... /***********************************************************/ |
- |
|
715 |
.................... |
- |
|
716 |
.................... /*concatenation functions*/ |
- |
|
717 |
.................... /* standard template: char *strcat(char *s1, const char *s2) |
- |
|
718 |
.................... appends s2 to s1*/ |
- |
|
719 |
.................... |
- |
|
720 |
.................... char *strcat(char *s1, char *s2) |
- |
|
721 |
.................... { |
- |
|
722 |
.................... char *s; |
- |
|
723 |
.................... |
- |
|
724 |
.................... for (s = s1; *s != '\0'; ++s); |
- |
|
725 |
.................... while(*s2 != '\0') |
821 |
.................... { |
726 |
.................... { |
822 |
.................... restart_wdt(); |
727 |
.................... *s = *s2; |
- |
|
728 |
.................... ++s; |
- |
|
729 |
.................... ++s2; |
823 |
02FE: CLRWDT |
730 |
.................... } |
824 |
.................... |
731 |
.................... |
825 |
.................... output_low(PIN_A4) ; |
- |
|
826 |
02FF: BSF 03.5 |
- |
|
827 |
0300: BCF 05.4 |
- |
|
828 |
0301: BCF 03.5 |
- |
|
829 |
0302: BCF 05.4 |
- |
|
830 |
.................... delay_ms(150); |
732 |
.................... *s = '\0'; |
831 |
0303: MOVLW 96 |
- |
|
832 |
0304: MOVWF 52 |
- |
|
833 |
0305: CALL 126 |
- |
|
834 |
.................... output_high(PIN_A4); |
- |
|
835 |
0306: BSF 03.5 |
- |
|
836 |
0307: BCF 05.4 |
- |
|
837 |
0308: BCF 03.5 |
- |
|
838 |
0309: BSF 05.4 |
- |
|
839 |
.................... delay_ms(150); |
- |
|
840 |
030A: MOVLW 96 |
- |
|
841 |
030B: MOVWF 52 |
- |
|
842 |
030C: CALL 126 |
- |
|
843 |
.................... output_low(PIN_A4) ; |
- |
|
844 |
030D: BSF 03.5 |
- |
|
845 |
030E: BCF 05.4 |
- |
|
846 |
030F: BCF 03.5 |
- |
|
847 |
0310: BCF 05.4 |
- |
|
848 |
.................... delay_ms(150); |
- |
|
849 |
0311: MOVLW 96 |
- |
|
850 |
0312: MOVWF 52 |
- |
|
851 |
0313: CALL 126 |
- |
|
852 |
.................... output_high(PIN_A4); |
- |
|
853 |
0314: BSF 03.5 |
- |
|
854 |
0315: BCF 05.4 |
- |
|
855 |
0316: BCF 03.5 |
- |
|
856 |
0317: BSF 05.4 |
- |
|
857 |
.................... delay_ms(150); |
733 |
.................... return(s1); |
858 |
0318: MOVLW 96 |
- |
|
859 |
0319: MOVWF 52 |
- |
|
860 |
031A: CALL 126 |
- |
|
861 |
.................... |
734 |
.................... } |
862 |
.................... /* |
- |
|
863 |
.................... while(kbhit(MOBIL)) {fgetc(MOBIL); delay_ms(100);} // Preskoc zbytek radku |
735 |
.................... /* standard template: char *strncat(char *s1, char *s2,size_t n) |
864 |
.................... fprintf(MOBIL,"AT\r"); //vycti prijate SMS |
736 |
.................... appends not more than n characters from s2 to s1*/ |
865 |
.................... while(fgetc(MOBIL)!=0x0A); // predkoc prvni radek odpovedi |
- |
|
866 |
.................... |
737 |
.................... |
- |
|
738 |
.................... char *strncat(char *s1, char *s2, size_t n) |
- |
|
739 |
.................... { |
867 |
.................... delay_ms(500); |
740 |
.................... char *s; |
- |
|
741 |
.................... |
868 |
.................... for(pom=0;pom<80;pom++) odp[pom]=0; |
742 |
.................... for (s = s1; *s != '\0'; ++s); |
869 |
.................... fprintf(MOBIL,"AT\r"); //vycti prijate SMS |
743 |
.................... while(*s2 != '\0' && 0<n) |
- |
|
744 |
.................... { |
870 |
.................... odp[0]=fgetc(MOBIL); |
745 |
.................... *s = *s2; |
- |
|
746 |
.................... ++s; |
- |
|
747 |
.................... ++s2; |
- |
|
748 |
.................... --n; |
- |
|
749 |
.................... } |
- |
|
750 |
.................... |
871 |
.................... odp[1]=fgetc(MOBIL); |
751 |
.................... *s = '\0'; |
872 |
.................... odp[2]=fgetc(MOBIL); |
752 |
.................... return(s1); |
- |
|
753 |
.................... } |
- |
|
754 |
.................... |
- |
|
755 |
.................... /***********************************************************/ |
873 |
.................... |
756 |
.................... |
874 |
.................... fprintf(VRTULE,"*%s*\n\r",odp); |
- |
|
875 |
.................... fgetc(MOBIL); |
- |
|
876 |
.................... output_low(PIN_A4); |
- |
|
877 |
.................... fgetc(MOBIL); |
- |
|
878 |
.................... fgetc(MOBIL); |
- |
|
879 |
.................... |
757 |
.................... |
- |
|
758 |
.................... /*comparison functions*/ |
- |
|
759 |
.................... /* standard template: signed int memcmp(void *s1, void *s2). |
- |
|
760 |
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */ |
- |
|
761 |
.................... |
- |
|
762 |
.................... signed int memcmp(void * s1,char *s2,size_t n) |
- |
|
763 |
.................... { |
- |
|
764 |
.................... char *su1, *su2; |
- |
|
765 |
.................... for(su1=s1, su2=s2; 0<n; ++su1, ++su2, --n) |
- |
|
766 |
.................... { |
- |
|
767 |
.................... if(*su1!=*su2) |
- |
|
768 |
.................... return ((*su1<*su2)?-1:+1); |
- |
|
769 |
.................... } |
- |
|
770 |
.................... return 0; |
- |
|
771 |
.................... } |
- |
|
772 |
.................... |
- |
|
773 |
.................... /* standard template: int strcmp(const char *s1, const char *s2). |
- |
|
774 |
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */ |
- |
|
775 |
.................... |
- |
|
776 |
.................... signed int strcmp(char *s1, char *s2) |
- |
|
777 |
.................... { |
- |
|
778 |
.................... for (; *s1 == *s2; s1++, s2++) |
- |
|
779 |
.................... if (*s1 == '\0') |
- |
|
780 |
.................... return(0); |
- |
|
781 |
.................... return((*s1 < *s2) ? -1: 1); |
- |
|
782 |
.................... } |
- |
|
783 |
.................... /* standard template: int strcoll(const char *s1, const char *s2). |
- |
|
784 |
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */ |
- |
|
785 |
.................... |
- |
|
786 |
.................... signed int strcoll(char *s1, char *s2) |
- |
|
787 |
.................... { |
- |
|
788 |
.................... for (; *s1 == *s2; s1++, s2++) |
- |
|
789 |
.................... if (*s1 == '\0') |
- |
|
790 |
.................... return(0); |
- |
|
791 |
.................... return((*s1 < *s2) ? -1: 1); |
- |
|
792 |
.................... } |
- |
|
793 |
.................... |
- |
|
794 |
.................... /* standard template: |
- |
|
795 |
.................... int strncmp(const char *s1, const char *s2, size_t n). |
- |
|
796 |
.................... Compares max of n characters (not following 0) from s1 to s2; |
- |
|
797 |
.................... returns same as strcmp */ |
- |
|
798 |
.................... |
- |
|
799 |
.................... signed int strncmp(char *s1, char *s2, size_t n) |
- |
|
800 |
.................... { |
- |
|
801 |
.................... for (; n > 0; s1++, s2++, n--) |
- |
|
802 |
.................... if (*s1 != *s2) |
- |
|
803 |
.................... return((*s1 <*s2) ? -1: 1); |
- |
|
804 |
.................... else if (*s1 == '\0') |
- |
|
805 |
.................... return(0); |
880 |
.................... delay_ms(1000); |
806 |
.................... return(0); |
- |
|
807 |
.................... } |
- |
|
808 |
.................... /* standard template: |
- |
|
809 |
.................... int strxfrm(const char *s1, const char *s2, size_t n). |
- |
|
810 |
.................... transforms maximum of n characters from s2 and places them into s1*/ |
- |
|
811 |
.................... size_t strxfrm(char *s1, char *s2, size_t n) |
- |
|
812 |
.................... { |
- |
|
813 |
.................... char *s; |
881 |
.................... continue; |
814 |
.................... int n1; |
- |
|
815 |
.................... n1=n; |
- |
|
816 |
.................... for (s = s1; n > 0 && *s2 != '\0'; n--) |
- |
|
817 |
.................... *s++ = *s2++; |
- |
|
818 |
.................... for (; n > 0; n--) |
- |
|
819 |
.................... *s++ = '\0'; |
- |
|
820 |
.................... |
- |
|
821 |
.................... return(n1); |
- |
|
822 |
.................... } |
- |
|
823 |
.................... |
- |
|
824 |
.................... |
- |
|
825 |
.................... |
- |
|
826 |
.................... |
- |
|
827 |
.................... |
- |
|
828 |
.................... /***********************************************************/ |
- |
|
829 |
.................... /*Search functions*/ |
- |
|
830 |
.................... /* standard template: void *memchr(const char *s, int c). |
- |
|
831 |
.................... Finds first occurrence of c in n characters of s */ |
- |
|
832 |
.................... |
- |
|
833 |
.................... char *memchr(void *s,int c,size_t n) |
- |
|
834 |
.................... { |
- |
|
835 |
.................... char uc; |
- |
|
836 |
.................... char *su; |
- |
|
837 |
.................... uc=c; |
- |
|
838 |
.................... for(su=s;0<n;++su,--n) |
- |
|
839 |
.................... if(*su==uc) |
- |
|
840 |
.................... return su; |
- |
|
841 |
.................... return NULL; |
- |
|
842 |
.................... } |
- |
|
843 |
.................... |
- |
|
844 |
.................... /* standard template: char *strchr(const char *s, int c). |
- |
|
845 |
.................... Finds first occurrence of c in s */ |
- |
|
846 |
.................... |
- |
|
847 |
.................... char *strchr(char *s, int c) |
- |
|
848 |
.................... { |
- |
|
849 |
.................... for (; *s != c; s++) |
- |
|
850 |
.................... if (*s == '\0') |
- |
|
851 |
.................... return(0); |
- |
|
852 |
.................... return(s); |
- |
|
853 |
.................... } |
- |
|
854 |
.................... /* standard template: |
- |
|
855 |
.................... size_t strcspn(const char *s1, const char *s2). |
- |
|
856 |
.................... Computes length of max initial segment of s1 that |
- |
|
857 |
.................... consists entirely of characters NOT from s2*/ |
- |
|
858 |
.................... |
- |
|
859 |
.................... int *strcspn(char *s1, char *s2) |
- |
|
860 |
.................... { |
- |
|
861 |
.................... char *sc1, *sc2; |
- |
|
862 |
.................... |
- |
|
863 |
.................... for (sc1 = s1; *sc1 != 0; sc1++) |
- |
|
864 |
.................... for (sc2 = s2; *sc2 != 0; sc2++) |
- |
|
865 |
.................... if (*sc1 == *sc2) |
- |
|
866 |
.................... return(sc1 - s1); |
- |
|
867 |
.................... return(sc1 - s1); |
- |
|
868 |
.................... } |
- |
|
869 |
.................... /* standard template: |
- |
|
870 |
.................... char *strpbrk(const char *s1, const char *s2). |
- |
|
871 |
.................... Locates first occurence of any character from s2 in s1; |
- |
|
872 |
.................... returns s1 if s2 is empty string */ |
- |
|
873 |
.................... |
- |
|
874 |
.................... char *strpbrk(char *s1, char *s2) |
- |
|
875 |
.................... { |
- |
|
876 |
.................... char *sc1, *sc2; |
- |
|
877 |
.................... |
- |
|
878 |
.................... for (sc1 = s1; *sc1 != 0; sc1++) |
- |
|
879 |
.................... for (sc2 = s2; *sc2 != 0; sc2++) |
- |
|
880 |
.................... if (*sc1 == *sc2) |
- |
|
881 |
.................... return(sc1); |
- |
|
882 |
.................... return(0); |
- |
|
883 |
.................... } |
- |
|
884 |
.................... |
- |
|
885 |
.................... |
- |
|
886 |
.................... /* standard template: char *strrchr(const char *s, int c). |
- |
|
887 |
.................... Finds last occurrence of c in s */ |
- |
|
888 |
.................... |
- |
|
889 |
.................... char *strrchr(char *s, int c) |
- |
|
890 |
.................... { |
- |
|
891 |
.................... char *p; |
- |
|
892 |
.................... |
- |
|
893 |
.................... for (p = 0; ; s++) |
- |
|
894 |
.................... { |
- |
|
895 |
.................... if (*s == c) |
- |
|
896 |
.................... p = s; |
- |
|
897 |
.................... if (*s == '\0') |
- |
|
898 |
.................... return(p); |
- |
|
899 |
.................... } |
- |
|
900 |
.................... } |
- |
|
901 |
.................... /* computes length of max initial segment of s1 consisting |
- |
|
902 |
.................... entirely of characters from s2 */ |
- |
|
903 |
.................... |
- |
|
904 |
.................... int *strspn(char *s1, char *s2) |
- |
|
905 |
.................... { |
- |
|
906 |
.................... char *sc1, *sc2; |
- |
|
907 |
.................... |
- |
|
908 |
.................... for (sc1 = s1; *sc1 != 0; sc1++) |
- |
|
909 |
.................... for (sc2 = s2; ; sc2++) |
- |
|
910 |
.................... if (*sc2 == '\0') |
- |
|
911 |
.................... return(sc1 - s1); |
- |
|
912 |
.................... else if (*sc1 == *sc2) |
- |
|
913 |
.................... break; |
- |
|
914 |
.................... return(sc1 - s1); |
- |
|
915 |
.................... } |
- |
|
916 |
.................... /* standard template: |
- |
|
917 |
.................... char *strstr(const char *s1, const char *s2); |
- |
|
918 |
.................... Locates first occurence of character sequence s2 in s1; |
- |
|
919 |
.................... returns 0 if s2 is empty string |
- |
|
920 |
.................... |
- |
|
921 |
.................... Uncomment #define FASTER_BUT_MORE_ROM at the top of the |
- |
|
922 |
.................... file to use the faster algorithm */ |
- |
|
923 |
.................... char *strstr(char *s1, char *s2) |
- |
|
924 |
.................... { |
- |
|
925 |
.................... char *s, *t; |
- |
|
926 |
.................... |
- |
|
927 |
.................... #ifdef FASTER_BUT_MORE_ROM |
- |
|
928 |
.................... if (*s2 == '\0') |
- |
|
929 |
.................... return(s1); |
- |
|
930 |
.................... #endif |
- |
|
931 |
.................... |
- |
|
932 |
.................... while (*s1) |
- |
|
933 |
.................... { |
- |
|
934 |
.................... for(s = s1, t = s2; *t && *s == *t; ++s, ++t); |
- |
|
935 |
.................... |
- |
|
936 |
.................... if (*t == '\0') |
- |
|
937 |
.................... return s1; |
- |
|
938 |
.................... ++s1; |
- |
|
939 |
.................... #ifdef FASTER_BUT_MORE_ROM |
- |
|
940 |
.................... while(*s1 != '\0' && *s1 != *s2) |
- |
|
941 |
.................... ++s1; |
- |
|
942 |
.................... #endif |
- |
|
943 |
.................... } |
- |
|
944 |
.................... return 0; |
- |
|
945 |
.................... } |
- |
|
946 |
.................... |
- |
|
947 |
.................... /* standard template: char *strtok(char *s1, const char *s2). |
- |
|
948 |
.................... |
- |
|
949 |
.................... Finds next token in s1 delimited by a character from separator |
- |
|
950 |
.................... string s2 (which can be different from call to call). First call |
- |
|
951 |
.................... starts at beginning of s1 searching for first character NOT |
- |
|
952 |
.................... contained in s2; returns 0 if none is found. |
- |
|
953 |
.................... If one is found, it is the start of first token (return value). |
- |
|
954 |
.................... Function then searches from there for a character contained in s2. |
- |
|
955 |
.................... If none is found, current token extends to end of s1, and subsequent |
- |
|
956 |
.................... searches for a token will return 0. If one is found, it is |
- |
|
957 |
.................... overwritten by '\0', which terminates current token. Function saves |
- |
|
958 |
.................... pointer to following character from which next search will start. |
- |
|
959 |
.................... Each subsequent call, with 0 as first argument, starts searching |
- |
|
960 |
.................... from saved pointer */ |
- |
|
961 |
.................... |
- |
|
962 |
.................... char *strtok(char *s1, char *s2) |
- |
|
963 |
.................... { |
- |
|
964 |
.................... char *beg, *end; |
- |
|
965 |
.................... static char *save; |
- |
|
966 |
.................... |
- |
|
967 |
.................... beg = (s1)? s1: save; |
- |
|
968 |
.................... beg += strspn(beg, s2); |
- |
|
969 |
.................... if (*beg == '\0') |
- |
|
970 |
.................... { |
- |
|
971 |
.................... *save = ' '; |
- |
|
972 |
.................... return(0); |
- |
|
973 |
.................... } |
- |
|
974 |
.................... end = strpbrk(beg, s2); |
- |
|
975 |
.................... if (*end != '\0') |
- |
|
976 |
.................... { |
- |
|
977 |
.................... *end = '\0'; |
- |
|
978 |
.................... end++; |
- |
|
979 |
.................... } |
- |
|
980 |
.................... save = end; |
- |
|
981 |
.................... return(beg); |
- |
|
982 |
.................... } |
- |
|
983 |
.................... |
- |
|
984 |
.................... /*****************************************************************/ |
- |
|
985 |
.................... /*Miscellaneous functions*/ |
- |
|
986 |
.................... /* standard template |
- |
|
987 |
.................... maps error number in errnum to an error message string |
- |
|
988 |
.................... Returns: Pointer to string |
882 |
.................... */ |
989 |
.................... */ |
- |
|
990 |
.................... #ifdef _ERRNO |
883 |
.................... fprintf(MOBIL,"AT+CMGL=1\r"); //vycti prijate SMS (0=nove;1=vsechny) |
991 |
.................... char * strerror(int errnum) |
884 |
031B: CLRF 50 |
992 |
.................... { |
885 |
031C: MOVF 50,W |
993 |
.................... char s[15]; |
- |
|
994 |
.................... switch( errnum) |
886 |
031D: CALL 00C |
995 |
.................... { |
887 |
031E: IORLW 00 |
996 |
.................... case 0: |
- |
|
997 |
.................... strcpy(s,"no errors"); |
- |
|
998 |
.................... return s; |
888 |
031F: BTFSC 03.2 |
999 |
.................... case EDOM : |
- |
|
1000 |
.................... strcpy(s,"domain error"); |
889 |
0320: GOTO 325 |
1001 |
.................... return s; |
890 |
0321: INCF 50,F |
1002 |
.................... case ERANGE: |
- |
|
1003 |
.................... strcpy(s,"range error"); |
891 |
0322: MOVWF 51 |
1004 |
.................... return s; |
892 |
0323: GOTO 1C3 |
1005 |
.................... } |
893 |
0324: GOTO 31C |
1006 |
.................... } |
894 |
.................... //SPEN=1; |
1007 |
.................... #ENDIF |
- |
|
1008 |
.................... /* standard template: size_t strlen(const char *s). |
- |
|
1009 |
.................... Computes length of s1 (preceding terminating 0) */ |
895 |
.................... |
1010 |
.................... |
- |
|
1011 |
.................... int *strlen(char *s) |
- |
|
1012 |
.................... { |
- |
|
1013 |
.................... char *sc; |
896 |
.................... |
1014 |
.................... |
897 |
.................... while(fgetc(MOBIL)!=0x0A); // predkoc prvni radek odpovedi |
1015 |
.................... for (sc = s; *sc != 0; sc++); |
898 |
0325: CALL 1ED |
- |
|
899 |
0326: MOVF 78,W |
1016 |
.................... return(sc - s); |
900 |
0327: SUBLW 0A |
- |
|
901 |
0328: BTFSS 03.2 |
1017 |
.................... } |
902 |
0329: GOTO 325 |
- |
|
903 |
.................... |
1018 |
.................... |
904 |
.................... odp[0]=fgetc(MOBIL); // Nacti prvni dva znaky druheho radku odpovedi |
1019 |
.................... /* standard template: size_t stricmp(const char *s1, const char *s2). |
905 |
032A: CALL 1ED |
1020 |
.................... Compares s1 to s2 ignoring case (upper vs. lower) */ |
906 |
032B: MOVF 78,W |
1021 |
.................... |
907 |
032C: MOVWF 21 |
1022 |
.................... signed int stricmp(char *s1, char *s2) |
908 |
.................... odp[1]=fgetc(MOBIL); |
1023 |
.................... { |
909 |
032D: CALL 1ED |
1024 |
.................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32)); |
910 |
032E: MOVF 78,W |
1025 |
.................... s1++, s2++) |
911 |
032F: MOVWF 22 |
1026 |
.................... if (*s1 == '\0') |
912 |
.................... while(fgetc(MOBIL)!=0x0A); // Preskoc zbytek radku |
1027 |
.................... return(0); |
913 |
0330: CALL 1ED |
1028 |
.................... return((*s1 < *s2) ? -1: 1); |
914 |
0331: MOVF 78,W |
1029 |
.................... } |
915 |
0332: SUBLW 0A |
1030 |
.................... |
916 |
0333: BTFSS 03.2 |
1031 |
.................... |
917 |
0334: GOTO 330 |
1032 |
.................... /* standard template: char *strlwr(char *s). |
918 |
.................... |
1033 |
.................... Replaces uppercase letters by lowercase; |
919 |
.................... // while(kbhit(MOBIL)) {fgetc(MOBIL); delay_ms(100);} // Preskoc zbytek radku |
1034 |
.................... returns pointer to new string s */ |
920 |
.................... output_high(PIN_A4); |
1035 |
.................... |
921 |
0335: BSF 03.5 |
1036 |
.................... char *strlwr(char *s) |
922 |
0336: BCF 05.4 |
1037 |
.................... { |
923 |
0337: BCF 03.5 |
1038 |
.................... char *p; |
924 |
0338: BSF 05.4 |
1039 |
.................... |
925 |
.................... |
1040 |
.................... for (p = s; *p != '\0'; p++) |
926 |
.................... |
1041 |
.................... if (*p >= 'A' && *p <='Z') |
927 |
.................... if(odp[0] == 79 && odp[1] ==75) // Je odpoved "OK"? |
1042 |
.................... *p += 'a' - 'A'; |
928 |
0339: MOVF 21,W |
1043 |
.................... return(s); |
929 |
033A: SUBLW 4F |
1044 |
.................... } |
930 |
033B: BTFSS 03.2 |
1045 |
.................... |
931 |
033C: GOTO 384 |
1046 |
.................... |
932 |
033D: MOVF 22,W |
1047 |
.................... /************************************************************/ |
933 |
033E: SUBLW 4B |
1048 |
.................... |
934 |
033F: BTFSS 03.2 |
1049 |
.................... |
935 |
0340: GOTO 384 |
1050 |
.................... #endif |
936 |
.................... { |
1051 |
.................... |
937 |
.................... lcd_gotoxy(1,1); |
1052 |
.................... #include <stdlib.h> |
938 |
0341: MOVLW 01 |
1053 |
.................... /////////////////////////////////////////////////////////////////////////// |
939 |
0342: MOVWF 52 |
1054 |
.................... //// (C) Copyright 1996,2003 Custom Computer Services //// |
940 |
0343: MOVWF 53 |
1055 |
.................... //// This source code may only be used by licensed users of the CCS C //// |
941 |
0344: CALL 217 |
1056 |
.................... //// compiler. This source code may only be distributed to other //// |
942 |
.................... printf(lcd_putc,"\fNeni nova SMS zprava"); |
1057 |
.................... //// licensed users of the CCS C compiler. No other use, reproduction //// |
943 |
0345: CLRF 50 |
1058 |
.................... //// or distribution is permitted without written permission. //// |
944 |
0346: MOVF 50,W |
1059 |
.................... //// Derivative programs created using this software in object code //// |
945 |
0347: CALL 01B |
1060 |
.................... //// form are not restricted in any way. //// |
946 |
0348: IORLW 00 |
1061 |
.................... /////////////////////////////////////////////////////////////////////////// |
947 |
0349: BTFSC 03.2 |
1062 |
.................... |
948 |
034A: GOTO 34F |
1063 |
.................... #ifndef _STDLIB |
949 |
034B: INCF 50,F |
1064 |
.................... #define _STDLIB |
950 |
034C: MOVWF 51 |
1065 |
.................... |
951 |
034D: CALL 23C |
1066 |
.................... //--------------------------------------------------------------------------- |
952 |
034E: GOTO 346 |
1067 |
.................... // Definitions and types |
953 |
.................... lcd_gotoxy(1,2); |
1068 |
.................... //--------------------------------------------------------------------------- |
954 |
034F: MOVLW 01 |
1069 |
.................... |
955 |
0350: MOVWF 52 |
1070 |
.................... #ifndef RAND_MAX |
956 |
0351: MOVLW 02 |
1071 |
.................... #define RAND_MAX 32767 // The value of which is the maximum value |
957 |
0352: MOVWF 53 |
1072 |
.................... // ... returned by the rand function |
958 |
0353: CALL 217 |
1073 |
.................... #endif |
959 |
.................... printf(lcd_putc,""); |
1074 |
.................... |
960 |
0354: CLRF 50 |
1075 |
.................... typedef struct { |
961 |
0355: MOVF 50,W |
1076 |
.................... signed int quot; |
962 |
0356: CALL 035 |
1077 |
.................... signed int rem; |
963 |
0357: IORLW 00 |
1078 |
.................... } div_t; |
964 |
0358: BTFSC 03.2 |
1079 |
.................... |
965 |
0359: GOTO 35E |
1080 |
.................... typedef struct { |
966 |
035A: INCF 50,F |
1081 |
.................... signed long quot; |
967 |
035B: MOVWF 51 |
1082 |
.................... signed long rem; |
968 |
035C: CALL 23C |
1083 |
.................... } ldiv_t; |
969 |
035D: GOTO 355 |
1084 |
.................... |
970 |
.................... lcd_gotoxy(1,3); |
1085 |
.................... #include <stddef.h> |
971 |
035E: MOVLW 01 |
1086 |
.................... /////////////////////////////////////////////////////////////////////////// |
972 |
035F: MOVWF 52 |
1087 |
.................... //// (C) Copyright 1996,2003 Custom Computer Services //// |
973 |
0360: MOVLW 03 |
1088 |
.................... //// This source code may only be used by licensed users of the CCS C //// |
974 |
0361: MOVWF 53 |
1089 |
.................... //// compiler. This source code may only be distributed to other //// |
975 |
0362: CALL 217 |
1090 |
.................... //// licensed users of the CCS C compiler. No other use, reproduction //// |
976 |
.................... printf(lcd_putc,"Zaslete SMS na cislo"); |
1091 |
.................... //// or distribution is permitted without written permission. //// |
977 |
0363: CLRF 50 |
1092 |
.................... //// Derivative programs created using this software in object code //// |
978 |
0364: MOVF 50,W |
1093 |
.................... //// form are not restricted in any way. //// |
979 |
0365: CALL 03A |
1094 |
.................... /////////////////////////////////////////////////////////////////////////// |
980 |
0366: IORLW 00 |
1095 |
.................... |
981 |
0367: BTFSC 03.2 |
1096 |
.................... #ifndef _STDDEF |
982 |
0368: GOTO 36D |
1097 |
.................... |
983 |
0369: INCF 50,F |
1098 |
.................... #define _STDDEF |
984 |
036A: MOVWF 51 |
1099 |
.................... |
985 |
036B: CALL 23C |
1100 |
.................... #if sizeof(int *)==1 |
986 |
036C: GOTO 364 |
1101 |
.................... #define ptrdiff_t int |
987 |
.................... lcd_gotoxy(1,4); |
1102 |
.................... #else |
988 |
036D: MOVLW 01 |
1103 |
.................... #define ptrdiff_t long |
989 |
036E: MOVWF 52 |
1104 |
.................... #endif |
990 |
036F: MOVLW 04 |
1105 |
.................... |
991 |
0370: MOVWF 53 |
1106 |
.................... #define size_t int |
992 |
0371: CALL 217 |
1107 |
.................... #define wchar_t char |
993 |
.................... printf(lcd_putc," 736 655 250"); |
1108 |
.................... #define NULL 0 |
994 |
0372: CLRF 50 |
1109 |
.................... |
995 |
0373: MOVF 50,W |
1110 |
.................... #define offsetof(s,f) (offsetofbit(s,f)/8) |
996 |
0374: CALL 053 |
1111 |
.................... |
997 |
0375: IORLW 00 |
1112 |
.................... #endif |
998 |
0376: BTFSC 03.2 |
1113 |
.................... |
999 |
0377: GOTO 37C |
1114 |
.................... |
1000 |
0378: INCF 50,F |
1115 |
.................... //--------------------------------------------------------------------------- |
1001 |
0379: MOVWF 51 |
1116 |
.................... // String conversion functions |
1002 |
037A: CALL 23C |
1117 |
.................... //--------------------------------------------------------------------------- |
1003 |
037B: GOTO 373 |
1118 |
.................... |
1004 |
.................... delay_ms(5000); |
1119 |
.................... /* Standard template: float atof(char * s) |
1005 |
037C: MOVLW 14 |
1120 |
.................... * converts the initial portion of the string s to a float. |
1006 |
037D: MOVWF 50 |
1121 |
.................... * returns the converted value if any, 0 otherwise |
1007 |
037E: MOVLW FA |
1122 |
.................... */ |
1008 |
037F: MOVWF 52 |
1123 |
.................... float atof(char * s); |
1009 |
0380: CALL 126 |
1124 |
.................... |
1010 |
0381: DECFSZ 50,F |
1125 |
.................... /* Standard template: float atoe(char * s) |
1011 |
0382: GOTO 37E |
1126 |
.................... * converts the initial portion of the string s to a float. |
- |
|
1127 |
.................... * returns the converted value if any, 0 otherwise |
- |
|
1128 |
.................... * also handles E format numbers |
- |
|
1129 |
.................... */ |
- |
|
1130 |
.................... float atoe(char * s); |
- |
|
1131 |
.................... |
- |
|
1132 |
.................... /* Standard template: signed int atoi(char * s) |
- |
|
1133 |
.................... * converts the initial portion of the string s to a signed int |
- |
|
1134 |
.................... * returns the converted value if any, 0 otherwise |
- |
|
1135 |
.................... */ |
- |
|
1136 |
.................... signed int atoi(char *s); |
- |
|
1137 |
.................... |
- |
|
1138 |
.................... /* Syntax: signed int32 atoi32(char * s) |
- |
|
1139 |
.................... converts the initial portion of the string s to a signed int32 |
- |
|
1140 |
.................... returns the converted value if any, 0 otherwise*/ |
- |
|
1141 |
.................... signed int32 atoi32(char *s); |
- |
|
1142 |
.................... |
- |
|
1143 |
.................... /* Syntax: char * itoa(signed int32 num, int8 base, char * s) |
- |
|
1144 |
.................... converts the signed int32 to a string and |
- |
|
1145 |
.................... returns the converted value if any, 0 otherwise*/ |
- |
|
1146 |
.................... char * itoa(signed int32 num, int8 base, char * s); |
- |
|
1147 |
.................... |
- |
|
1148 |
.................... /* Standard template: signed long atol(char * s) |
- |
|
1149 |
.................... * converts the initial portion of the string s to a signed long |
- |
|
1150 |
.................... * returns the converted value if any, 0 otherwise |
- |
|
1151 |
.................... */ |
- |
|
1152 |
.................... signed long atol(char *s); |
- |
|
1153 |
.................... |
- |
|
1154 |
.................... /* Standard template: float strtol(char * s,char *endptr) |
- |
|
1155 |
.................... * converts the initial portion of the string s to a float |
- |
|
1156 |
.................... * returns the converted value if any, 0 otherwise |
- |
|
1157 |
.................... * the final string is returned in the endptr, if endptr is not null |
- |
|
1158 |
.................... */ |
- |
|
1159 |
.................... float strtod(char *s,char *endptr); |
- |
|
1160 |
.................... |
- |
|
1161 |
.................... /* Standard template: long strtoul(char * s,char *endptr,signed int base) |
- |
|
1162 |
.................... * converts the initial portion of the string s, represented as an |
- |
|
1163 |
.................... * integral value of radix base to a signed long. |
- |
|
1164 |
.................... * Returns the converted value if any, 0 otherwise |
- |
|
1165 |
.................... * the final string is returned in the endptr, if endptr is not null |
- |
|
1166 |
.................... */ |
- |
|
1167 |
.................... signed long strtol(char *s,char *endptr,signed int base); |
- |
|
1168 |
.................... |
- |
|
1169 |
.................... /* Standard template: long strtoul(char * s,char *endptr,signed int base) |
- |
|
1170 |
.................... * converts the initial portion of the string s, represented as an |
- |
|
1171 |
.................... * integral value of radix base to a unsigned long. |
- |
|
1172 |
.................... * returns the converted value if any, 0 otherwise |
- |
|
1173 |
.................... * the final string is returned in the endptr, if endptr is not null |
- |
|
1174 |
.................... */ |
- |
|
1175 |
.................... long strtoul(char *s,char *endptr,signed int base); |
- |
|
1176 |
.................... |
- |
|
1177 |
.................... //--------------------------------------------------------------------------- |
- |
|
1178 |
.................... // Pseudo-random sequence generation functions |
- |
|
1179 |
.................... //--------------------------------------------------------------------------- |
- |
|
1180 |
.................... |
- |
|
1181 |
.................... /* The rand function computes a sequence of pseudo-random integers in |
- |
|
1182 |
.................... * the range 0 to RAND_MAX |
- |
|
1183 |
.................... * |
- |
|
1184 |
.................... * Parameters: |
- |
|
1185 |
.................... * (none) |
- |
|
1186 |
.................... * |
- |
|
1187 |
.................... * Returns: |
- |
|
1188 |
.................... * The pseudo-random integer |
- |
|
1189 |
.................... */ |
- |
|
1190 |
.................... long rand(void); |
- |
|
1191 |
.................... |
- |
|
1192 |
.................... /* The srand function uses the argument as a seed for a new sequence of |
- |
|
1193 |
.................... * pseudo-random numbers to be returned by subsequent calls to rand. |
- |
|
1194 |
.................... * |
- |
|
1195 |
.................... * Parameters: |
- |
|
1196 |
.................... * [in] seed: The seed value to start from. You might need to pass |
- |
|
1197 |
.................... * |
- |
|
1198 |
.................... * Returns: |
- |
|
1199 |
.................... * (none) |
- |
|
1200 |
.................... * |
- |
|
1201 |
.................... * Remarks |
- |
|
1202 |
.................... * The srand function sets the starting point for generating |
- |
|
1203 |
.................... * a series of pseudorandom integers. To reinitialize the |
- |
|
1204 |
.................... * generator, use 1 as the seed argument. Any other value for |
- |
|
1205 |
.................... * seed sets the generator to a random starting point. rand |
- |
|
1206 |
.................... * retrieves the pseudorandom numbers that are generated. |
- |
|
1207 |
.................... * Calling rand before any call to srand generates the same |
- |
|
1208 |
.................... * sequence as calling srand with seed passed as 1. |
- |
|
1209 |
.................... * Usually, you need to pass a time here from outer source |
- |
|
1210 |
.................... * so that the numbers will be different every time you run. |
- |
|
1211 |
.................... */ |
- |
|
1212 |
.................... void srand(unsigned int32 seed); |
- |
|
1213 |
.................... |
- |
|
1214 |
.................... //--------------------------------------------------------------------------- |
- |
|
1215 |
.................... // Memory management functions |
- |
|
1216 |
.................... //--------------------------------------------------------------------------- |
- |
|
1217 |
.................... |
- |
|
1218 |
.................... // Comming soon |
- |
|
1219 |
.................... |
- |
|
1220 |
.................... //--------------------------------------------------------------------------- |
- |
|
1221 |
.................... // Communication with the environment |
- |
|
1222 |
.................... //--------------------------------------------------------------------------- |
- |
|
1223 |
.................... |
- |
|
1224 |
.................... /* The function returns 0 always |
- |
|
1225 |
.................... */ |
- |
|
1226 |
.................... signed int system(char *string); |
- |
|
1227 |
.................... |
- |
|
1228 |
.................... //--------------------------------------------------------------------------- |
- |
|
1229 |
.................... // Searching and sorting utilities |
- |
|
1230 |
.................... //--------------------------------------------------------------------------- |
- |
|
1231 |
.................... |
- |
|
1232 |
.................... /* Performs a binary search of a sorted array.. |
- |
|
1233 |
.................... * |
- |
|
1234 |
.................... * Parameters: |
- |
|
1235 |
.................... * [in] key: Object to search for |
- |
|
1236 |
.................... * [in] base: Pointer to base of search data |
- |
|
1237 |
.................... * [in] num: Number of elements |
- |
|
1238 |
.................... * [in] width: Width of elements |
- |
|
1239 |
.................... * [in] compare: Function that compares two elements |
- |
|
1240 |
.................... * |
- |
|
1241 |
.................... * Returns: |
- |
|
1242 |
.................... * bsearch returns a pointer to an occurrence of key in the array pointed |
- |
|
1243 |
.................... * to by base. If key is not found, the function returns NULL. If the |
- |
|
1244 |
.................... * array is not in order or contains duplicate records with identical keys, |
- |
|
1245 |
.................... * the result is unpredictable. |
- |
|
1246 |
.................... */ |
- |
|
1247 |
.................... //void *bsearch(const void *key, const void *base, size_t num, size_t width, |
- |
|
1248 |
.................... // int (*compare)(const void *, const void *)); |
- |
|
1249 |
.................... |
- |
|
1250 |
.................... /* Performs the shell-metzner sort (not the quick sort algorithm). The contents |
- |
|
1251 |
.................... * of the array are sorted into ascending order according to a comparison |
- |
|
1252 |
.................... * function pointed to by compar. |
- |
|
1253 |
.................... * |
- |
|
1254 |
.................... * Parameters: |
- |
|
1255 |
.................... * [in] base: Pointer to base of search data |
- |
|
1256 |
.................... * [in] num: Number of elements |
- |
|
1257 |
.................... * [in] width: Width of elements |
- |
|
1258 |
.................... * [in] compare: Function that compares two elements |
- |
|
1259 |
.................... * |
- |
|
1260 |
.................... * Returns: |
- |
|
1261 |
.................... * (none) |
- |
|
1262 |
.................... */ |
- |
|
1263 |
.................... //void *qsort(const void *base, size_t num, size_t width, |
- |
|
1264 |
.................... // int (*compare)(const void *, const void *)); |
- |
|
1265 |
.................... |
- |
|
1266 |
.................... //--------------------------------------------------------------------------- |
- |
|
1267 |
.................... // Integer arithmetic functions |
- |
|
1268 |
.................... //--------------------------------------------------------------------------- |
- |
|
1269 |
.................... |
- |
|
1270 |
.................... #define labs abs |
- |
|
1271 |
.................... |
- |
|
1272 |
.................... div_t div(signed int numer,signed int denom); |
- |
|
1273 |
.................... ldiv_t ldiv(signed long numer,signed long denom); |
- |
|
1274 |
.................... |
- |
|
1275 |
.................... //--------------------------------------------------------------------------- |
- |
|
1276 |
.................... // Multibyte character functions |
- |
|
1277 |
.................... //--------------------------------------------------------------------------- |
- |
|
1278 |
.................... |
- |
|
1279 |
.................... // Not supported |
- |
|
1280 |
.................... |
- |
|
1281 |
.................... //--------------------------------------------------------------------------- |
- |
|
1282 |
.................... // Multibyte string functions |
- |
|
1283 |
.................... //--------------------------------------------------------------------------- |
- |
|
1284 |
.................... |
- |
|
1285 |
.................... // Not supported |
- |
|
1286 |
.................... |
- |
|
1287 |
.................... |
- |
|
1288 |
.................... //--------------------------------------------------------------------------- |
- |
|
1289 |
.................... // Internal implementation |
- |
|
1290 |
.................... //--------------------------------------------------------------------------- |
- |
|
1291 |
.................... |
- |
|
1292 |
.................... #include <stddef.h> |
- |
|
1293 |
.................... /////////////////////////////////////////////////////////////////////////// |
- |
|
1294 |
.................... //// (C) Copyright 1996,2003 Custom Computer Services //// |
- |
|
1295 |
.................... //// This source code may only be used by licensed users of the CCS C //// |
- |
|
1296 |
.................... //// compiler. This source code may only be distributed to other //// |
- |
|
1297 |
.................... //// licensed users of the CCS C compiler. No other use, reproduction //// |
- |
|
1298 |
.................... //// or distribution is permitted without written permission. //// |
- |
|
1299 |
.................... //// Derivative programs created using this software in object code //// |
- |
|
1300 |
.................... //// form are not restricted in any way. //// |
- |
|
1301 |
.................... /////////////////////////////////////////////////////////////////////////// |
- |
|
1302 |
.................... |
- |
|
1303 |
.................... #ifndef _STDDEF |
- |
|
1304 |
.................... |
- |
|
1305 |
.................... #define _STDDEF |
- |
|
1306 |
.................... |
- |
|
1307 |
.................... #if sizeof(int *)==1 |
- |
|
1308 |
.................... #define ptrdiff_t int |
- |
|
1309 |
.................... #else |
- |
|
1310 |
.................... #define ptrdiff_t long |
- |
|
1311 |
.................... #endif |
- |
|
1312 |
.................... |
- |
|
1313 |
.................... #define size_t int |
- |
|
1314 |
.................... #define wchar_t char |
- |
|
1315 |
.................... #define NULL 0 |
- |
|
1316 |
.................... |
- |
|
1317 |
.................... #define offsetof(s,f) (offsetofbit(s,f)/8) |
- |
|
1318 |
.................... |
- |
|
1319 |
.................... #endif |
- |
|
1320 |
.................... |
- |
|
1321 |
.................... #include <string.h> |
- |
|
1322 |
.................... //////////////////////////////////////////////////////////////////////////// |
- |
|
1323 |
.................... //// (C) Copyright 1996,2003 Custom Computer Services //// |
- |
|
1324 |
.................... //// This source code may only be used by licensed users of the CCS C //// |
- |
|
1325 |
.................... //// compiler. This source code may only be distributed to other //// |
- |
|
1326 |
.................... //// licensed users of the CCS C compiler. No other use, reproduction //// |
- |
|
1327 |
.................... //// or distribution is permitted without written permission. //// |
- |
|
1328 |
.................... //// Derivative programs created using this software in object code //// |
- |
|
1329 |
.................... //// form are not restricted in any way. //// |
- |
|
1330 |
.................... //////////////////////////////////////////////////////////////////////////// |
- |
|
1331 |
.................... |
- |
|
1332 |
.................... #ifndef _STRING |
- |
|
1333 |
.................... #define _STRING |
- |
|
1334 |
.................... #include <stddef.h> |
- |
|
1335 |
.................... #include <ctype.h> |
- |
|
1336 |
.................... |
- |
|
1337 |
.................... |
- |
|
1338 |
.................... |
- |
|
1339 |
.................... ////////////////////////////////////////////// |
- |
|
1340 |
.................... //// Uncomment the following define to //// |
- |
|
1341 |
.................... //// allow some functions to use a //// |
- |
|
1342 |
.................... //// quicker algorithm, but use more ROM //// |
- |
|
1343 |
.................... //// //// |
- |
|
1344 |
.................... //// #define FASTER_BUT_MORE_ROM //// |
- |
|
1345 |
.................... ////////////////////////////////////////////// |
- |
|
1346 |
.................... |
- |
|
1347 |
.................... |
- |
|
1348 |
.................... |
- |
|
1349 |
.................... /*Copying functions*/ |
- |
|
1350 |
.................... /* standard template: |
- |
|
1351 |
.................... void *memmove(void *s1, void *s2, size_t n). |
- |
|
1352 |
.................... Copies max of n characters safely (not following ending '\0') |
- |
|
1353 |
.................... from s2 in s1; if s2 has less than n characters, appends 0 */ |
- |
|
1354 |
.................... |
- |
|
1355 |
.................... char *memmove(void *s1,char *s2,size_t n) |
- |
|
1356 |
.................... { |
- |
|
1357 |
.................... char *sc1; |
- |
|
1358 |
.................... char *sc2; |
- |
|
1359 |
.................... sc1=s1; |
- |
|
1360 |
.................... sc2=s2; |
- |
|
1361 |
.................... if(sc2<sc1 && sc1 <sc2 +n) |
- |
|
1362 |
.................... for(sc1+=n,sc2+=n;0<n;--n) |
- |
|
1363 |
.................... *--sc1=*--sc2; |
- |
|
1364 |
.................... else |
- |
|
1365 |
.................... for(;0<n;--n) |
- |
|
1366 |
.................... *sc1++=*sc2++; |
- |
|
1367 |
.................... return s1; |
- |
|
1368 |
.................... } |
- |
|
1369 |
.................... |
- |
|
1370 |
.................... /* compiler ignored the name 'strcpy()'; perhaps, it's reserved? |
- |
|
1371 |
.................... Standard template: char *strcpy(char *s1, const char *s2) |
- |
|
1372 |
.................... copies the string s2 including the null character to s1*/ |
- |
|
1373 |
.................... |
- |
|
1374 |
.................... char *strcopy(char *s1, char *s2) |
- |
|
1375 |
.................... { |
- |
|
1376 |
.................... char *s; |
- |
|
1377 |
.................... |
- |
|
1378 |
.................... for (s = s1; *s2 != 0; s++, s2++) { |
- |
|
1379 |
.................... *s = *s2; |
- |
|
1380 |
.................... } |
- |
|
1381 |
.................... *s = *s2; |
- |
|
1382 |
.................... return(s1); |
- |
|
1383 |
.................... } |
- |
|
1384 |
.................... |
- |
|
1385 |
.................... /* standard template: |
- |
|
1386 |
.................... char *strncpy(char *s1, const char *s2, size_t n). |
- |
|
1387 |
.................... Copies max of n characters (not following ending '\0') |
- |
|
1388 |
.................... from s2 in s1; if s2 has less than n characters, appends 0 */ |
- |
|
1389 |
.................... |
- |
|
1390 |
.................... char *strncpy(char *s1, char *s2, size_t n) |
- |
|
1391 |
.................... { |
- |
|
1392 |
.................... char *s; |
- |
|
1393 |
.................... |
- |
|
1394 |
.................... for (s = s1; n > 0 && *s2 != '\0'; n--) |
- |
|
1395 |
.................... *s++ = *s2++; |
- |
|
1396 |
.................... for (; n > 0; n--) |
- |
|
1397 |
.................... *s++ = '\0'; |
- |
|
1398 |
.................... |
- |
|
1399 |
.................... return(s1); |
- |
|
1400 |
.................... } |
- |
|
1401 |
.................... /***********************************************************/ |
- |
|
1402 |
.................... |
- |
|
1403 |
.................... /*concatenation functions*/ |
- |
|
1404 |
.................... /* standard template: char *strcat(char *s1, const char *s2) |
- |
|
1405 |
.................... appends s2 to s1*/ |
- |
|
1406 |
.................... |
- |
|
1407 |
.................... char *strcat(char *s1, char *s2) |
- |
|
1408 |
.................... { |
- |
|
1409 |
.................... char *s; |
- |
|
1410 |
.................... |
- |
|
1411 |
.................... for (s = s1; *s != '\0'; ++s); |
- |
|
1412 |
.................... while(*s2 != '\0') |
- |
|
1413 |
.................... { |
- |
|
1414 |
.................... *s = *s2; |
- |
|
1415 |
.................... ++s; |
- |
|
1416 |
.................... ++s2; |
- |
|
1417 |
.................... } |
- |
|
1418 |
.................... |
- |
|
1419 |
.................... *s = '\0'; |
- |
|
1420 |
.................... return(s1); |
- |
|
1421 |
.................... } |
- |
|
1422 |
.................... /* standard template: char *strncat(char *s1, char *s2,size_t n) |
- |
|
1423 |
.................... appends not more than n characters from s2 to s1*/ |
- |
|
1424 |
.................... |
- |
|
1425 |
.................... char *strncat(char *s1, char *s2, size_t n) |
- |
|
1426 |
.................... { |
- |
|
1427 |
.................... char *s; |
- |
|
1428 |
.................... |
- |
|
1429 |
.................... for (s = s1; *s != '\0'; ++s); |
- |
|
1430 |
.................... while(*s2 != '\0' && 0<n) |
- |
|
1431 |
.................... { |
- |
|
1432 |
.................... *s = *s2; |
- |
|
1433 |
.................... ++s; |
- |
|
1434 |
.................... ++s2; |
- |
|
1435 |
.................... --n; |
- |
|
1436 |
.................... } |
- |
|
1437 |
.................... |
- |
|
1438 |
.................... *s = '\0'; |
- |
|
1439 |
.................... return(s1); |
- |
|
1440 |
.................... } |
- |
|
1441 |
.................... |
- |
|
1442 |
.................... /***********************************************************/ |
- |
|
1443 |
.................... |
- |
|
1444 |
.................... |
- |
|
1445 |
.................... /*comparison functions*/ |
- |
|
1446 |
.................... /* standard template: signed int memcmp(void *s1, void *s2). |
- |
|
1447 |
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */ |
- |
|
1448 |
.................... |
- |
|
1449 |
.................... signed int memcmp(void * s1,char *s2,size_t n) |
- |
|
1450 |
.................... { |
- |
|
1451 |
.................... char *su1, *su2; |
- |
|
1452 |
.................... for(su1=s1, su2=s2; 0<n; ++su1, ++su2, --n) |
- |
|
1453 |
.................... { |
- |
|
1454 |
.................... if(*su1!=*su2) |
- |
|
1455 |
.................... return ((*su1<*su2)?-1:+1); |
- |
|
1456 |
.................... } |
- |
|
1457 |
.................... return 0; |
- |
|
1458 |
.................... } |
- |
|
1459 |
.................... |
- |
|
1460 |
.................... /* standard template: int strcmp(const char *s1, const char *s2). |
- |
|
1461 |
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */ |
- |
|
1462 |
.................... |
- |
|
1463 |
.................... signed int strcmp(char *s1, char *s2) |
- |
|
1464 |
.................... { |
- |
|
1465 |
.................... for (; *s1 == *s2; s1++, s2++) |
- |
|
1466 |
.................... if (*s1 == '\0') |
- |
|
1467 |
.................... return(0); |
- |
|
1468 |
.................... return((*s1 < *s2) ? -1: 1); |
- |
|
1469 |
.................... } |
- |
|
1470 |
.................... /* standard template: int strcoll(const char *s1, const char *s2). |
- |
|
1471 |
.................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */ |
- |
|
1472 |
.................... |
- |
|
1473 |
.................... signed int strcoll(char *s1, char *s2) |
- |
|
1474 |
.................... { |
- |
|
1475 |
.................... for (; *s1 == *s2; s1++, s2++) |
- |
|
1476 |
.................... if (*s1 == '\0') |
- |
|
1477 |
.................... return(0); |
- |
|
1478 |
.................... return((*s1 < *s2) ? -1: 1); |
- |
|
1479 |
.................... } |
- |
|
1480 |
.................... |
- |
|
1481 |
.................... /* standard template: |
- |
|
1482 |
.................... int strncmp(const char *s1, const char *s2, size_t n). |
- |
|
1483 |
.................... Compares max of n characters (not following 0) from s1 to s2; |
- |
|
1484 |
.................... returns same as strcmp */ |
- |
|
1485 |
.................... |
- |
|
1486 |
.................... signed int strncmp(char *s1, char *s2, size_t n) |
- |
|
1487 |
.................... { |
- |
|
1488 |
.................... for (; n > 0; s1++, s2++, n--) |
- |
|
1489 |
.................... if (*s1 != *s2) |
- |
|
1490 |
.................... return((*s1 <*s2) ? -1: 1); |
- |
|
1491 |
.................... else if (*s1 == '\0') |
- |
|
1492 |
.................... return(0); |
- |
|
1493 |
.................... return(0); |
- |
|
1494 |
.................... } |
- |
|
1495 |
.................... /* standard template: |
- |
|
1496 |
.................... int strxfrm(const char *s1, const char *s2, size_t n). |
- |
|
1497 |
.................... transforms maximum of n characters from s2 and places them into s1*/ |
- |
|
1498 |
.................... size_t strxfrm(char *s1, char *s2, size_t n) |
- |
|
1499 |
.................... { |
- |
|
1500 |
.................... char *s; |
- |
|
1501 |
.................... int n1; |
- |
|
1502 |
.................... n1=n; |
- |
|
1503 |
.................... for (s = s1; n > 0 && *s2 != '\0'; n--) |
- |
|
1504 |
.................... *s++ = *s2++; |
- |
|
1505 |
.................... for (; n > 0; n--) |
- |
|
1506 |
.................... *s++ = '\0'; |
- |
|
1507 |
.................... |
- |
|
1508 |
.................... return(n1); |
- |
|
1509 |
.................... } |
- |
|
1510 |
.................... |
- |
|
1511 |
.................... |
- |
|
1512 |
.................... |
- |
|
1513 |
.................... |
- |
|
1514 |
.................... |
- |
|
1515 |
.................... /***********************************************************/ |
- |
|
1516 |
.................... /*Search functions*/ |
- |
|
1517 |
.................... /* standard template: void *memchr(const char *s, int c). |
- |
|
1518 |
.................... Finds first occurrence of c in n characters of s */ |
- |
|
1519 |
.................... |
- |
|
1520 |
.................... char *memchr(void *s,int c,size_t n) |
- |
|
1521 |
.................... { |
- |
|
1522 |
.................... char uc; |
- |
|
1523 |
.................... char *su; |
- |
|
1524 |
.................... uc=c; |
- |
|
1525 |
.................... for(su=s;0<n;++su,--n) |
- |
|
1526 |
.................... if(*su==uc) |
- |
|
1527 |
.................... return su; |
- |
|
1528 |
.................... return NULL; |
- |
|
1529 |
.................... } |
- |
|
1530 |
.................... |
- |
|
1531 |
.................... /* standard template: char *strchr(const char *s, int c). |
- |
|
1532 |
.................... Finds first occurrence of c in s */ |
- |
|
1533 |
.................... |
- |
|
1534 |
.................... char *strchr(char *s, int c) |
- |
|
1535 |
.................... { |
- |
|
1536 |
.................... for (; *s != c; s++) |
- |
|
1537 |
.................... if (*s == '\0') |
- |
|
1538 |
.................... return(0); |
- |
|
1539 |
.................... return(s); |
- |
|
1540 |
.................... } |
- |
|
1541 |
.................... /* standard template: |
- |
|
1542 |
.................... size_t strcspn(const char *s1, const char *s2). |
- |
|
1543 |
.................... Computes length of max initial segment of s1 that |
- |
|
1544 |
.................... consists entirely of characters NOT from s2*/ |
- |
|
1545 |
.................... |
- |
|
1546 |
.................... int *strcspn(char *s1, char *s2) |
- |
|
1547 |
.................... { |
- |
|
1548 |
.................... char *sc1, *sc2; |
- |
|
1549 |
.................... |
- |
|
1550 |
.................... for (sc1 = s1; *sc1 != 0; sc1++) |
- |
|
1551 |
.................... for (sc2 = s2; *sc2 != 0; sc2++) |
- |
|
1552 |
.................... if (*sc1 == *sc2) |
- |
|
1553 |
.................... return(sc1 - s1); |
- |
|
1554 |
.................... return(sc1 - s1); |
- |
|
1555 |
.................... } |
- |
|
1556 |
.................... /* standard template: |
- |
|
1557 |
.................... char *strpbrk(const char *s1, const char *s2). |
- |
|
1558 |
.................... Locates first occurence of any character from s2 in s1; |
- |
|
1559 |
.................... returns s1 if s2 is empty string */ |
- |
|
1560 |
.................... |
- |
|
1561 |
.................... char *strpbrk(char *s1, char *s2) |
- |
|
1562 |
.................... { |
- |
|
1563 |
.................... char *sc1, *sc2; |
- |
|
1564 |
.................... |
- |
|
1565 |
.................... for (sc1 = s1; *sc1 != 0; sc1++) |
- |
|
1566 |
.................... for (sc2 = s2; *sc2 != 0; sc2++) |
- |
|
1567 |
.................... if (*sc1 == *sc2) |
- |
|
1568 |
.................... return(sc1); |
- |
|
1569 |
.................... return(0); |
- |
|
1570 |
.................... } |
- |
|
1571 |
.................... |
- |
|
1572 |
.................... |
- |
|
1573 |
.................... /* standard template: char *strrchr(const char *s, int c). |
- |
|
1574 |
.................... Finds last occurrence of c in s */ |
- |
|
1575 |
.................... |
- |
|
1576 |
.................... char *strrchr(char *s, int c) |
- |
|
1577 |
.................... { |
- |
|
1578 |
.................... char *p; |
- |
|
1579 |
.................... |
- |
|
1580 |
.................... for (p = 0; ; s++) |
- |
|
1581 |
.................... { |
- |
|
1582 |
.................... if (*s == c) |
- |
|
1583 |
.................... p = s; |
- |
|
1584 |
.................... if (*s == '\0') |
- |
|
1585 |
.................... return(p); |
1012 |
.................... } |
1586 |
.................... } |
- |
|
1587 |
.................... } |
- |
|
1588 |
.................... /* computes length of max initial segment of s1 consisting |
- |
|
1589 |
.................... entirely of characters from s2 */ |
- |
|
1590 |
.................... |
- |
|
1591 |
.................... int *strspn(char *s1, char *s2) |
- |
|
1592 |
.................... { |
- |
|
1593 |
.................... char *sc1, *sc2; |
- |
|
1594 |
.................... |
- |
|
1595 |
.................... for (sc1 = s1; *sc1 != 0; sc1++) |
- |
|
1596 |
.................... for (sc2 = s2; ; sc2++) |
- |
|
1597 |
.................... if (*sc2 == '\0') |
- |
|
1598 |
.................... return(sc1 - s1); |
- |
|
1599 |
.................... else if (*sc1 == *sc2) |
- |
|
1600 |
.................... break; |
- |
|
1601 |
.................... return(sc1 - s1); |
- |
|
1602 |
.................... } |
- |
|
1603 |
.................... /* standard template: |
- |
|
1604 |
.................... char *strstr(const char *s1, const char *s2); |
- |
|
1605 |
.................... Locates first occurence of character sequence s2 in s1; |
- |
|
1606 |
.................... returns 0 if s2 is empty string |
- |
|
1607 |
.................... |
- |
|
1608 |
.................... Uncomment #define FASTER_BUT_MORE_ROM at the top of the |
- |
|
1609 |
.................... file to use the faster algorithm */ |
- |
|
1610 |
.................... char *strstr(char *s1, char *s2) |
- |
|
1611 |
.................... { |
- |
|
1612 |
.................... char *s, *t; |
- |
|
1613 |
.................... |
- |
|
1614 |
.................... #ifdef FASTER_BUT_MORE_ROM |
- |
|
1615 |
.................... if (*s2 == '\0') |
- |
|
1616 |
.................... return(s1); |
- |
|
1617 |
.................... #endif |
- |
|
1618 |
.................... |
- |
|
1619 |
.................... while (*s1) |
- |
|
1620 |
.................... { |
- |
|
1621 |
.................... for(s = s1, t = s2; *t && *s == *t; ++s, ++t); |
- |
|
1622 |
.................... |
- |
|
1623 |
.................... if (*t == '\0') |
- |
|
1624 |
.................... return s1; |
- |
|
1625 |
.................... ++s1; |
- |
|
1626 |
.................... #ifdef FASTER_BUT_MORE_ROM |
- |
|
1627 |
.................... while(*s1 != '\0' && *s1 != *s2) |
- |
|
1628 |
.................... ++s1; |
- |
|
1629 |
.................... #endif |
- |
|
1630 |
.................... } |
- |
|
1631 |
.................... return 0; |
- |
|
1632 |
.................... } |
- |
|
1633 |
.................... |
- |
|
1634 |
.................... /* standard template: char *strtok(char *s1, const char *s2). |
- |
|
1635 |
.................... |
- |
|
1636 |
.................... Finds next token in s1 delimited by a character from separator |
- |
|
1637 |
.................... string s2 (which can be different from call to call). First call |
- |
|
1638 |
.................... starts at beginning of s1 searching for first character NOT |
- |
|
1639 |
.................... contained in s2; returns 0 if none is found. |
- |
|
1640 |
.................... If one is found, it is the start of first token (return value). |
- |
|
1641 |
.................... Function then searches from there for a character contained in s2. |
- |
|
1642 |
.................... If none is found, current token extends to end of s1, and subsequent |
- |
|
1643 |
.................... searches for a token will return 0. If one is found, it is |
- |
|
1644 |
.................... overwritten by '\0', which terminates current token. Function saves |
- |
|
1645 |
.................... pointer to following character from which next search will start. |
- |
|
1646 |
.................... Each subsequent call, with 0 as first argument, starts searching |
- |
|
1647 |
.................... from saved pointer */ |
- |
|
1648 |
.................... |
- |
|
1649 |
.................... char *strtok(char *s1, char *s2) |
- |
|
1650 |
.................... { |
- |
|
1651 |
.................... char *beg, *end; |
- |
|
1652 |
.................... static char *save; |
- |
|
1653 |
.................... |
- |
|
1654 |
.................... beg = (s1)? s1: save; |
- |
|
1655 |
.................... beg += strspn(beg, s2); |
- |
|
1656 |
.................... if (*beg == '\0') |
- |
|
1657 |
.................... { |
- |
|
1658 |
.................... *save = ' '; |
- |
|
1659 |
.................... return(0); |
- |
|
1660 |
.................... } |
- |
|
1661 |
.................... end = strpbrk(beg, s2); |
- |
|
1662 |
.................... if (*end != '\0') |
- |
|
1663 |
.................... { |
- |
|
1664 |
.................... *end = '\0'; |
- |
|
1665 |
.................... end++; |
- |
|
1666 |
.................... } |
- |
|
1667 |
.................... save = end; |
- |
|
1668 |
.................... return(beg); |
- |
|
1669 |
.................... } |
- |
|
1670 |
.................... |
- |
|
1671 |
.................... /*****************************************************************/ |
- |
|
1672 |
.................... /*Miscellaneous functions*/ |
- |
|
1673 |
.................... /* standard template |
- |
|
1674 |
.................... maps error number in errnum to an error message string |
- |
|
1675 |
.................... Returns: Pointer to string |
- |
|
1676 |
.................... */ |
- |
|
1677 |
.................... #ifdef _ERRNO |
- |
|
1678 |
.................... char * strerror(int errnum) |
- |
|
1679 |
.................... { |
- |
|
1680 |
.................... char s[15]; |
- |
|
1681 |
.................... switch( errnum) |
- |
|
1682 |
.................... { |
- |
|
1683 |
.................... case 0: |
- |
|
1684 |
.................... strcpy(s,"no errors"); |
- |
|
1685 |
.................... return s; |
- |
|
1686 |
.................... case EDOM : |
- |
|
1687 |
.................... strcpy(s,"domain error"); |
- |
|
1688 |
.................... return s; |
- |
|
1689 |
.................... case ERANGE: |
- |
|
1690 |
.................... strcpy(s,"range error"); |
- |
|
1691 |
.................... return s; |
- |
|
1692 |
.................... } |
- |
|
1693 |
.................... } |
- |
|
1694 |
.................... #ENDIF |
- |
|
1695 |
.................... /* standard template: size_t strlen(const char *s). |
- |
|
1696 |
.................... Computes length of s1 (preceding terminating 0) */ |
- |
|
1697 |
.................... |
- |
|
1698 |
.................... int *strlen(char *s) |
- |
|
1699 |
.................... { |
- |
|
1700 |
.................... char *sc; |
- |
|
1701 |
.................... |
- |
|
1702 |
.................... for (sc = s; *sc != 0; sc++); |
- |
|
1703 |
.................... return(sc - s); |
- |
|
1704 |
.................... } |
- |
|
1705 |
.................... |
- |
|
1706 |
.................... /* standard template: size_t stricmp(const char *s1, const char *s2). |
- |
|
1707 |
.................... Compares s1 to s2 ignoring case (upper vs. lower) */ |
- |
|
1708 |
.................... |
- |
|
1709 |
.................... signed int stricmp(char *s1, char *s2) |
- |
|
1710 |
.................... { |
- |
|
1711 |
.................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32)); |
- |
|
1712 |
.................... s1++, s2++) |
- |
|
1713 |
.................... if (*s1 == '\0') |
- |
|
1714 |
.................... return(0); |
- |
|
1715 |
.................... return((*s1 < *s2) ? -1: 1); |
- |
|
1716 |
.................... } |
- |
|
1717 |
.................... |
- |
|
1718 |
.................... |
- |
|
1719 |
.................... /* standard template: char *strlwr(char *s). |
- |
|
1720 |
.................... Replaces uppercase letters by lowercase; |
- |
|
1721 |
.................... returns pointer to new string s */ |
- |
|
1722 |
.................... |
- |
|
1723 |
.................... char *strlwr(char *s) |
- |
|
1724 |
.................... { |
- |
|
1725 |
.................... char *p; |
- |
|
1726 |
.................... |
- |
|
1727 |
.................... for (p = s; *p != '\0'; p++) |
- |
|
1728 |
.................... if (*p >= 'A' && *p <='Z') |
- |
|
1729 |
.................... *p += 'a' - 'A'; |
- |
|
1730 |
.................... return(s); |
- |
|
1731 |
.................... } |
- |
|
1732 |
.................... |
- |
|
1733 |
.................... |
- |
|
1734 |
.................... /************************************************************/ |
- |
|
1735 |
.................... |
- |
|
1736 |
.................... |
- |
|
1737 |
.................... #endif |
- |
|
1738 |
.................... |
- |
|
1739 |
.................... |
- |
|
1740 |
.................... div_t div(signed int numer,signed int denom) |
- |
|
1741 |
.................... { |
- |
|
1742 |
.................... div_t val; |
- |
|
1743 |
.................... val.quot = numer / denom; |
- |
|
1744 |
.................... val.rem = numer - (denom * val.quot); |
- |
|
1745 |
.................... return (val); |
- |
|
1746 |
.................... } |
- |
|
1747 |
.................... |
- |
|
1748 |
.................... ldiv_t ldiv(signed long numer,signed long denom) |
- |
|
1749 |
.................... { |
- |
|
1750 |
.................... ldiv_t val; |
- |
|
1751 |
.................... val.quot = numer / denom; |
- |
|
1752 |
.................... val.rem = numer - (denom * val.quot); |
- |
|
1753 |
.................... return (val); |
- |
|
1754 |
.................... } |
- |
|
1755 |
.................... |
- |
|
1756 |
.................... float atof(char * s) |
- |
|
1757 |
.................... { |
- |
|
1758 |
.................... float pow10 = 1.0; |
- |
|
1759 |
.................... float result = 0.0; |
- |
|
1760 |
.................... int sign = 0; |
- |
|
1761 |
.................... char c; |
- |
|
1762 |
.................... int ptr = 0; |
- |
|
1763 |
.................... |
- |
|
1764 |
.................... c = s[ptr++]; |
- |
|
1765 |
.................... |
- |
|
1766 |
.................... if ((c>='0' && c<='9') || c=='+' || c=='-' || c=='.') { |
- |
|
1767 |
.................... if(c == '-') { |
- |
|
1768 |
.................... sign = 1; |
- |
|
1769 |
.................... c = s[ptr++]; |
- |
|
1770 |
.................... } |
- |
|
1771 |
.................... if(c == '+') |
- |
|
1772 |
.................... c = s[ptr++]; |
- |
|
1773 |
.................... |
- |
|
1774 |
.................... while((c >= '0' && c <= '9')) { |
- |
|
1775 |
.................... result = 10*result + c - '0'; |
- |
|
1776 |
.................... c = s[ptr++]; |
- |
|
1777 |
.................... } |
- |
|
1778 |
.................... |
- |
|
1779 |
.................... if (c == '.') { |
- |
|
1780 |
.................... c = s[ptr++]; |
- |
|
1781 |
.................... while((c >= '0' && c <= '9')) { |
- |
|
1782 |
.................... pow10 = pow10*10; |
- |
|
1783 |
.................... result += (c - '0')/pow10; |
- |
|
1784 |
.................... c = s[ptr++]; |
- |
|
1785 |
.................... } |
- |
|
1786 |
.................... } |
- |
|
1787 |
.................... |
- |
|
1788 |
.................... } |
- |
|
1789 |
.................... |
- |
|
1790 |
.................... if (sign == 1) |
- |
|
1791 |
.................... result = -1*result; |
- |
|
1792 |
.................... return(result); |
- |
|
1793 |
.................... } |
- |
|
1794 |
.................... |
- |
|
1795 |
.................... float atoe(char * s) |
- |
|
1796 |
.................... { |
- |
|
1797 |
.................... float pow10 = 1.0; |
- |
|
1798 |
.................... float result = 0.0; |
- |
|
1799 |
.................... int sign = 0; |
- |
|
1800 |
.................... int expsign = 0; |
- |
|
1801 |
.................... char c; |
- |
|
1802 |
.................... int ptr = 0; |
- |
|
1803 |
.................... int i; |
- |
|
1804 |
.................... float exp = 1.0; |
- |
|
1805 |
.................... int expcnt = 0; |
- |
|
1806 |
.................... |
- |
|
1807 |
.................... c = s[ptr++]; |
- |
|
1808 |
.................... |
- |
|
1809 |
.................... if ((c>='0' && c<='9') || c=='+' || c=='-' || c=='.' || c=='E' || c=='e') { |
- |
|
1810 |
.................... if(c == '-') { |
- |
|
1811 |
.................... sign = 1; |
- |
|
1812 |
.................... c = s[ptr++]; |
- |
|
1813 |
.................... } |
- |
|
1814 |
.................... if(c == '+') |
- |
|
1815 |
.................... c = s[ptr++]; |
- |
|
1816 |
.................... |
- |
|
1817 |
.................... while((c >= '0' && c <= '9')) { |
- |
|
1818 |
.................... result = 10*result + c - '0'; |
- |
|
1819 |
.................... c = s[ptr++]; |
- |
|
1820 |
.................... } |
- |
|
1821 |
.................... |
- |
|
1822 |
.................... if (c == '.') { |
- |
|
1823 |
.................... c = s[ptr++]; |
- |
|
1824 |
.................... while((c >= '0' && c <= '9')) { |
- |
|
1825 |
.................... pow10 = pow10*10; |
- |
|
1826 |
.................... result += (c - '0')/pow10; |
- |
|
1827 |
.................... c = s[ptr++]; |
- |
|
1828 |
.................... } |
- |
|
1829 |
.................... } |
- |
|
1830 |
.................... |
- |
|
1831 |
.................... // Handling the exponent |
- |
|
1832 |
.................... if (c=='e' || c=='E') { |
- |
|
1833 |
.................... c = s[ptr++]; |
- |
|
1834 |
.................... |
- |
|
1835 |
.................... if(c == '-') { |
- |
|
1836 |
.................... expsign = 1; |
- |
|
1837 |
.................... c = s[ptr++]; |
- |
|
1838 |
.................... } |
- |
|
1839 |
.................... if(c == '+') |
- |
|
1840 |
.................... c = s[ptr++]; |
- |
|
1841 |
.................... |
- |
|
1842 |
.................... while((c >= '0' && c <= '9')) { |
- |
|
1843 |
.................... expcnt = 10*expcnt + c - '0'; |
- |
|
1844 |
.................... c = s[ptr++]; |
- |
|
1845 |
.................... } |
- |
|
1846 |
.................... |
- |
|
1847 |
.................... for(i=0;i<expcnt;i++) |
- |
|
1848 |
.................... exp*=10; |
- |
|
1849 |
.................... |
- |
|
1850 |
.................... if(expsign==1) |
- |
|
1851 |
.................... result/=exp; |
- |
|
1852 |
.................... else |
- |
|
1853 |
.................... result*=exp; |
- |
|
1854 |
.................... } |
- |
|
1855 |
.................... } |
- |
|
1856 |
.................... |
- |
|
1857 |
.................... if (sign == 1) |
- |
|
1858 |
.................... result = -1*result; |
- |
|
1859 |
.................... return(result); |
- |
|
1860 |
.................... } |
- |
|
1861 |
.................... |
- |
|
1862 |
.................... signed int atoi(char *s) |
- |
|
1863 |
.................... { |
- |
|
1864 |
.................... signed int result; |
- |
|
1865 |
.................... int sign, base, index; |
- |
|
1866 |
.................... char c; |
- |
|
1867 |
.................... |
- |
|
1868 |
.................... index = 0; |
- |
|
1869 |
.................... sign = 0; |
- |
|
1870 |
.................... base = 10; |
- |
|
1871 |
.................... result = 0; |
- |
|
1872 |
.................... |
- |
|
1873 |
.................... if (!s) |
- |
|
1874 |
.................... return 0; |
- |
|
1875 |
.................... // Omit all preceeding alpha characters |
- |
|
1876 |
.................... c = s[index++]; |
- |
|
1877 |
.................... |
- |
|
1878 |
.................... // increase index if either positive or negative sign is detected |
- |
|
1879 |
.................... if (c == '-') |
- |
|
1880 |
.................... { |
- |
|
1881 |
.................... sign = 1; // Set the sign to negative |
- |
|
1882 |
.................... c = s[index++]; |
- |
|
1883 |
.................... } |
- |
|
1884 |
.................... else if (c == '+') |
- |
|
1885 |
.................... { |
- |
|
1886 |
.................... c = s[index++]; |
- |
|
1887 |
.................... } |
- |
|
1888 |
.................... |
- |
|
1889 |
.................... if (c >= '0' && c <= '9') |
- |
|
1890 |
.................... { |
- |
|
1891 |
.................... |
- |
|
1892 |
.................... // Check for hexa number |
- |
|
1893 |
.................... if (c == '0' && (s[index] == 'x' || s[index] == 'X')) |
- |
|
1894 |
.................... { |
- |
|
1895 |
.................... base = 16; |
- |
|
1896 |
.................... index++; |
- |
|
1897 |
.................... c = s[index++]; |
- |
|
1898 |
.................... } |
- |
|
1899 |
.................... |
- |
|
1900 |
.................... // The number is a decimal number |
- |
|
1901 |
.................... if (base == 10) |
- |
|
1902 |
.................... { |
- |
|
1903 |
.................... while (c >= '0' && c <= '9') |
- |
|
1904 |
.................... { |
- |
|
1905 |
.................... result = 10*result + (c - '0'); |
- |
|
1906 |
.................... c = s[index++]; |
- |
|
1907 |
.................... } |
- |
|
1908 |
.................... } |
- |
|
1909 |
.................... else if (base == 16) // The number is a hexa number |
- |
|
1910 |
.................... { |
- |
|
1911 |
.................... c = toupper(c); |
- |
|
1912 |
.................... while ( (c >= '0' && c <= '9') || (c >= 'A' && c<='F')) |
- |
|
1913 |
.................... { |
- |
|
1914 |
.................... if (c >= '0' && c <= '9') |
- |
|
1915 |
.................... result = (result << 4) + (c - '0'); |
- |
|
1916 |
.................... else |
- |
|
1917 |
.................... result = (result << 4) + (c - 'A' + 10); |
- |
|
1918 |
.................... |
- |
|
1919 |
.................... c = s[index++]; |
- |
|
1920 |
.................... c = toupper(c); |
- |
|
1921 |
.................... } |
- |
|
1922 |
.................... } |
- |
|
1923 |
.................... } |
- |
|
1924 |
.................... |
- |
|
1925 |
.................... if (sign == 1 && base == 10) |
- |
|
1926 |
.................... result = -result; |
- |
|
1927 |
.................... |
- |
|
1928 |
.................... return(result); |
- |
|
1929 |
.................... } |
- |
|
1930 |
.................... |
- |
|
1931 |
.................... signed long atol(char *s) |
- |
|
1932 |
.................... { |
- |
|
1933 |
.................... signed long result; |
- |
|
1934 |
.................... int sign, base, index; |
- |
|
1935 |
.................... char c; |
- |
|
1936 |
.................... |
- |
|
1937 |
.................... index = 0; |
- |
|
1938 |
.................... sign = 0; |
- |
|
1939 |
.................... base = 10; |
- |
|
1940 |
.................... result = 0; |
- |
|
1941 |
.................... |
- |
|
1942 |
.................... if (!s) |
- |
|
1943 |
.................... return 0; |
- |
|
1944 |
.................... c = s[index++]; |
- |
|
1945 |
.................... |
- |
|
1946 |
.................... // increase index if either positive or negative sign is detected |
- |
|
1947 |
.................... if (c == '-') |
- |
|
1948 |
.................... { |
- |
|
1949 |
.................... sign = 1; // Set the sign to negative |
- |
|
1950 |
.................... c = s[index++]; |
- |
|
1951 |
.................... } |
- |
|
1952 |
.................... else if (c == '+') |
- |
|
1953 |
.................... { |
- |
|
1954 |
.................... c = s[index++]; |
- |
|
1955 |
.................... } |
- |
|
1956 |
.................... |
- |
|
1957 |
.................... if (c >= '0' && c <= '9') |
- |
|
1958 |
.................... { |
- |
|
1959 |
.................... if (c == '0' && (s[index] == 'x' || s[index] == 'X')) |
- |
|
1960 |
.................... { |
- |
|
1961 |
.................... base = 16; |
- |
|
1962 |
.................... index++; |
- |
|
1963 |
.................... c = s[index++]; |
- |
|
1964 |
.................... } |
- |
|
1965 |
.................... |
- |
|
1966 |
.................... // The number is a decimal number |
- |
|
1967 |
.................... if (base == 10) |
- |
|
1968 |
.................... { |
- |
|
1969 |
.................... while (c >= '0' && c <= '9') |
- |
|
1970 |
.................... { |
- |
|
1971 |
.................... result = 10*result + (c - '0'); |
- |
|
1972 |
.................... c = s[index++]; |
- |
|
1973 |
.................... } |
- |
|
1974 |
.................... } |
- |
|
1975 |
.................... else if (base == 16) // The number is a hexa number |
- |
|
1976 |
.................... { |
- |
|
1977 |
.................... c = toupper(c); |
- |
|
1978 |
.................... while ( (c >= '0' && c <= '9') || (c >= 'A' && c <='F')) |
- |
|
1979 |
.................... { |
- |
|
1980 |
.................... if (c >= '0' && c <= '9') |
- |
|
1981 |
.................... result = (result << 4) + (c - '0'); |
- |
|
1982 |
.................... else |
- |
|
1983 |
.................... result = (result << 4) + (c - 'A' + 10); |
- |
|
1984 |
.................... |
- |
|
1985 |
.................... c = s[index++];c = toupper(c); |
- |
|
1986 |
.................... } |
- |
|
1987 |
.................... } |
- |
|
1988 |
.................... } |
- |
|
1989 |
.................... |
- |
|
1990 |
.................... if (base == 10 && sign == 1) |
- |
|
1991 |
.................... result = -result; |
- |
|
1992 |
.................... |
- |
|
1993 |
.................... return(result); |
- |
|
1994 |
.................... } |
- |
|
1995 |
.................... |
- |
|
1996 |
.................... /* A fast routine to multiply by 10 |
- |
|
1997 |
.................... */ |
- |
|
1998 |
.................... signed int32 mult_with10(int32 num) |
- |
|
1999 |
.................... { |
- |
|
2000 |
.................... return ( (num << 1) + (num << 3) ); |
- |
|
2001 |
.................... } |
- |
|
2002 |
.................... |
- |
|
2003 |
.................... signed int32 atoi32(char *s) |
- |
|
2004 |
.................... { |
- |
|
2005 |
.................... signed int32 result; |
- |
|
2006 |
.................... int sign, base, index; |
- |
|
2007 |
.................... char c; |
- |
|
2008 |
.................... |
- |
|
2009 |
.................... index = 0; |
- |
|
2010 |
.................... sign = 0; |
- |
|
2011 |
.................... base = 10; |
- |
|
2012 |
.................... result = 0; |
- |
|
2013 |
.................... |
- |
|
2014 |
.................... if (!s) |
- |
|
2015 |
.................... return 0; |
- |
|
2016 |
.................... c = s[index++]; |
- |
|
2017 |
.................... |
- |
|
2018 |
.................... // increase index if either positive or negative sign is detected |
- |
|
2019 |
.................... if (c == '-') |
- |
|
2020 |
.................... { |
- |
|
2021 |
.................... sign = 1; // Set the sign to negative |
- |
|
2022 |
.................... c = s[index++]; |
- |
|
2023 |
.................... } |
- |
|
2024 |
.................... else if (c == '+') |
- |
|
2025 |
.................... { |
- |
|
2026 |
.................... c = s[index++]; |
- |
|
2027 |
.................... } |
- |
|
2028 |
.................... |
- |
|
2029 |
.................... if (c >= '0' && c <= '9') |
- |
|
2030 |
.................... { |
- |
|
2031 |
.................... if (c == '0' && (s[index] == 'x' || s[index] == 'X')) |
- |
|
2032 |
.................... { |
- |
|
2033 |
.................... base = 16; |
- |
|
2034 |
.................... index++; |
- |
|
2035 |
.................... c = s[index++]; |
- |
|
2036 |
.................... } |
- |
|
2037 |
.................... |
- |
|
2038 |
.................... // The number is a decimal number |
- |
|
2039 |
.................... if (base == 10) |
- |
|
2040 |
.................... { |
- |
|
2041 |
.................... while (c >= '0' && c <= '9') { |
- |
|
2042 |
.................... result = (result << 1) + (result << 3); // result *= 10; |
- |
|
2043 |
.................... result += (c - '0'); |
- |
|
2044 |
.................... c = s[index++]; |
- |
|
2045 |
.................... } |
- |
|
2046 |
.................... } |
- |
|
2047 |
.................... else if (base == 16) // The number is a hexa number |
- |
|
2048 |
.................... { |
- |
|
2049 |
.................... c = toupper(c); |
- |
|
2050 |
.................... while ((c >= '0' && c <= '9') || (c >= 'A' && c <='F')) |
- |
|
2051 |
.................... { |
- |
|
2052 |
.................... if (c >= '0' && c <= '9') |
- |
|
2053 |
.................... result = (result << 4) + (c - '0'); |
- |
|
2054 |
.................... else |
- |
|
2055 |
.................... result = (result << 4) + (c - 'A' + 10); |
- |
|
2056 |
.................... |
- |
|
2057 |
.................... c = s[index++];c = toupper(c); |
- |
|
2058 |
.................... } |
- |
|
2059 |
.................... } |
- |
|
2060 |
.................... } |
- |
|
2061 |
.................... |
- |
|
2062 |
.................... if (base == 10 && sign == 1) |
- |
|
2063 |
.................... result = -result; |
- |
|
2064 |
.................... |
- |
|
2065 |
.................... return(result); |
- |
|
2066 |
.................... } |
- |
|
2067 |
.................... |
- |
|
2068 |
.................... char * itoa(signed int32 num, int8 base, char *s) |
- |
|
2069 |
.................... { |
- |
|
2070 |
.................... int32 temp=1; |
- |
|
2071 |
.................... int8 i,sign=0,cnt=0; |
- |
|
2072 |
.................... char c; |
- |
|
2073 |
.................... |
- |
|
2074 |
.................... if(num<0) { |
- |
|
2075 |
.................... sign=1; // Check for negative number |
- |
|
2076 |
.................... num*=-1; |
- |
|
2077 |
.................... } |
- |
|
2078 |
.................... |
- |
|
2079 |
.................... while(temp>0) { |
- |
|
2080 |
.................... temp=(num/base); |
- |
|
2081 |
.................... s[cnt]=(num%base)+'0'; // Conversion |
- |
|
2082 |
.................... |
- |
|
2083 |
.................... if(s[cnt]>0x39) |
- |
|
2084 |
.................... s[cnt]+=0x7; |
- |
|
2085 |
.................... |
- |
|
2086 |
.................... cnt++; |
- |
|
2087 |
.................... num=temp; |
- |
|
2088 |
.................... } |
- |
|
2089 |
.................... |
- |
|
2090 |
.................... if(sign==1) { |
- |
|
2091 |
.................... s[cnt]=0x2D; // Negative sign |
- |
|
2092 |
.................... cnt++; |
- |
|
2093 |
.................... } |
- |
|
2094 |
.................... |
- |
|
2095 |
.................... for(i = 0;i<(int8)(cnt/2);i++) { |
- |
|
2096 |
.................... |
- |
|
2097 |
.................... c=s[i]; |
- |
|
2098 |
.................... s[i]=s[cnt-i-1]; // Reverse the number |
- |
|
2099 |
.................... s[cnt-i-1]=c; |
- |
|
2100 |
.................... } |
- |
|
2101 |
.................... s[cnt]='\0'; // End the string |
- |
|
2102 |
.................... return s; |
- |
|
2103 |
.................... } |
- |
|
2104 |
.................... |
- |
|
2105 |
.................... float strtod(char *s,char *endptr) { |
- |
|
2106 |
.................... float pow10 = 1.0; |
- |
|
2107 |
.................... float result = 0.0; |
- |
|
2108 |
.................... int sign = 0, point = 0; |
- |
|
2109 |
.................... char c; |
- |
|
2110 |
.................... int ptr = 0; |
- |
|
2111 |
.................... |
- |
|
2112 |
.................... if (!s) |
- |
|
2113 |
.................... return 0; |
- |
|
2114 |
.................... c=s[ptr++]; |
- |
|
2115 |
.................... |
- |
|
2116 |
.................... |
- |
|
2117 |
.................... while((c>='0' && c<='9') || c=='+' || c=='-' || c=='.') { |
- |
|
2118 |
.................... if(c == '-') { |
- |
|
2119 |
.................... sign = 1; |
- |
|
2120 |
.................... c = s[ptr++]; |
- |
|
2121 |
.................... } |
- |
|
2122 |
.................... |
- |
|
2123 |
.................... while((c >= '0' && c <= '9') && point == 0) { |
- |
|
2124 |
.................... result = 10*result + c - '0'; |
- |
|
2125 |
.................... c = s[ptr++]; |
- |
|
2126 |
.................... } |
- |
|
2127 |
.................... |
- |
|
2128 |
.................... if (c == '.') { |
- |
|
2129 |
.................... point = 1; |
- |
|
2130 |
.................... c = s[ptr++]; |
- |
|
2131 |
.................... } |
- |
|
2132 |
.................... |
- |
|
2133 |
.................... while((c >= '0' && c <= '9') && point == 1) { |
- |
|
2134 |
.................... pow10 = pow10*10; |
- |
|
2135 |
.................... result += (c - '0')/pow10; |
- |
|
2136 |
.................... c = s[ptr++]; |
- |
|
2137 |
.................... } |
- |
|
2138 |
.................... |
- |
|
2139 |
.................... if (c == '+') { |
- |
|
2140 |
.................... c = s[ptr++]; |
- |
|
2141 |
.................... } |
- |
|
2142 |
.................... } |
- |
|
2143 |
.................... |
- |
|
2144 |
.................... if (sign == 1) |
- |
|
2145 |
.................... result = -1*result; |
- |
|
2146 |
.................... if(endptr) |
- |
|
2147 |
.................... { |
- |
|
2148 |
.................... if (ptr) { |
- |
|
2149 |
.................... ptr--; |
- |
|
2150 |
.................... *((char *)endptr)=s+ptr; |
- |
|
2151 |
.................... } |
- |
|
2152 |
.................... else |
- |
|
2153 |
.................... *((char *)endptr)=s; |
- |
|
2154 |
.................... } |
- |
|
2155 |
.................... |
- |
|
2156 |
.................... return(result); |
- |
|
2157 |
.................... } |
- |
|
2158 |
.................... |
- |
|
2159 |
.................... long strtoul(char *s,char *endptr,signed int base) |
- |
|
2160 |
.................... { |
- |
|
2161 |
.................... char *sc,*s1,*sd; |
- |
|
2162 |
.................... unsigned long x=0; |
- |
|
2163 |
.................... char sign; |
- |
|
2164 |
.................... char digits[]="0123456789abcdefghijklmnopqstuvwxyz"; |
- |
|
2165 |
.................... for(sc=s;isspace(*sc);++sc); |
- |
|
2166 |
.................... sign=*sc=='-'||*sc=='+'?*sc++:'+'; |
- |
|
2167 |
.................... if(sign=='-') |
- |
|
2168 |
.................... { |
- |
|
2169 |
.................... if (endptr) |
- |
|
2170 |
.................... { |
- |
|
2171 |
.................... *((char *)endptr)=s; |
- |
|
2172 |
.................... } |
- |
|
2173 |
.................... return 0; |
- |
|
2174 |
.................... } |
- |
|
2175 |
.................... |
- |
|
2176 |
.................... if (base <0 || base ==1|| base >36) // invalid base |
- |
|
2177 |
.................... { |
- |
|
2178 |
.................... if (endptr) |
- |
|
2179 |
.................... { |
- |
|
2180 |
.................... *((char *)endptr)=s; |
- |
|
2181 |
.................... } |
- |
|
2182 |
.................... return 0; |
- |
|
2183 |
.................... } |
- |
|
2184 |
.................... else if (base) |
- |
|
2185 |
.................... { |
- |
|
2186 |
.................... if(base==16 && *sc =='0'&&(sc[1]=='x' || sc[1]=='X')) |
- |
|
2187 |
.................... sc+=2; |
- |
|
2188 |
.................... if(base==8 && *sc =='0') |
- |
|
2189 |
.................... sc+=1; |
- |
|
2190 |
.................... if(base==2 && *sc =='0'&&sc[1]=='b') |
- |
|
2191 |
.................... sc+=2; |
- |
|
2192 |
.................... |
- |
|
2193 |
.................... } |
- |
|
2194 |
.................... else if(*sc!='0') // base is 0, find base |
- |
|
2195 |
.................... base=10; |
- |
|
2196 |
.................... else if (sc[1]=='x' || sc[1]=='X') |
- |
|
2197 |
.................... base =16,sc+=2; |
- |
|
2198 |
.................... else if(sc[1]=='b') |
- |
|
2199 |
.................... base=2,sc+=2; |
1013 |
.................... else |
2200 |
.................... else |
1014 |
0383: GOTO 5DF |
2201 |
.................... base=8; |
- |
|
2202 |
.................... for (s1=sc;*sc=='0';++sc);// skip leading zeroes |
- |
|
2203 |
.................... sd=memchr(digits,tolower(*sc),base); |
- |
|
2204 |
.................... for(; sd!=0; ) |
1015 |
.................... { |
2205 |
.................... { |
- |
|
2206 |
.................... x=x*base+(int16)(sd-digits); |
- |
|
2207 |
.................... ++sc; |
- |
|
2208 |
.................... sd=memchr(digits,tolower(*sc),base); |
- |
|
2209 |
.................... } |
- |
|
2210 |
.................... if(s1==sc) |
- |
|
2211 |
.................... { |
- |
|
2212 |
.................... if (endptr) |
- |
|
2213 |
.................... { |
- |
|
2214 |
.................... *((char *)endptr)=s; |
- |
|
2215 |
.................... } |
- |
|
2216 |
.................... return 0; |
- |
|
2217 |
.................... } |
- |
|
2218 |
.................... if (endptr) |
- |
|
2219 |
.................... *((char *)endptr)=sc; |
- |
|
2220 |
.................... return x; |
- |
|
2221 |
.................... } |
- |
|
2222 |
.................... |
- |
|
2223 |
.................... |
- |
|
2224 |
.................... signed long strtol(char *s,char *endptr,signed int base) |
- |
|
2225 |
.................... { |
- |
|
2226 |
.................... char *sc,*s1,*sd; |
- |
|
2227 |
.................... signed long x=0; |
- |
|
2228 |
.................... char sign; |
- |
|
2229 |
.................... char digits[]="0123456789abcdefghijklmnopqstuvwxyz"; |
- |
|
2230 |
.................... for(sc=s;isspace(*sc);++sc); |
- |
|
2231 |
.................... sign=*sc=='-'||*sc=='+'?*sc++:'+'; |
- |
|
2232 |
.................... if (base <0 || base ==1|| base >36) // invalid base |
- |
|
2233 |
.................... { |
- |
|
2234 |
.................... if (endptr) |
- |
|
2235 |
.................... { |
- |
|
2236 |
.................... *((char *)endptr)=s; |
- |
|
2237 |
.................... } |
- |
|
2238 |
.................... return 0; |
- |
|
2239 |
.................... } |
- |
|
2240 |
.................... else if (base) |
- |
|
2241 |
.................... { |
- |
|
2242 |
.................... if(base==16 && *sc =='0'&&(sc[1]=='x' || sc[1]=='X')) |
- |
|
2243 |
.................... sc+=2; |
- |
|
2244 |
.................... if(base==8 && *sc =='0') |
- |
|
2245 |
.................... sc+=1; |
- |
|
2246 |
.................... if(base==2 && *sc =='0'&&sc[1]=='b') |
- |
|
2247 |
.................... sc+=2; |
- |
|
2248 |
.................... |
- |
|
2249 |
.................... } |
- |
|
2250 |
.................... else if(*sc!='0') // base is 0, find base |
- |
|
2251 |
.................... base=10; |
- |
|
2252 |
.................... else if (sc[1]=='x' || sc[1]=='X') |
- |
|
2253 |
.................... base =16,sc+=2; |
- |
|
2254 |
.................... else if(sc[1]=='b') |
- |
|
2255 |
.................... base=2,sc+=2; |
- |
|
2256 |
.................... else |
- |
|
2257 |
.................... base=8; |
- |
|
2258 |
.................... for (s1=sc;*sc=='0';++sc);// skip leading zeroes |
- |
|
2259 |
.................... |
- |
|
2260 |
.................... sd=memchr(digits,tolower(*sc),base); |
- |
|
2261 |
.................... for(;sd!=0;) |
- |
|
2262 |
.................... { |
- |
|
2263 |
.................... x=x*base+(int16)(sd-digits); |
- |
|
2264 |
.................... ++sc; |
- |
|
2265 |
.................... sd=memchr(digits,tolower(*sc),base); |
- |
|
2266 |
.................... } |
- |
|
2267 |
.................... if(s1==sc) |
- |
|
2268 |
.................... { |
- |
|
2269 |
.................... if (endptr) |
- |
|
2270 |
.................... { |
- |
|
2271 |
.................... *((char *)endptr)=s; |
- |
|
2272 |
.................... } |
- |
|
2273 |
.................... return 0; |
- |
|
2274 |
.................... } |
- |
|
2275 |
.................... if(sign=='-') |
- |
|
2276 |
.................... x =-x; |
- |
|
2277 |
.................... if (endptr) |
- |
|
2278 |
.................... *((char *)endptr)=sc; |
- |
|
2279 |
.................... return x; |
- |
|
2280 |
.................... } |
- |
|
2281 |
.................... |
- |
|
2282 |
.................... signed int system(char *string) |
- |
|
2283 |
.................... { |
- |
|
2284 |
.................... return 0; |
- |
|
2285 |
.................... } |
- |
|
2286 |
.................... |
- |
|
2287 |
.................... int mblen(char *s,size_t n) |
- |
|
2288 |
.................... { |
- |
|
2289 |
.................... return strlen(s); |
- |
|
2290 |
.................... } |
- |
|
2291 |
.................... |
- |
|
2292 |
.................... int mbtowc(wchar_t *pwc,char *s,size_t n) |
- |
|
2293 |
.................... { |
- |
|
2294 |
.................... *pwc=*s; |
- |
|
2295 |
.................... return 1; |
- |
|
2296 |
.................... } |
- |
|
2297 |
.................... |
- |
|
2298 |
.................... int wctomb(char *s,wchar_t wchar) |
- |
|
2299 |
.................... { |
- |
|
2300 |
.................... *s=wchar; |
- |
|
2301 |
.................... return 1; |
- |
|
2302 |
.................... } |
- |
|
2303 |
.................... |
- |
|
2304 |
.................... size_t mbstowcs(wchar_t *pwcs,char *s,size_t n) |
- |
|
2305 |
.................... { |
- |
|
2306 |
.................... strncpy(pwcs,s,n); |
- |
|
2307 |
.................... return strlen(pwcs); |
- |
|
2308 |
.................... } |
- |
|
2309 |
.................... |
- |
|
2310 |
.................... size_t wcstombs(char *s,wchar_t *pwcs,size_t n) |
- |
|
2311 |
.................... { |
- |
|
2312 |
.................... strncpy(s,pwcs,n); |
- |
|
2313 |
.................... return strlen(s); |
- |
|
2314 |
.................... } |
- |
|
2315 |
.................... |
- |
|
2316 |
.................... //--------------------------------------------------------------------------- |
- |
|
2317 |
.................... // The random number implementation |
- |
|
2318 |
.................... //--------------------------------------------------------------------------- |
- |
|
2319 |
.................... |
- |
|
2320 |
.................... unsigned int32 _Randseed = 1; |
- |
|
2321 |
006F: MOVLW 01 |
- |
|
2322 |
0070: MOVWF 22 |
- |
|
2323 |
0071: CLRF 23 |
- |
|
2324 |
0072: CLRF 24 |
- |
|
2325 |
0073: CLRF 25 |
- |
|
2326 |
.................... |
- |
|
2327 |
.................... long rand(void) |
- |
|
2328 |
.................... { |
- |
|
2329 |
.................... _Randseed = _Randseed * 1103515245 + 12345; |
- |
|
2330 |
.................... return ((unsigned long)(_Randseed >> 16) % RAND_MAX); |
- |
|
2331 |
.................... } |
- |
|
2332 |
.................... |
- |
|
2333 |
.................... void srand(unsigned int32 seed) |
- |
|
2334 |
.................... { |
- |
|
2335 |
.................... _Randseed = seed; |
- |
|
2336 |
.................... } |
- |
|
2337 |
.................... |
- |
|
2338 |
.................... //--------------------------------------------------------------------------- |
- |
|
2339 |
.................... // Searching and sorting utilities implementation |
- |
|
2340 |
.................... //--------------------------------------------------------------------------- |
- |
|
2341 |
.................... |
- |
|
2342 |
.................... typedef signed int (*_Cmpfun)(char * p1,char * p2); |
- |
|
2343 |
.................... |
- |
|
2344 |
.................... void qsort(char * qdata, int qitems, int qsize, _Cmpfun cmp) { |
- |
|
2345 |
.................... int m,j,i,l; |
- |
|
2346 |
.................... short done; |
- |
|
2347 |
.................... BYTE t[16]; |
- |
|
2348 |
.................... |
- |
|
2349 |
.................... m = qitems/2; |
- |
|
2350 |
.................... while( m > 0 ) { |
- |
|
2351 |
.................... for(j=0; j<(qitems-m); ++j) { |
- |
|
2352 |
.................... i = j; |
- |
|
2353 |
.................... do |
- |
|
2354 |
.................... { |
- |
|
2355 |
.................... done=TRUE; |
- |
|
2356 |
.................... l = i+m; |
- |
|
2357 |
.................... if( (*cmp)(qdata+i*qsize, qdata+l*qsize) > 0 ) { |
- |
|
2358 |
.................... memcpy(t, qdata+i*qsize, qsize); |
- |
|
2359 |
.................... memcpy(qdata+i*qsize, qdata+l*qsize, qsize); |
- |
|
2360 |
.................... memcpy(qdata+l*qsize, t, qsize); |
- |
|
2361 |
.................... if(m <= i) |
- |
|
2362 |
.................... i -= m; |
- |
|
2363 |
.................... done = FALSE; |
- |
|
2364 |
.................... } |
- |
|
2365 |
.................... } while(!done); |
- |
|
2366 |
.................... } |
- |
|
2367 |
.................... m = m/2; |
- |
|
2368 |
.................... } |
- |
|
2369 |
.................... } |
- |
|
2370 |
.................... |
- |
|
2371 |
.................... |
- |
|
2372 |
.................... char *bsearch(char *key, char *base, size_t num, size_t width,_Cmpfun cmp) |
- |
|
2373 |
.................... { |
- |
|
2374 |
.................... char *p, *q; |
- |
|
2375 |
.................... size_t n; |
- |
|
2376 |
.................... size_t pivot; |
- |
|
2377 |
.................... signed int val; |
- |
|
2378 |
.................... |
- |
|
2379 |
.................... p = base; |
- |
|
2380 |
.................... n = num; |
- |
|
2381 |
.................... |
- |
|
2382 |
.................... while (n > 0) |
- |
|
2383 |
.................... { |
- |
|
2384 |
.................... pivot = n >> 1; |
- |
|
2385 |
.................... q = p + width * pivot; |
- |
|
2386 |
.................... |
- |
|
2387 |
.................... val = (*cmp)(key, q); |
- |
|
2388 |
.................... |
- |
|
2389 |
.................... if (val < 0) |
- |
|
2390 |
.................... n = pivot; |
- |
|
2391 |
.................... else if (val == 0) |
- |
|
2392 |
.................... return ((char *)q); |
- |
|
2393 |
.................... else { |
- |
|
2394 |
.................... p = q + width; |
- |
|
2395 |
.................... n -= pivot + 1; |
- |
|
2396 |
.................... } |
- |
|
2397 |
.................... } |
- |
|
2398 |
.................... |
- |
|
2399 |
.................... return NULL; // There's no match |
- |
|
2400 |
.................... } |
- |
|
2401 |
.................... |
- |
|
2402 |
.................... |
- |
|
2403 |
.................... #endif |
- |
|
2404 |
.................... |
- |
|
2405 |
.................... |
- |
|
2406 |
.................... #define DELKA 40 |
- |
|
2407 |
.................... |
- |
|
2408 |
.................... char odp[DELKA]; |
- |
|
2409 |
.................... |
- |
|
2410 |
.................... int1 check_new_sms() |
- |
|
2411 |
.................... { |
- |
|
2412 |
.................... fprintf(MOBIL,"AT+CMGL=1\r"); //vycti prijate SMS (0=nove;1=vsechny) |
1016 |
.................... //!!!KAKL for(pom=0;pom<55;pom++) //preskoc nedulezite informace |
2413 |
.................... while(fgetc(MOBIL)!=0x0A); // predkoc prvni radek odpovedi |
- |
|
2414 |
.................... odp[0]=fgetc(MOBIL); // Nacti prvni dva znaky druheho radku odpovedi |
- |
|
2415 |
.................... odp[1]=fgetc(MOBIL); |
- |
|
2416 |
.................... while(fgetc(MOBIL)!=0x0A); // Preskoc zbytek radku |
- |
|
2417 |
.................... |
- |
|
2418 |
.................... if(odp[0] == 'O' && odp[1] == 'K') return 1; |
- |
|
2419 |
.................... else return 0; |
- |
|
2420 |
.................... } |
- |
|
2421 |
.................... |
- |
|
2422 |
.................... read_sms() |
- |
|
2423 |
.................... { |
- |
|
2424 |
.................... int pom,pom2,pom3,odkl,odkl2,maskovadlo; |
1017 |
.................... for(pom=0;pom<54;pom++) //preskoc nedulezite informace |
2425 |
.................... for(pom=0;pom<54;pom++) //preskoc nedulezite informace |
1018 |
0384: CLRF 49 |
- |
|
1019 |
0385: MOVF 49,W |
- |
|
1020 |
0386: SUBLW 35 |
- |
|
1021 |
0387: BTFSS 03.0 |
- |
|
1022 |
0388: GOTO 38C |
- |
|
1023 |
.................... { |
2426 |
.................... { |
1024 |
.................... fgetc(MOBIL); |
2427 |
.................... fgetc(MOBIL); |
1025 |
0389: CALL 1ED |
- |
|
1026 |
.................... } |
2428 |
.................... } |
1027 |
038A: INCF 49,F |
- |
|
1028 |
038B: GOTO 385 |
- |
|
1029 |
.................... |
2429 |
.................... |
1030 |
.................... //gets(odp); //uloz zakodovany text SMS |
2430 |
.................... //gets(odp); //uloz zakodovany text SMS |
1031 |
.................... |
2431 |
.................... |
1032 |
.................... odp[0]=fgetc(MOBIL); |
2432 |
.................... odp[0]=fgetc(MOBIL); |
1033 |
038C: CALL 1ED |
- |
|
1034 |
038D: MOVF 78,W |
- |
|
1035 |
038E: MOVWF 21 |
- |
|
1036 |
.................... odp[1]=fgetc(MOBIL); |
2433 |
.................... odp[1]=fgetc(MOBIL); |
1037 |
038F: CALL 1ED |
- |
|
1038 |
0390: MOVF 78,W |
- |
|
1039 |
0391: MOVWF 22 |
- |
|
1040 |
.................... odp[2]=fgetc(MOBIL); |
2434 |
.................... odp[2]=fgetc(MOBIL); |
1041 |
0392: CALL 1ED |
- |
|
1042 |
0393: MOVF 78,W |
- |
|
1043 |
0394: MOVWF 23 |
- |
|
1044 |
.................... odp[3]=fgetc(MOBIL); |
2435 |
.................... odp[3]=fgetc(MOBIL); |
1045 |
0395: CALL 1ED |
- |
|
1046 |
0396: MOVF 78,W |
- |
|
1047 |
0397: MOVWF 24 |
- |
|
1048 |
.................... odp[4]=fgetc(MOBIL); |
2436 |
.................... odp[4]=fgetc(MOBIL); |
1049 |
0398: CALL 1ED |
- |
|
1050 |
0399: MOVF 78,W |
- |
|
1051 |
039A: MOVWF 25 |
- |
|
1052 |
.................... odp[5]=fgetc(MOBIL); |
2437 |
.................... odp[5]=fgetc(MOBIL); |
1053 |
039B: CALL 1ED |
- |
|
1054 |
039C: MOVF 78,W |
- |
|
1055 |
039D: MOVWF 26 |
- |
|
1056 |
.................... odp[6]=fgetc(MOBIL); |
2438 |
.................... odp[6]=fgetc(MOBIL); |
1057 |
039E: CALL 1ED |
- |
|
1058 |
039F: MOVF 78,W |
- |
|
1059 |
03A0: MOVWF 27 |
- |
|
1060 |
.................... odp[7]=fgetc(MOBIL); |
2439 |
.................... odp[7]=fgetc(MOBIL); |
1061 |
03A1: CALL 1ED |
- |
|
1062 |
03A2: MOVF 78,W |
- |
|
1063 |
03A3: MOVWF 28 |
- |
|
1064 |
.................... |
2440 |
.................... |
1065 |
.................... /*lcd_gotoxy(1,1); |
2441 |
.................... /*lcd_gotoxy(1,1); |
1066 |
.................... printf(lcd_putc,"\f%s\n",odp);*/ |
2442 |
.................... printf(lcd_putc,"\f%s\n",odp);*/ |
1067 |
.................... |
2443 |
.................... |
1068 |
.................... if(odp[0]==0) odp[1]='0'; // Prevod z ASCII do BIN |
2444 |
.................... if(odp[0]==0) odp[1]='0'; // Prevod z ASCII do BIN |
1069 |
03A4: MOVF 21,F |
- |
|
1070 |
03A5: BTFSS 03.2 |
- |
|
1071 |
03A6: GOTO 3A9 |
- |
|
1072 |
03A7: MOVLW 30 |
- |
|
1073 |
03A8: MOVWF 22 |
- |
|
1074 |
.................... odp[0]=odp[0] - '0'; |
2445 |
.................... odp[0]=odp[0] - '0'; |
1075 |
03A9: MOVLW 30 |
- |
|
1076 |
03AA: SUBWF 21,F |
- |
|
1077 |
.................... odp[1]=odp[1] - '0'; |
2446 |
.................... odp[1]=odp[1] - '0'; |
1078 |
03AB: SUBWF 22,F |
- |
|
1079 |
.................... if(odp[0]>9) odp[0]=odp[0]-7; |
2447 |
.................... if(odp[0]>9) odp[0]=odp[0]-7; |
1080 |
03AC: MOVF 21,W |
- |
|
1081 |
03AD: SUBLW 09 |
- |
|
1082 |
03AE: BTFSC 03.0 |
- |
|
1083 |
03AF: GOTO 3B2 |
- |
|
1084 |
03B0: MOVLW 07 |
- |
|
1085 |
03B1: SUBWF 21,F |
- |
|
1086 |
.................... if(odp[1]>9) odp[1]=odp[1]-7; |
2448 |
.................... if(odp[1]>9) odp[1]=odp[1]-7; |
1087 |
03B2: MOVF 22,W |
- |
|
1088 |
03B3: SUBLW 09 |
- |
|
1089 |
03B4: BTFSC 03.0 |
- |
|
1090 |
03B5: GOTO 3B8 |
- |
|
1091 |
03B6: MOVLW 07 |
- |
|
1092 |
03B7: SUBWF 22,F |
- |
|
1093 |
.................... odp[0]=odp[0] << 4; |
2449 |
.................... odp[0]=odp[0] << 4; |
1094 |
03B8: SWAPF 21,F |
- |
|
1095 |
03B9: MOVLW F0 |
- |
|
1096 |
03BA: ANDWF 21,F |
- |
|
1097 |
.................... odp[0] |= odp[1]; |
2450 |
.................... odp[0] |= odp[1]; |
1098 |
03BB: MOVF 22,W |
- |
|
1099 |
03BC: IORWF 21,F |
- |
|
1100 |
.................... |
2451 |
.................... |
1101 |
.................... if(odp[2]==0) odp[3]='0'; |
2452 |
.................... if(odp[2]==0) odp[3]='0'; |
1102 |
03BD: MOVF 23,F |
- |
|
1103 |
03BE: BTFSS 03.2 |
- |
|
1104 |
03BF: GOTO 3C2 |
- |
|
1105 |
03C0: MOVLW 30 |
- |
|
1106 |
03C1: MOVWF 24 |
- |
|
1107 |
.................... odp[2]=odp[2] - '0'; |
2453 |
.................... odp[2]=odp[2] - '0'; |
1108 |
03C2: MOVLW 30 |
- |
|
1109 |
03C3: SUBWF 23,F |
- |
|
1110 |
.................... odp[3]=odp[3] - '0'; |
2454 |
.................... odp[3]=odp[3] - '0'; |
1111 |
03C4: SUBWF 24,F |
- |
|
1112 |
.................... if(odp[2]>9) odp[2]=odp[2]-7; |
2455 |
.................... if(odp[2]>9) odp[2]=odp[2]-7; |
1113 |
03C5: MOVF 23,W |
- |
|
1114 |
03C6: SUBLW 09 |
- |
|
1115 |
03C7: BTFSC 03.0 |
- |
|
1116 |
03C8: GOTO 3CB |
- |
|
1117 |
03C9: MOVLW 07 |
- |
|
1118 |
03CA: SUBWF 23,F |
- |
|
1119 |
.................... if(odp[3]>9) odp[3]=odp[3]-7; |
2456 |
.................... if(odp[3]>9) odp[3]=odp[3]-7; |
1120 |
03CB: MOVF 24,W |
- |
|
1121 |
03CC: SUBLW 09 |
- |
|
1122 |
03CD: BTFSC 03.0 |
- |
|
1123 |
03CE: GOTO 3D1 |
- |
|
1124 |
03CF: MOVLW 07 |
- |
|
1125 |
03D0: SUBWF 24,F |
- |
|
1126 |
.................... odp[2]=odp[2] << 4; |
2457 |
.................... odp[2]=odp[2] << 4; |
1127 |
03D1: SWAPF 23,F |
- |
|
1128 |
03D2: MOVLW F0 |
- |
|
1129 |
03D3: ANDWF 23,F |
- |
|
1130 |
.................... odp[2] |= odp[3]; |
2458 |
.................... odp[2] |= odp[3]; |
1131 |
03D4: MOVF 24,W |
- |
|
1132 |
03D5: IORWF 23,F |
- |
|
1133 |
.................... |
2459 |
.................... |
1134 |
.................... if(odp[4]==0) odp[5]='0'; |
2460 |
.................... if(odp[4]==0) odp[5]='0'; |
1135 |
03D6: MOVF 25,F |
- |
|
1136 |
03D7: BTFSS 03.2 |
- |
|
1137 |
03D8: GOTO 3DB |
- |
|
1138 |
03D9: MOVLW 30 |
- |
|
1139 |
03DA: MOVWF 26 |
- |
|
1140 |
.................... odp[4]=odp[4] - '0'; |
2461 |
.................... odp[4]=odp[4] - '0'; |
1141 |
03DB: MOVLW 30 |
- |
|
1142 |
03DC: SUBWF 25,F |
- |
|
1143 |
.................... odp[5]=odp[5] - '0'; |
2462 |
.................... odp[5]=odp[5] - '0'; |
1144 |
03DD: SUBWF 26,F |
- |
|
1145 |
.................... if(odp[4]>9) odp[4]=odp[4]-7; |
2463 |
.................... if(odp[4]>9) odp[4]=odp[4]-7; |
1146 |
03DE: MOVF 25,W |
- |
|
1147 |
03DF: SUBLW 09 |
- |
|
1148 |
03E0: BTFSC 03.0 |
- |
|
1149 |
03E1: GOTO 3E4 |
- |
|
1150 |
03E2: MOVLW 07 |
- |
|
1151 |
03E3: SUBWF 25,F |
- |
|
1152 |
.................... if(odp[5]>9) odp[5]=odp[5]-7; |
2464 |
.................... if(odp[5]>9) odp[5]=odp[5]-7; |
1153 |
03E4: MOVF 26,W |
- |
|
1154 |
03E5: SUBLW 09 |
- |
|
1155 |
03E6: BTFSC 03.0 |
- |
|
1156 |
03E7: GOTO 3EA |
- |
|
1157 |
03E8: MOVLW 07 |
- |
|
1158 |
03E9: SUBWF 26,F |
- |
|
1159 |
.................... odp[4]=odp[4] << 4; |
2465 |
.................... odp[4]=odp[4] << 4; |
1160 |
03EA: SWAPF 25,F |
- |
|
1161 |
03EB: MOVLW F0 |
- |
|
1162 |
03EC: ANDWF 25,F |
- |
|
1163 |
.................... odp[4] |= odp[5]; |
2466 |
.................... odp[4] |= odp[5]; |
1164 |
03ED: MOVF 26,W |
- |
|
1165 |
03EE: IORWF 25,F |
- |
|
1166 |
.................... |
2467 |
.................... |
1167 |
.................... if(odp[6]==0) odp[7]='0'; |
2468 |
.................... if(odp[6]==0) odp[7]='0'; |
1168 |
03EF: MOVF 27,F |
- |
|
1169 |
03F0: BTFSS 03.2 |
- |
|
1170 |
03F1: GOTO 3F4 |
- |
|
1171 |
03F2: MOVLW 30 |
- |
|
1172 |
03F3: MOVWF 28 |
- |
|
1173 |
.................... odp[6]=odp[6] - '0'; |
2469 |
.................... odp[6]=odp[6] - '0'; |
1174 |
03F4: MOVLW 30 |
- |
|
1175 |
03F5: SUBWF 27,F |
- |
|
1176 |
.................... odp[7]=odp[7] - '0'; |
2470 |
.................... odp[7]=odp[7] - '0'; |
1177 |
03F6: SUBWF 28,F |
- |
|
1178 |
.................... if(odp[6]>9) odp[6]=odp[6]-7; |
2471 |
.................... if(odp[6]>9) odp[6]=odp[6]-7; |
1179 |
03F7: MOVF 27,W |
- |
|
1180 |
03F8: SUBLW 09 |
- |
|
1181 |
03F9: BTFSC 03.0 |
- |
|
1182 |
03FA: GOTO 3FD |
- |
|
1183 |
03FB: MOVLW 07 |
- |
|
1184 |
03FC: SUBWF 27,F |
- |
|
1185 |
.................... if(odp[7]>9) odp[7]=odp[7]-7; |
2472 |
.................... if(odp[7]>9) odp[7]=odp[7]-7; |
1186 |
03FD: MOVF 28,W |
- |
|
1187 |
03FE: SUBLW 09 |
- |
|
1188 |
03FF: BTFSC 03.0 |
- |
|
1189 |
0400: GOTO 403 |
- |
|
1190 |
0401: MOVLW 07 |
- |
|
1191 |
0402: SUBWF 28,F |
- |
|
1192 |
.................... odp[6]=odp[6] << 4; |
2473 |
.................... odp[6]=odp[6] << 4; |
1193 |
0403: SWAPF 27,F |
- |
|
1194 |
0404: MOVLW F0 |
- |
|
1195 |
0405: ANDWF 27,F |
- |
|
1196 |
.................... odp[6] |= odp[7]; |
2474 |
.................... odp[6] |= odp[7]; |
1197 |
0406: MOVF 28,W |
- |
|
1198 |
0407: IORWF 27,F |
- |
|
1199 |
.................... |
2475 |
.................... |
1200 |
.................... odp[1]=odp[2]; |
2476 |
.................... odp[1]=odp[2]; |
1201 |
0408: MOVF 23,W |
- |
|
1202 |
0409: MOVWF 22 |
- |
|
1203 |
.................... odp[2]=odp[4]; |
2477 |
.................... odp[2]=odp[4]; |
1204 |
040A: MOVF 25,W |
- |
|
1205 |
040B: MOVWF 23 |
- |
|
1206 |
.................... odp[3]=odp[6]; |
2478 |
.................... odp[3]=odp[6]; |
1207 |
040C: MOVF 27,W |
- |
|
1208 |
040D: MOVWF 24 |
- |
|
1209 |
.................... odp[4]=odp[5]=odp[6]=0; |
2479 |
.................... odp[4]=odp[5]=odp[6]=0; |
1210 |
040E: CLRF 27 |
- |
|
1211 |
040F: MOVF 27,W |
- |
|
1212 |
0410: MOVWF 26 |
- |
|
1213 |
0411: MOVWF 25 |
- |
|
1214 |
.................... |
2480 |
.................... |
1215 |
.................... /*lcd_gotoxy(1,2); |
2481 |
.................... /*lcd_gotoxy(1,2); |
1216 |
.................... printf(lcd_putc,"%u %u %u %u",odp[0],odp[1],odp[2]odp[3]); */ |
2482 |
.................... printf(lcd_putc,"%u %u %u %u",odp[0],odp[1],odp[2]odp[3]); */ |
1217 |
.................... |
2483 |
.................... |
1218 |
.................... pom3=0; |
2484 |
.................... pom3=0; |
1219 |
0412: CLRF 4B |
- |
|
1220 |
.................... for (pom = 0; pom < 4;pom++) |
2485 |
.................... for (pom = 0; pom < 4;pom++) |
1221 |
0413: CLRF 49 |
- |
|
1222 |
0414: MOVF 49,W |
- |
|
1223 |
0415: SUBLW 03 |
- |
|
1224 |
0416: BTFSS 03.0 |
- |
|
1225 |
0417: GOTO 46B |
- |
|
1226 |
.................... { |
2486 |
.................... { |
1227 |
.................... maskovadlo = maskovadlo >> 1; //rotace promene urcene pro maskovani |
2487 |
.................... maskovadlo = maskovadlo >> 1; //rotace promene urcene pro maskovani |
1228 |
0418: BCF 03.0 |
- |
|
1229 |
0419: RRF 4E,F |
- |
|
1230 |
.................... maskovadlo = maskovadlo | 0x80; |
2488 |
.................... maskovadlo = maskovadlo | 0x80; |
1231 |
041A: BSF 4E.7 |
- |
|
1232 |
.................... odkl = odp[pom] & maskovadlo; //odlozeni "prenosu" do odkl pomoci maskovadla |
2489 |
.................... odkl = odp[pom] & maskovadlo; //odlozeni "prenosu" do odkl pomoci maskovadla |
1233 |
041B: MOVLW 21 |
- |
|
1234 |
041C: ADDWF 49,W |
- |
|
1235 |
041D: MOVWF 04 |
- |
|
1236 |
041E: MOVF 00,W |
- |
|
1237 |
041F: ANDWF 4E,W |
- |
|
1238 |
0420: MOVWF 4C |
- |
|
1239 |
.................... odp[pom] = odp[pom] << pom3; //rotace znaku |
2490 |
.................... odp[pom] = odp[pom] << pom3; //rotace znaku |
1240 |
0421: MOVLW 21 |
- |
|
1241 |
0422: ADDWF 49,W |
- |
|
1242 |
0423: MOVWF 50 |
- |
|
1243 |
0424: MOVLW 21 |
- |
|
1244 |
0425: ADDWF 49,W |
- |
|
1245 |
0426: MOVWF 04 |
- |
|
1246 |
0427: MOVF 00,W |
- |
|
1247 |
0428: MOVWF 77 |
- |
|
1248 |
0429: MOVF 4B,W |
- |
|
1249 |
042A: MOVWF 78 |
- |
|
1250 |
042B: BTFSC 03.2 |
- |
|
1251 |
042C: GOTO 431 |
- |
|
1252 |
042D: BCF 03.0 |
- |
|
1253 |
042E: RLF 77,F |
- |
|
1254 |
042F: DECFSZ 78,F |
- |
|
1255 |
0430: GOTO 42D |
- |
|
1256 |
0431: MOVF 50,W |
- |
|
1257 |
0432: MOVWF 04 |
- |
|
1258 |
0433: MOVF 77,W |
- |
|
1259 |
0434: MOVWF 00 |
- |
|
1260 |
.................... for (pom2 = 0; pom2 < (8-pom3);pom2++) //rotace odkl2 |
2491 |
.................... for (pom2 = 0; pom2 < (8-pom3);pom2++) //rotace odkl2 |
1261 |
0435: CLRF 4A |
- |
|
1262 |
0436: MOVF 4B,W |
- |
|
1263 |
0437: SUBLW 08 |
- |
|
1264 |
0438: SUBWF 4A,W |
- |
|
1265 |
0439: BTFSC 03.0 |
- |
|
1266 |
043A: GOTO 440 |
- |
|
1267 |
.................... { |
2492 |
.................... { |
1268 |
.................... odkl2 = odkl2 >> 1; |
2493 |
.................... odkl2 = odkl2 >> 1; |
1269 |
043B: BCF 03.0 |
- |
|
1270 |
043C: RRF 4D,F |
- |
|
1271 |
.................... odkl2 = odkl2 & 127; |
2494 |
.................... odkl2 = odkl2 & 127; |
1272 |
043D: BCF 4D.7 |
- |
|
1273 |
.................... } |
2495 |
.................... } |
1274 |
043E: INCF 4A,F |
- |
|
1275 |
043F: GOTO 436 |
- |
|
1276 |
.................... odp[pom] = odp[pom] | odkl2; //pridani odkl2 ke znaku |
2496 |
.................... odp[pom] = odp[pom] | odkl2; //pridani odkl2 ke znaku |
1277 |
0440: MOVLW 21 |
- |
|
1278 |
0441: ADDWF 49,W |
- |
|
1279 |
0442: MOVWF 50 |
- |
|
1280 |
0443: MOVLW 21 |
- |
|
1281 |
0444: ADDWF 49,W |
- |
|
1282 |
0445: MOVWF 04 |
- |
|
1283 |
0446: MOVF 00,W |
- |
|
1284 |
0447: IORWF 4D,W |
- |
|
1285 |
0448: MOVWF 52 |
- |
|
1286 |
0449: MOVF 50,W |
- |
|
1287 |
044A: MOVWF 04 |
- |
|
1288 |
044B: MOVF 52,W |
- |
|
1289 |
044C: MOVWF 00 |
- |
|
1290 |
.................... odp[pom] = odp[pom] & 127; //smazani nejvysiho bitu |
2497 |
.................... odp[pom] = odp[pom] & 127; //smazani nejvysiho bitu |
1291 |
044D: MOVLW 21 |
- |
|
1292 |
044E: ADDWF 49,W |
- |
|
1293 |
044F: MOVWF 50 |
- |
|
1294 |
0450: MOVLW 21 |
- |
|
1295 |
0451: ADDWF 49,W |
- |
|
1296 |
0452: MOVWF 04 |
- |
|
1297 |
0453: MOVF 00,W |
- |
|
1298 |
0454: ANDLW 7F |
- |
|
1299 |
0455: MOVWF 52 |
- |
|
1300 |
0456: MOVF 50,W |
- |
|
1301 |
0457: MOVWF 04 |
- |
|
1302 |
0458: MOVF 52,W |
- |
|
1303 |
0459: MOVWF 00 |
- |
|
1304 |
.................... odkl2 = odkl; //ulozeni odlk na dalsi pruchod |
2498 |
.................... odkl2 = odkl; //ulozeni odlk na dalsi pruchod |
1305 |
045A: MOVF 4C,W |
- |
|
1306 |
045B: MOVWF 4D |
- |
|
1307 |
.................... pom3++; //inkrementace citace rotace |
2499 |
.................... pom3++; //inkrementace citace rotace |
1308 |
045C: INCF 4B,F |
- |
|
1309 |
.................... if (pom3 == 8) //kazdy 8my znak |
2500 |
.................... if (pom3 == 8) //kazdy 8my znak |
1310 |
045D: MOVF 4B,W |
- |
|
1311 |
045E: SUBLW 08 |
- |
|
1312 |
045F: BTFSS 03.2 |
- |
|
1313 |
0460: GOTO 469 |
- |
|
1314 |
.................... { |
2501 |
.................... { |
1315 |
.................... pom3 = 0; //smaz citac |
2502 |
.................... pom3 = 0; //smaz citac |
1316 |
0461: CLRF 4B |
- |
|
1317 |
.................... odp[pom+1] = odkl2; //uloz 8my znak vznikly z "prenosu" |
2503 |
.................... odp[pom+1] = odkl2; //uloz 8my znak vznikly z "prenosu" |
1318 |
0462: MOVLW 01 |
- |
|
1319 |
0463: ADDWF 49,W |
- |
|
1320 |
0464: ADDLW 21 |
- |
|
1321 |
0465: MOVWF 04 |
- |
|
1322 |
0466: MOVF 4D,W |
- |
|
1323 |
0467: MOVWF 00 |
- |
|
1324 |
.................... maskovadlo = 0; //smaz maskovadlo |
2504 |
.................... maskovadlo = 0; //smaz maskovadlo |
1325 |
0468: CLRF 4E |
- |
|
1326 |
.................... } |
2505 |
.................... } |
1327 |
.................... } |
2506 |
.................... } |
1328 |
0469: INCF 49,F |
- |
|
1329 |
046A: GOTO 414 |
- |
|
1330 |
.................... odp[pom]='\0'; |
2507 |
.................... odp[pom]='\0'; |
1331 |
046B: MOVLW 21 |
- |
|
1332 |
046C: ADDWF 49,W |
- |
|
1333 |
046D: MOVWF 04 |
- |
|
1334 |
046E: CLRF 00 |
- |
|
1335 |
.................... |
- |
|
1336 |
.................... /*lcd_gotoxy(1,3); |
- |
|
1337 |
.................... printf(lcd_putc,"%u %u %u %u",odp[0],odp[1],odp[2],odp[3]); */ |
- |
|
1338 |
.................... lcd_init(); |
- |
|
1339 |
046F: CALL 184 |
- |
|
1340 |
.................... lcd_gotoxy(1,1); |
- |
|
1341 |
0470: MOVLW 01 |
- |
|
1342 |
0471: MOVWF 52 |
- |
|
1343 |
0472: MOVWF 53 |
- |
|
1344 |
0473: CALL 217 |
- |
|
1345 |
.................... printf(lcd_putc,"\fPrijata SMS s textem"); |
- |
|
1346 |
0474: CLRF 50 |
- |
|
1347 |
0475: MOVF 50,W |
- |
|
1348 |
0476: CALL 067 |
- |
|
1349 |
0477: IORLW 00 |
- |
|
1350 |
0478: BTFSC 03.2 |
- |
|
1351 |
0479: GOTO 47E |
- |
|
1352 |
047A: INCF 50,F |
- |
|
1353 |
047B: MOVWF 51 |
- |
|
1354 |
047C: CALL 23C |
- |
|
1355 |
047D: GOTO 475 |
- |
|
1356 |
.................... lcd_gotoxy(9,3); |
- |
|
1357 |
047E: MOVLW 09 |
- |
|
1358 |
047F: MOVWF 52 |
- |
|
1359 |
0480: MOVLW 03 |
- |
|
1360 |
0481: MOVWF 53 |
- |
|
1361 |
0482: CALL 217 |
- |
|
1362 |
.................... printf(lcd_putc,"%s",odp); |
- |
|
1363 |
0483: MOVLW 21 |
- |
|
1364 |
0484: MOVWF 04 |
- |
|
1365 |
0485: MOVLW 00 |
- |
|
1366 |
0486: IORWF 00,W |
- |
|
1367 |
0487: BTFSC 03.2 |
- |
|
1368 |
0488: GOTO 492 |
- |
|
1369 |
0489: MOVF 04,W |
- |
|
1370 |
048A: MOVWF 50 |
- |
|
1371 |
048B: MOVF 00,W |
- |
|
1372 |
048C: MOVWF 51 |
- |
|
1373 |
048D: CALL 23C |
- |
|
1374 |
048E: MOVF 50,W |
- |
|
1375 |
048F: MOVWF 04 |
- |
|
1376 |
0490: INCF 04,F |
- |
|
1377 |
0491: GOTO 485 |
- |
|
1378 |
.................... output_low(PIN_A4) ; |
- |
|
1379 |
0492: BSF 03.5 |
- |
|
1380 |
0493: BCF 05.4 |
- |
|
1381 |
0494: BCF 03.5 |
- |
|
1382 |
0495: BCF 05.4 |
- |
|
1383 |
.................... delay_ms(1000); |
- |
|
1384 |
0496: MOVLW 04 |
- |
|
1385 |
0497: MOVWF 50 |
- |
|
1386 |
0498: MOVLW FA |
- |
|
1387 |
0499: MOVWF 52 |
- |
|
1388 |
049A: CALL 126 |
- |
|
1389 |
049B: DECFSZ 50,F |
- |
|
1390 |
049C: GOTO 498 |
- |
|
1391 |
.................... output_high(PIN_A4); |
- |
|
1392 |
049D: BSF 03.5 |
- |
|
1393 |
049E: BCF 05.4 |
- |
|
1394 |
049F: BCF 03.5 |
- |
|
1395 |
04A0: BSF 05.4 |
- |
|
1396 |
.................... |
- |
|
1397 |
.................... //!!! fprintf(MOBIL,"AT+CMGD=1\r"); //smaz prijatou SMSku |
- |
|
1398 |
.................... |
2508 |
.................... } |
1399 |
.................... if (odp[0] > 64 && odp[0] < 91 ) |
- |
|
1400 |
04A1: MOVF 21,W |
- |
|
1401 |
04A2: SUBLW 40 |
- |
|
1402 |
04A3: BTFSC 03.0 |
- |
|
1403 |
04A4: GOTO 4AB |
- |
|
1404 |
04A5: MOVF 21,W |
- |
|
1405 |
04A6: SUBLW 5A |
- |
|
1406 |
04A7: BTFSS 03.0 |
- |
|
1407 |
04A8: GOTO 4AB |
- |
|
1408 |
.................... { |
- |
|
1409 |
.................... odp[0] += 32; |
- |
|
1410 |
04A9: MOVLW 20 |
- |
|
1411 |
04AA: ADDWF 21,F |
- |
|
1412 |
.................... } |
- |
|
1413 |
.................... |
2509 |
.................... |
1414 |
.................... if (odp[1] > 64 && odp[1] < 91 ) |
2510 |
.................... void read_time() |
1415 |
04AB: MOVF 22,W |
- |
|
1416 |
04AC: SUBLW 40 |
- |
|
1417 |
04AD: BTFSC 03.0 |
- |
|
1418 |
04AE: GOTO 4B5 |
- |
|
1419 |
04AF: MOVF 22,W |
- |
|
1420 |
04B0: SUBLW 5A |
- |
|
1421 |
04B1: BTFSS 03.0 |
- |
|
1422 |
04B2: GOTO 4B5 |
- |
|
1423 |
.................... { |
2511 |
.................... { |
1424 |
.................... odp[1] += 32; |
- |
|
1425 |
04B3: MOVLW 20 |
- |
|
1426 |
04B4: ADDWF 22,F |
- |
|
1427 |
.................... } |
2512 |
.................... unsigned int8 n; |
1428 |
.................... |
2513 |
.................... |
1429 |
.................... if (odp[2] > 64 && odp[2] < 91 ) |
- |
|
1430 |
04B5: MOVF 23,W |
- |
|
1431 |
04B6: SUBLW 40 |
- |
|
1432 |
04B7: BTFSC 03.0 |
- |
|
1433 |
04B8: GOTO 4BF |
- |
|
1434 |
04B9: MOVF 23,W |
- |
|
1435 |
04BA: SUBLW 5A |
- |
|
1436 |
04BB: BTFSS 03.0 |
- |
|
1437 |
04BC: GOTO 4BF |
- |
|
1438 |
.................... { |
- |
|
1439 |
.................... odp[2] += 32; |
- |
|
1440 |
04BD: MOVLW 20 |
- |
|
1441 |
04BE: ADDWF 23,F |
- |
|
1442 |
.................... } |
- |
|
1443 |
.................... |
2514 |
.................... |
- |
|
2515 |
.................... fprintf(MOBIL,"AT+CCLK?\r"); |
- |
|
2516 |
.................... while(fgetc(MOBIL)!='"'); |
- |
|
2517 |
.................... for(n=0;n<12;n++) //preskoc nedulezite informace |
- |
|
2518 |
.................... { |
1444 |
.................... if (odp[3] > 64 && odp[3] < 91 ) |
2519 |
.................... fgetc(MOBIL); |
- |
|
2520 |
.................... } |
- |
|
2521 |
.................... odp[0]=fgetc(MOBIL); |
- |
|
2522 |
.................... odp[1]=fgetc(MOBIL); |
- |
|
2523 |
.................... odp[2]=0; |
- |
|
2524 |
.................... } |
- |
|
2525 |
.................... |
- |
|
2526 |
.................... void del_sms() |
- |
|
2527 |
.................... { |
- |
|
2528 |
.................... fprintf(MOBIL,"AT+CMGD=1\r"); //smaz prijatou SMSku |
- |
|
2529 |
.................... } |
- |
|
2530 |
.................... |
- |
|
2531 |
.................... void main() |
- |
|
2532 |
.................... { |
- |
|
2533 |
* |
- |
|
2534 |
0057: CLRF 04 |
- |
|
2535 |
0058: MOVLW 1F |
- |
|
2536 |
0059: ANDWF 03,F |
- |
|
2537 |
005A: BCF 20.6 |
- |
|
2538 |
005B: MOVF 20,W |
- |
|
2539 |
005C: BSF 03.5 |
- |
|
2540 |
005D: MOVWF 07 |
- |
|
2541 |
005E: BCF 03.5 |
- |
|
2542 |
005F: BSF 07.6 |
- |
|
2543 |
0060: BSF 03.5 |
- |
|
2544 |
0061: BCF 06.2 |
- |
|
2545 |
0062: BCF 03.5 |
- |
|
2546 |
0063: BSF 06.2 |
- |
|
2547 |
0064: BSF 03.5 |
- |
|
2548 |
0065: BSF 1F.0 |
- |
|
2549 |
0066: BSF 1F.1 |
- |
|
2550 |
0067: BSF 1F.2 |
- |
|
2551 |
0068: BCF 1F.3 |
- |
|
2552 |
0069: MOVLW 07 |
- |
|
2553 |
006A: MOVWF 1C |
- |
|
2554 |
.................... setup_adc_ports(NO_ANALOGS); |
- |
|
2555 |
* |
- |
|
2556 |
0074: BSF 03.5 |
- |
|
2557 |
0075: BSF 1F.0 |
- |
|
2558 |
0076: BSF 1F.1 |
- |
|
2559 |
0077: BSF 1F.2 |
- |
|
2560 |
0078: BCF 1F.3 |
- |
|
2561 |
.................... setup_adc(ADC_OFF); |
- |
|
2562 |
0079: BCF 03.5 |
- |
|
2563 |
007A: BCF 1F.0 |
- |
|
2564 |
.................... setup_spi(SPI_SS_DISABLED); |
- |
|
2565 |
007B: BCF 14.5 |
- |
|
2566 |
007C: BCF 20.5 |
- |
|
2567 |
007D: MOVF 20,W |
- |
|
2568 |
007E: BSF 03.5 |
- |
|
2569 |
007F: MOVWF 07 |
- |
|
2570 |
0080: BCF 03.5 |
- |
|
2571 |
0081: BSF 20.4 |
- |
|
2572 |
0082: MOVF 20,W |
- |
|
2573 |
0083: BSF 03.5 |
- |
|
2574 |
0084: MOVWF 07 |
- |
|
2575 |
0085: BCF 03.5 |
- |
|
2576 |
0086: BCF 20.3 |
- |
|
2577 |
0087: MOVF 20,W |
- |
|
2578 |
0088: BSF 03.5 |
- |
|
2579 |
0089: MOVWF 07 |
- |
|
2580 |
008A: MOVLW 01 |
- |
|
2581 |
008B: BCF 03.5 |
- |
|
2582 |
008C: MOVWF 14 |
- |
|
2583 |
008D: MOVLW 00 |
- |
|
2584 |
008E: BSF 03.5 |
- |
|
2585 |
008F: MOVWF 14 |
- |
|
2586 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
- |
|
2587 |
0090: MOVF 01,W |
- |
|
2588 |
0091: ANDLW C7 |
- |
|
2589 |
0092: IORLW 08 |
- |
|
2590 |
0093: MOVWF 01 |
- |
|
2591 |
.................... setup_timer_1(T1_DISABLED); |
- |
|
2592 |
0094: BCF 03.5 |
- |
|
2593 |
0095: CLRF 10 |
- |
|
2594 |
.................... setup_timer_2(T2_DIV_BY_4,255,1); |
- |
|
2595 |
0096: MOVLW 00 |
- |
|
2596 |
0097: MOVWF 78 |
- |
|
2597 |
0098: IORLW 05 |
- |
|
2598 |
0099: MOVWF 12 |
- |
|
2599 |
009A: MOVLW FF |
- |
|
2600 |
009B: BSF 03.5 |
- |
|
2601 |
009C: MOVWF 12 |
- |
|
2602 |
.................... setup_ccp1(CCP_PWM); |
- |
|
2603 |
009D: BCF 03.5 |
- |
|
2604 |
009E: BCF 20.2 |
1445 |
04BF: MOVF 24,W |
2605 |
009F: MOVF 20,W |
- |
|
2606 |
00A0: BSF 03.5 |
- |
|
2607 |
00A1: MOVWF 07 |
- |
|
2608 |
00A2: BCF 03.5 |
- |
|
2609 |
00A3: BCF 07.2 |
- |
|
2610 |
00A4: MOVLW 0C |
- |
|
2611 |
00A5: MOVWF 17 |
- |
|
2612 |
.................... setup_ccp2(CCP_PWM); |
- |
|
2613 |
00A6: BCF 20.1 |
- |
|
2614 |
00A7: MOVF 20,W |
- |
|
2615 |
00A8: BSF 03.5 |
- |
|
2616 |
00A9: MOVWF 07 |
- |
|
2617 |
00AA: BCF 03.5 |
- |
|
2618 |
00AB: BCF 07.1 |
- |
|
2619 |
00AC: MOVLW 0C |
- |
|
2620 |
00AD: MOVWF 1D |
- |
|
2621 |
.................... setup_comparator(NC_NC_NC_NC); |
- |
|
2622 |
00AE: MOVLW 07 |
- |
|
2623 |
00AF: BSF 03.5 |
- |
|
2624 |
00B0: MOVWF 1C |
- |
|
2625 |
00B1: MOVF 05,W |
- |
|
2626 |
00B2: CLRWDT |
- |
|
2627 |
00B3: MOVLW 0E |
- |
|
2628 |
00B4: MOVWF 77 |
- |
|
2629 |
00B5: DECFSZ 77,F |
- |
|
2630 |
00B6: GOTO 0B5 |
- |
|
2631 |
00B7: NOP |
- |
|
2632 |
00B8: NOP |
- |
|
2633 |
00B9: MOVF 1C,W |
- |
|
2634 |
00BA: BCF 03.5 |
- |
|
2635 |
00BB: BCF 0D.6 |
- |
|
2636 |
.................... setup_vref(FALSE); |
- |
|
2637 |
00BC: BSF 03.5 |
- |
|
2638 |
00BD: CLRF 1D |
- |
|
2639 |
.................... setup_wdt(WDT_2304MS); |
- |
|
2640 |
00BE: MOVLW 0F |
- |
|
2641 |
00BF: MOVWF 77 |
1446 |
04C0: SUBLW 40 |
2642 |
00C0: MOVLW 07 |
1447 |
04C1: BTFSC 03.0 |
2643 |
00C1: BCF 03.5 |
1448 |
04C2: GOTO 4C9 |
2644 |
00C2: CLRF 01 |
- |
|
2645 |
00C3: MOVLW 81 |
- |
|
2646 |
00C4: MOVWF 04 |
- |
|
2647 |
00C5: MOVF 00,W |
- |
|
2648 |
00C6: ANDLW F0 |
- |
|
2649 |
00C7: IORLW 07 |
- |
|
2650 |
00C8: MOVWF 00 |
- |
|
2651 |
00C9: CLRWDT |
1449 |
04C3: MOVF 24,W |
2652 |
00CA: MOVF 00,W |
- |
|
2653 |
00CB: ANDLW F7 |
- |
|
2654 |
00CC: BTFSC 77.3 |
- |
|
2655 |
00CD: ANDLW F0 |
- |
|
2656 |
00CE: IORWF 77,W |
- |
|
2657 |
00CF: MOVWF 00 |
- |
|
2658 |
.................... |
- |
|
2659 |
.................... set_pwm1_duty(0); |
- |
|
2660 |
00D0: CLRF 15 |
- |
|
2661 |
.................... set_pwm2_duty(0); |
- |
|
2662 |
00D1: CLRF 1B |
- |
|
2663 |
.................... |
- |
|
2664 |
.................... while(TRUE) |
- |
|
2665 |
.................... { |
- |
|
2666 |
.................... int status; |
- |
|
2667 |
.................... char *ptr; |
- |
|
2668 |
.................... int time; |
- |
|
2669 |
.................... |
- |
|
2670 |
.................... restart_wdt(); |
- |
|
2671 |
00D2: CLRWDT |
- |
|
2672 |
.................... |
- |
|
2673 |
.................... output_low(PIN_A4) ; |
- |
|
2674 |
00D3: BSF 03.5 |
- |
|
2675 |
00D4: BCF 05.4 |
- |
|
2676 |
00D5: BCF 03.5 |
- |
|
2677 |
00D6: BCF 05.4 |
- |
|
2678 |
.................... delay_ms(150); |
- |
|
2679 |
00D7: MOVLW 96 |
- |
|
2680 |
00D8: MOVWF 52 |
- |
|
2681 |
00D9: CALL 013 |
- |
|
2682 |
.................... output_high(PIN_A4); |
- |
|
2683 |
00DA: BSF 03.5 |
- |
|
2684 |
00DB: BCF 05.4 |
- |
|
2685 |
00DC: BCF 03.5 |
- |
|
2686 |
00DD: BSF 05.4 |
- |
|
2687 |
.................... delay_ms(150); |
- |
|
2688 |
00DE: MOVLW 96 |
- |
|
2689 |
00DF: MOVWF 52 |
- |
|
2690 |
00E0: CALL 013 |
- |
|
2691 |
.................... output_low(PIN_A4) ; |
- |
|
2692 |
00E1: BSF 03.5 |
- |
|
2693 |
00E2: BCF 05.4 |
- |
|
2694 |
00E3: BCF 03.5 |
- |
|
2695 |
00E4: BCF 05.4 |
- |
|
2696 |
.................... delay_ms(150); |
- |
|
2697 |
00E5: MOVLW 96 |
- |
|
2698 |
00E6: MOVWF 52 |
- |
|
2699 |
00E7: CALL 013 |
- |
|
2700 |
.................... output_high(PIN_A4); |
- |
|
2701 |
00E8: BSF 03.5 |
- |
|
2702 |
00E9: BCF 05.4 |
- |
|
2703 |
00EA: BCF 03.5 |
- |
|
2704 |
00EB: BSF 05.4 |
- |
|
2705 |
.................... delay_ms(150); |
- |
|
2706 |
00EC: MOVLW 96 |
- |
|
2707 |
00ED: MOVWF 52 |
- |
|
2708 |
00EE: CALL 013 |
- |
|
2709 |
.................... |
- |
|
2710 |
.................... |
- |
|
2711 |
.................... set_pwm1_duty(500); |
- |
|
2712 |
00EF: MOVLW 7D |
- |
|
2713 |
00F0: MOVWF 15 |
- |
|
2714 |
00F1: MOVF 17,W |
- |
|
2715 |
00F2: ANDLW CF |
- |
|
2716 |
00F3: MOVWF 17 |
- |
|
2717 |
.................... set_pwm2_duty(500); |
1450 |
04C4: SUBLW 5A |
2718 |
00F4: MOVLW 7D |
- |
|
2719 |
00F5: MOVWF 1B |
- |
|
2720 |
00F6: MOVF 1D,W |
- |
|
2721 |
00F7: ANDLW CF |
- |
|
2722 |
00F8: MOVWF 1D |
- |
|
2723 |
.................... |
- |
|
2724 |
.................... fprintf(VRTULE,"ABABABABAB"); |
- |
|
2725 |
00F9: CLRF 51 |
- |
|
2726 |
00FA: MOVF 51,W |
- |
|
2727 |
00FB: CALL 004 |
- |
|
2728 |
00FC: IORLW 00 |
1451 |
04C5: BTFSS 03.0 |
2729 |
00FD: BTFSC 03.2 |
- |
|
2730 |
00FE: GOTO 103 |
- |
|
2731 |
00FF: INCF 51,F |
- |
|
2732 |
0100: MOVWF 52 |
1452 |
04C6: GOTO 4C9 |
2733 |
0101: GOTO 029 |
- |
|
2734 |
0102: GOTO 0FA |
1453 |
.................... { |
2735 |
.................... |
1454 |
.................... odp[3] += 32; |
2736 |
.................... Delay_ms(5000); |
- |
|
2737 |
0103: MOVLW 14 |
- |
|
2738 |
0104: MOVWF 51 |
1455 |
04C7: MOVLW 20 |
2739 |
0105: MOVLW FA |
- |
|
2740 |
0106: MOVWF 52 |
- |
|
2741 |
0107: CALL 013 |
1456 |
04C8: ADDWF 24,F |
2742 |
0108: DECFSZ 51,F |
- |
|
2743 |
0109: GOTO 105 |
1457 |
.................... } |
2744 |
.................... |
1458 |
.................... |
2745 |
.................... |
1459 |
.................... lcd_gotoxy(1,1); |
- |
|
1460 |
04C9: MOVLW 01 |
- |
|
1461 |
04CA: MOVWF 52 |
- |
|
1462 |
04CB: MOVWF 53 |
- |
|
1463 |
04CC: CALL 217 |
- |
|
1464 |
.................... printf(lcd_putc,"\f Odstraneni velkych"); |
- |
|
1465 |
04CD: CLRF 50 |
- |
|
1466 |
04CE: MOVF 50,W |
- |
|
1467 |
04CF: CALL 081 |
- |
|
1468 |
04D0: IORLW 00 |
- |
|
1469 |
04D1: BTFSC 03.2 |
- |
|
1470 |
04D2: GOTO 4D7 |
- |
|
1471 |
04D3: INCF 50,F |
- |
|
1472 |
04D4: MOVWF 51 |
- |
|
1473 |
04D5: CALL 23C |
- |
|
1474 |
04D6: GOTO 4CE |
- |
|
1475 |
.................... lcd_gotoxy(1,2); |
- |
|
1476 |
04D7: MOVLW 01 |
- |
|
1477 |
04D8: MOVWF 52 |
- |
|
1478 |
04D9: MOVLW 02 |
- |
|
1479 |
04DA: MOVWF 53 |
- |
|
1480 |
04DB: CALL 217 |
- |
|
1481 |
.................... printf(lcd_putc," pismen"); |
2746 |
.................... /* if(check_new_sms()) // Je odpoved "OK"? |
1482 |
04DC: CLRF 50 |
- |
|
1483 |
04DD: MOVF 50,W |
- |
|
1484 |
04DE: CALL 09A |
- |
|
1485 |
04DF: IORLW 00 |
- |
|
1486 |
04E0: BTFSC 03.2 |
- |
|
1487 |
04E1: GOTO 4E6 |
- |
|
1488 |
04E2: INCF 50,F |
- |
|
1489 |
04E3: MOVWF 51 |
- |
|
1490 |
04E4: CALL 23C |
- |
|
1491 |
04E5: GOTO 4DD |
- |
|
1492 |
.................... lcd_gotoxy(9,4); |
2747 |
.................... { |
1493 |
04E6: MOVLW 09 |
- |
|
1494 |
04E7: MOVWF 52 |
- |
|
1495 |
04E8: MOVLW 04 |
- |
|
1496 |
04E9: MOVWF 53 |
- |
|
1497 |
04EA: CALL 217 |
- |
|
1498 |
.................... printf(lcd_putc,"%s",odp); |
2748 |
.................... // printf(lcd_putc,"736 655 250"); |
1499 |
04EB: MOVLW 21 |
- |
|
1500 |
04EC: MOVWF 04 |
- |
|
1501 |
04ED: MOVLW 00 |
- |
|
1502 |
04EE: IORWF 00,W |
- |
|
1503 |
04EF: BTFSC 03.2 |
- |
|
1504 |
04F0: GOTO 4FA |
- |
|
1505 |
04F1: MOVF 04,W |
- |
|
1506 |
04F2: MOVWF 50 |
- |
|
1507 |
04F3: MOVF 00,W |
- |
|
1508 |
04F4: MOVWF 51 |
- |
|
1509 |
04F5: CALL 23C |
- |
|
1510 |
04F6: MOVF 50,W |
- |
|
1511 |
04F7: MOVWF 04 |
- |
|
1512 |
04F8: INCF 04,F |
- |
|
1513 |
04F9: GOTO 4ED |
- |
|
1514 |
.................... output_low(PIN_A4) ; |
- |
|
1515 |
04FA: BSF 03.5 |
- |
|
1516 |
04FB: BCF 05.4 |
- |
|
1517 |
04FC: BCF 03.5 |
- |
|
1518 |
04FD: BCF 05.4 |
- |
|
1519 |
.................... delay_ms(1000); |
2749 |
.................... delay_ms(1000); |
1520 |
04FE: MOVLW 04 |
- |
|
1521 |
04FF: MOVWF 50 |
- |
|
1522 |
0500: MOVLW FA |
- |
|
1523 |
0501: MOVWF 52 |
- |
|
1524 |
0502: CALL 126 |
- |
|
1525 |
0503: DECFSZ 50,F |
- |
|
1526 |
0504: GOTO 500 |
- |
|
1527 |
.................... output_high(PIN_A4); |
- |
|
1528 |
0505: BSF 03.5 |
- |
|
1529 |
0506: BCF 05.4 |
- |
|
1530 |
0507: BCF 03.5 |
- |
|
1531 |
0508: BSF 05.4 |
- |
|
1532 |
.................... |
2750 |
.................... } |
1533 |
.................... |
- |
|
1534 |
.................... //!!!KAKL |
- |
|
1535 |
.................... fprintf(VRTULE,"%s",odp); |
- |
|
1536 |
0509: MOVLW 21 |
- |
|
1537 |
050A: MOVWF 04 |
- |
|
1538 |
050B: MOVLW 00 |
- |
|
1539 |
050C: IORWF 00,W |
- |
|
1540 |
050D: BTFSC 03.2 |
- |
|
1541 |
050E: GOTO 518 |
- |
|
1542 |
050F: MOVF 04,W |
- |
|
1543 |
0510: MOVWF 50 |
- |
|
1544 |
0511: MOVF 00,W |
- |
|
1545 |
0512: MOVWF 51 |
- |
|
1546 |
0513: GOTO 26F |
- |
|
1547 |
0514: MOVF 50,W |
- |
|
1548 |
0515: MOVWF 04 |
- |
|
1549 |
0516: INCF 04,F |
- |
|
1550 |
0517: GOTO 50B |
- |
|
1551 |
.................... |
2751 |
.................... else |
1552 |
.................... |
2752 |
.................... { |
1553 |
.................... if (odp[0] == 122 && odp[1] == 97 && odp[2] == 112 && odp[3] == 49) //odp=="zap1" |
- |
|
1554 |
0518: MOVF 21,W |
- |
|
1555 |
0519: SUBLW 7A |
- |
|
1556 |
051A: BTFSS 03.2 |
- |
|
1557 |
051B: GOTO 52A |
- |
|
1558 |
051C: MOVF 22,W |
- |
|
1559 |
051D: SUBLW 61 |
- |
|
1560 |
051E: BTFSS 03.2 |
- |
|
1561 |
051F: GOTO 52A |
- |
|
1562 |
0520: MOVF 23,W |
- |
|
1563 |
0521: SUBLW 70 |
- |
|
1564 |
0522: BTFSS 03.2 |
- |
|
1565 |
0523: GOTO 52A |
- |
|
1566 |
0524: MOVF 24,W |
- |
|
1567 |
0525: SUBLW 31 |
- |
|
1568 |
0526: BTFSS 03.2 |
- |
|
1569 |
0527: GOTO 52A |
- |
|
1570 |
.................... { |
- |
|
1571 |
.................... status=1; |
2753 |
.................... read_sms(); |
1572 |
0528: MOVLW 01 |
- |
|
1573 |
0529: MOVWF 4F |
- |
|
1574 |
.................... } |
- |
|
1575 |
.................... |
2754 |
.................... |
1576 |
.................... if (odp[0] == 118 && odp[1] == 121 && odp[2] == 112 && odp[3]== 49) //odp=="vyp1" |
2755 |
.................... if (odp[0] == 'A' || odp[0] == 'a') |
1577 |
052A: MOVF 21,W |
2756 |
.................... { |
1578 |
052B: SUBLW 76 |
- |
|
1579 |
052C: BTFSS 03.2 |
- |
|
1580 |
052D: GOTO 53C |
2757 |
.................... set_pwm1_duty(500); |
1581 |
052E: MOVF 22,W |
2758 |
.................... set_pwm2_duty(500); |
1582 |
052F: SUBLW 79 |
- |
|
1583 |
0530: BTFSS 03.2 |
2759 |
.................... Delay_ms(5000); |
1584 |
0531: GOTO 53C |
2760 |
.................... fprintf(VRTULE,"ABABABABAB"); |
1585 |
0532: MOVF 23,W |
2761 |
.................... Delay_ms(20000); |
1586 |
0533: SUBLW 70 |
- |
|
1587 |
0534: BTFSS 03.2 |
2762 |
.................... set_pwm1_duty(0); |
1588 |
0535: GOTO 53C |
2763 |
.................... set_pwm2_duty(0); |
1589 |
0536: MOVF 24,W |
2764 |
.................... } |
1590 |
0537: SUBLW 31 |
- |
|
1591 |
0538: BTFSS 03.2 |
2765 |
.................... |
1592 |
0539: GOTO 53C |
2766 |
.................... if (odp[0] == 118 && odp[1] == 121 && odp[2] == 112 && odp[3]== 49) |
1593 |
.................... { |
2767 |
.................... { |
1594 |
.................... status=2; |
2768 |
.................... fprintf(VRTULE,""); |
1595 |
053A: MOVLW 02 |
- |
|
1596 |
053B: MOVWF 4F |
- |
|
1597 |
.................... } |
2769 |
.................... } |
1598 |
.................... |
2770 |
.................... |
1599 |
.................... if (odp[0] == 97 && odp[1] == 104 && odp[2] == 111 && odp[3]== 106) //odp=="ahoj" |
2771 |
.................... if (odp[0] == 97 && odp[1] == 104 && odp[2] == 111 && odp[3]== 106) |
1600 |
053C: MOVF 21,W |
- |
|
1601 |
053D: SUBLW 61 |
- |
|
1602 |
053E: BTFSS 03.2 |
- |
|
1603 |
053F: GOTO 54E |
- |
|
1604 |
0540: MOVF 22,W |
- |
|
1605 |
0541: SUBLW 68 |
- |
|
1606 |
0542: BTFSS 03.2 |
- |
|
1607 |
0543: GOTO 54E |
- |
|
1608 |
0544: MOVF 23,W |
- |
|
1609 |
0545: SUBLW 6F |
- |
|
1610 |
0546: BTFSS 03.2 |
- |
|
1611 |
0547: GOTO 54E |
- |
|
1612 |
0548: MOVF 24,W |
- |
|
1613 |
0549: SUBLW 6A |
- |
|
1614 |
054A: BTFSS 03.2 |
- |
|
1615 |
054B: GOTO 54E |
- |
|
1616 |
.................... { |
2772 |
.................... { |
1617 |
.................... status=3; |
2773 |
.................... fprintf(VRTULE,""); |
1618 |
054C: MOVLW 03 |
- |
|
1619 |
054D: MOVWF 4F |
- |
|
1620 |
.................... } |
2774 |
.................... } |
1621 |
.................... |
2775 |
.................... } |
1622 |
.................... switch (status) |
2776 |
.................... /* read_time(); |
- |
|
2777 |
.................... time=strtoul(odp,&ptr,10); |
- |
|
2778 |
.................... if((time >= 30 && time <= 35) || (time >= 0 && time <= 5)) |
1623 |
.................... { |
2779 |
.................... { |
1624 |
054E: MOVF 4F,W |
- |
|
1625 |
054F: XORLW 01 |
- |
|
1626 |
0550: BTFSC 03.2 |
- |
|
1627 |
0551: GOTO 559 |
- |
|
1628 |
0552: XORLW 03 |
- |
|
1629 |
0553: BTFSC 03.2 |
- |
|
1630 |
0554: GOTO 577 |
- |
|
1631 |
0555: XORLW 01 |
- |
|
1632 |
0556: BTFSC 03.2 |
- |
|
1633 |
0557: GOTO 595 |
- |
|
1634 |
0558: GOTO 5AF |
- |
|
1635 |
.................... |
- |
|
1636 |
.................... case 1: output_low(zar1); |
- |
|
1637 |
0559: BSF 03.5 |
- |
|
1638 |
055A: BCF 05.3 |
- |
|
1639 |
055B: BCF 03.5 |
- |
|
1640 |
055C: BCF 05.3 |
- |
|
1641 |
.................... printf(lcd_putc,"\f"); |
- |
|
1642 |
055D: CLRF 50 |
- |
|
1643 |
055E: MOVF 50,W |
- |
|
1644 |
055F: CALL 0AC |
- |
|
1645 |
0560: IORLW 00 |
- |
|
1646 |
0561: BTFSC 03.2 |
- |
|
1647 |
0562: GOTO 567 |
- |
|
1648 |
0563: INCF 50,F |
- |
|
1649 |
0564: MOVWF 51 |
- |
|
1650 |
0565: CALL 23C |
- |
|
1651 |
0566: GOTO 55E |
- |
|
1652 |
.................... lcd_gotoxy(1,2); |
- |
|
1653 |
0567: MOVLW 01 |
- |
|
1654 |
0568: MOVWF 52 |
- |
|
1655 |
0569: MOVLW 02 |
- |
|
1656 |
056A: MOVWF 53 |
- |
|
1657 |
056B: CALL 217 |
- |
|
1658 |
.................... printf(lcd_putc," Zapnuto zarizeni 1"); |
- |
|
1659 |
056C: CLRF 50 |
- |
|
1660 |
056D: MOVF 50,W |
- |
|
1661 |
056E: CALL 0B2 |
- |
|
1662 |
056F: IORLW 00 |
- |
|
1663 |
0570: BTFSC 03.2 |
- |
|
1664 |
0571: GOTO 576 |
- |
|
1665 |
0572: INCF 50,F |
- |
|
1666 |
0573: MOVWF 51 |
- |
|
1667 |
0574: CALL 23C |
- |
|
1668 |
0575: GOTO 56D |
- |
|
1669 |
.................... break; |
- |
|
1670 |
0576: GOTO 5D8 |
- |
|
1671 |
.................... |
- |
|
1672 |
.................... case 2: output_high(zar1); |
- |
|
1673 |
0577: BSF 03.5 |
- |
|
1674 |
0578: BCF 05.3 |
- |
|
1675 |
0579: BCF 03.5 |
- |
|
1676 |
057A: BSF 05.3 |
- |
|
1677 |
.................... printf(lcd_putc,"\f"); |
- |
|
1678 |
057B: CLRF 50 |
- |
|
1679 |
057C: MOVF 50,W |
- |
|
1680 |
057D: CALL 0AC |
- |
|
1681 |
057E: IORLW 00 |
- |
|
1682 |
057F: BTFSC 03.2 |
- |
|
1683 |
0580: GOTO 585 |
- |
|
1684 |
0581: INCF 50,F |
- |
|
1685 |
0582: MOVWF 51 |
- |
|
1686 |
0583: CALL 23C |
- |
|
1687 |
0584: GOTO 57C |
- |
|
1688 |
.................... lcd_gotoxy(1,2); |
- |
|
1689 |
0585: MOVLW 01 |
- |
|
1690 |
0586: MOVWF 52 |
- |
|
1691 |
0587: MOVLW 02 |
- |
|
1692 |
0588: MOVWF 53 |
- |
|
1693 |
0589: CALL 217 |
- |
|
1694 |
.................... printf(lcd_putc," Vypnuto zarizeni 1"); |
- |
|
1695 |
058A: CLRF 50 |
- |
|
1696 |
058B: MOVF 50,W |
- |
|
1697 |
058C: CALL 0CA |
- |
|
1698 |
058D: IORLW 00 |
- |
|
1699 |
058E: BTFSC 03.2 |
- |
|
1700 |
058F: GOTO 594 |
- |
|
1701 |
0590: INCF 50,F |
- |
|
1702 |
0591: MOVWF 51 |
- |
|
1703 |
0592: CALL 23C |
- |
|
1704 |
0593: GOTO 58B |
- |
|
1705 |
.................... break; |
2780 |
.................... set_pwm1_duty(500); |
1706 |
0594: GOTO 5D8 |
- |
|
1707 |
.................... |
- |
|
1708 |
.................... case 3: printf(lcd_putc,"\f"); |
- |
|
1709 |
0595: CLRF 50 |
- |
|
1710 |
0596: MOVF 50,W |
- |
|
1711 |
0597: CALL 0AC |
- |
|
1712 |
0598: IORLW 00 |
- |
|
1713 |
0599: BTFSC 03.2 |
- |
|
1714 |
059A: GOTO 59F |
- |
|
1715 |
059B: INCF 50,F |
- |
|
1716 |
059C: MOVWF 51 |
- |
|
1717 |
059D: CALL 23C |
- |
|
1718 |
059E: GOTO 596 |
- |
|
1719 |
.................... lcd_gotoxy(1,2); |
- |
|
1720 |
059F: MOVLW 01 |
- |
|
1721 |
05A0: MOVWF 52 |
- |
|
1722 |
05A1: MOVLW 02 |
- |
|
1723 |
05A2: MOVWF 53 |
- |
|
1724 |
05A3: CALL 217 |
- |
|
1725 |
.................... printf(lcd_putc," Preji hezky den!"); |
- |
|
1726 |
05A4: CLRF 50 |
- |
|
1727 |
05A5: MOVF 50,W |
- |
|
1728 |
05A6: CALL 0E2 |
- |
|
1729 |
05A7: IORLW 00 |
- |
|
1730 |
05A8: BTFSC 03.2 |
- |
|
1731 |
05A9: GOTO 5AE |
- |
|
1732 |
05AA: INCF 50,F |
- |
|
1733 |
05AB: MOVWF 51 |
- |
|
1734 |
05AC: CALL 23C |
- |
|
1735 |
05AD: GOTO 5A5 |
- |
|
1736 |
.................... break; |
2781 |
.................... set_pwm2_duty(500); |
1737 |
05AE: GOTO 5D8 |
- |
|
1738 |
.................... |
- |
|
1739 |
.................... default: printf(lcd_putc,"\f"); |
- |
|
1740 |
05AF: CLRF 50 |
- |
|
1741 |
05B0: MOVF 50,W |
- |
|
1742 |
05B1: CALL 0AC |
- |
|
1743 |
05B2: IORLW 00 |
- |
|
1744 |
05B3: BTFSC 03.2 |
- |
|
1745 |
05B4: GOTO 5B9 |
- |
|
1746 |
05B5: INCF 50,F |
- |
|
1747 |
05B6: MOVWF 51 |
- |
|
1748 |
05B7: CALL 23C |
- |
|
1749 |
05B8: GOTO 5B0 |
- |
|
1750 |
.................... lcd_gotoxy(1,2); |
- |
|
1751 |
05B9: MOVLW 01 |
- |
|
1752 |
05BA: MOVWF 52 |
- |
|
1753 |
05BB: MOVLW 02 |
- |
|
1754 |
05BC: MOVWF 53 |
- |
|
1755 |
05BD: CALL 217 |
- |
|
1756 |
.................... printf(lcd_putc," Prikaz nebyl"); |
- |
|
1757 |
05BE: CLRF 50 |
- |
|
1758 |
05BF: MOVF 50,W |
- |
|
1759 |
05C0: CALL 0F9 |
- |
|
1760 |
05C1: IORLW 00 |
- |
|
1761 |
05C2: BTFSC 03.2 |
- |
|
1762 |
05C3: GOTO 5C8 |
- |
|
1763 |
05C4: INCF 50,F |
- |
|
1764 |
05C5: MOVWF 51 |
- |
|
1765 |
05C6: CALL 23C |
- |
|
1766 |
05C7: GOTO 5BF |
- |
|
1767 |
.................... lcd_gotoxy(1,3); |
- |
|
1768 |
05C8: MOVLW 01 |
- |
|
1769 |
05C9: MOVWF 52 |
- |
|
1770 |
05CA: MOVLW 03 |
- |
|
1771 |
05CB: MOVWF 53 |
- |
|
1772 |
05CC: CALL 217 |
- |
|
1773 |
.................... printf(lcd_putc," rozeznan"); |
- |
|
1774 |
05CD: CLRF 50 |
- |
|
1775 |
05CE: MOVF 50,W |
- |
|
1776 |
05CF: CALL 113 |
- |
|
1777 |
05D0: IORLW 00 |
- |
|
1778 |
05D1: BTFSC 03.2 |
- |
|
1779 |
05D2: GOTO 5D7 |
- |
|
1780 |
05D3: INCF 50,F |
- |
|
1781 |
05D4: MOVWF 51 |
- |
|
1782 |
05D5: CALL 23C |
- |
|
1783 |
05D6: GOTO 5CE |
- |
|
1784 |
.................... break; |
- |
|
1785 |
05D7: GOTO 5D8 |
- |
|
1786 |
.................... } |
2782 |
.................... } |
1787 |
.................... delay_ms(1000); |
2783 |
.................... else |
1788 |
05D8: MOVLW 04 |
- |
|
1789 |
05D9: MOVWF 50 |
- |
|
1790 |
05DA: MOVLW FA |
- |
|
1791 |
05DB: MOVWF 52 |
- |
|
1792 |
05DC: CALL 126 |
2784 |
.................... { |
1793 |
05DD: DECFSZ 50,F |
2785 |
.................... set_pwm1_duty(0); |
1794 |
05DE: GOTO 5DA |
2786 |
.................... set_pwm2_duty(0); |
1795 |
.................... } |
2787 |
.................... }*/ |
1796 |
.................... |
2788 |
.................... |
- |
|
2789 |
.................... delay_ms(1000); |
- |
|
2790 |
010A: MOVLW 04 |
- |
|
2791 |
010B: MOVWF 51 |
- |
|
2792 |
010C: MOVLW FA |
- |
|
2793 |
010D: MOVWF 52 |
- |
|
2794 |
010E: CALL 013 |
- |
|
2795 |
010F: DECFSZ 51,F |
- |
|
2796 |
0110: GOTO 10C |
1797 |
.................... } |
2797 |
.................... } |
1798 |
05DF: GOTO 2FE |
2798 |
0111: GOTO 0D2 |
1799 |
.................... } |
2799 |
.................... } |
1800 |
05E0: SLEEP |
2800 |
0112: SLEEP |
1801 |
|
2801 |
|
1802 |
Configuration Fuses: |
2802 |
Configuration Fuses: |
1803 |
Word 1: 3F3A HS NOWDT NOPUT NODEBUG NOPROTECT NOBROWNOUT NOLVP NOCPD NOWRT |
2803 |
Word 1: 3F3A HS NOWDT NOPUT NODEBUG NOPROTECT NOBROWNOUT NOLVP NOCPD NOWRT |