Rev Author Line No. Line
247 kaklik 1 CCS PCM C Compiler, Version 3.245, 27853 12-V-08 00:50
223 kapl 2  
239 kaklik 3 Filename: D:\MLAB_E\projekty\Ovladani_mobilnim_telefonem\SW\final\main.lst
223 kapl 4  
246 kaklik 5 ROM used: 2699 words (33%)
238 kaklik 6 Largest free fragment is 2048
240 kaklik 7 RAM used: 52 (30%) at main() level
245 kaklik 8 139 (79%) worst case
9 Stack: 2 locations
223 kapl 10  
11 *
246 kaklik 12 0000: MOVLW 08
223 kapl 13 0001: MOVWF 0A
246 kaklik 14 0002: GOTO 000
223 kapl 15 0003: NOP
16 .................... #include ".\main.h"
238 kaklik 17 .................... #include <16F876A.h>
18 .................... //////// Standard Header file for the PIC16F876A device ////////////////
19 .................... #device PIC16F876A
223 kapl 20 .................... #list
21 ....................
22 .................... #device adc=8
23 ....................
246 kaklik 24 .................... #FUSES WDT //Watch Dog Timer
238 kaklik 25 .................... #FUSES HS//XT //Crystal osc <= 4mhz
223 kapl 26 .................... #FUSES NOPUT //No Power Up Timer
27 .................... #FUSES NOPROTECT //Code not protected from reading
28 .................... #FUSES NODEBUG //No Debug mode for ICD
29 .................... #FUSES NOBROWNOUT //No brownout reset
30 .................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
31 .................... #FUSES NOCPD //No EE protection
32 .................... #FUSES NOWRT //Program memory not write protected
33 ....................
238 kaklik 34 .................... #use delay(clock=18432000,RESTART_WDT)
245 kaklik 35 *
246 kaklik 36 01C8: MOVLW 52
37 01C9: MOVWF 04
38 01CA: MOVF 00,W
39 01CB: BTFSC 03.2
40 01CC: GOTO 1DD
41 01CD: MOVLW 05
42 01CE: MOVWF 78
43 01CF: MOVLW BF
44 01D0: MOVWF 77
45 01D1: CLRWDT
46 01D2: DECFSZ 77,F
47 01D3: GOTO 1D1
48 01D4: DECFSZ 78,F
49 01D5: GOTO 1CF
50 01D6: MOVLW F9
51 01D7: MOVWF 77
52 01D8: DECFSZ 77,F
53 01D9: GOTO 1D8
54 01DA: CLRWDT
55 01DB: DECFSZ 00,F
56 01DC: GOTO 1CD
57 01DD: RETLW 00
58 .................... #use rs232(STREAM=MOBIL,baud=19200,force_sw,parity=N,xmit=PIN_C6,rcv=PIN_B5,bits=8)
59 01DE: BCF 20.6
60 01DF: MOVF 20,W
61 01E0: BSF 03.5
62 01E1: MOVWF 07
63 01E2: BCF 03.5
64 01E3: BCF 07.6
65 01E4: MOVLW 08
66 01E5: MOVWF 78
245 kaklik 67 01E6: NOP
68 01E7: NOP
69 01E8: NOP
246 kaklik 70 01E9: BSF 78.7
71 01EA: GOTO 1FA
72 01EB: BCF 78.7
73 01EC: RRF 53,F
74 01ED: BTFSC 03.0
75 01EE: BSF 07.6
76 01EF: BTFSS 03.0
77 01F0: BCF 07.6
78 01F1: BSF 78.6
79 01F2: GOTO 1FA
80 01F3: BCF 78.6
81 01F4: DECFSZ 78,F
82 01F5: GOTO 1EC
245 kaklik 83 01F6: NOP
246 kaklik 84 01F7: NOP
85 01F8: NOP
86 01F9: BSF 07.6
87 01FA: MOVLW 49
88 01FB: MOVWF 04
89 01FC: DECFSZ 04,F
90 01FD: GOTO 1FC
91 01FE: NOP
92 01FF: NOP
93 0200: NOP
94 0201: BTFSC 78.7
95 0202: GOTO 1EB
96 0203: BTFSC 78.6
97 0204: GOTO 1F3
98 0205: RETLW 00
99 0206: MOVLW 08
100 0207: MOVWF 77
101 0208: BSF 03.5
102 0209: BSF 06.5
103 020A: BCF 03.5
104 020B: BTFSS 06.5
105 020C: GOTO 20F
106 020D: BSF 03.5
107 020E: GOTO 20A
108 020F: CLRF 57
109 0210: BSF 77.7
110 0211: GOTO 220
111 0212: BCF 77.7
112 0213: GOTO 220
113 0214: BCF 03.0
114 0215: BTFSC 06.5
115 0216: BSF 03.0
116 0217: RRF 57,F
117 0218: BSF 77.6
118 0219: GOTO 220
119 021A: BCF 77.6
120 021B: DECFSZ 77,F
121 021C: GOTO 214
122 021D: MOVF 57,W
123 021E: MOVWF 78
124 021F: GOTO 22D
125 0220: MOVLW 49
126 0221: BTFSC 77.7
127 0222: MOVLW 14
128 0223: MOVWF 78
129 0224: DECFSZ 78,F
130 0225: GOTO 224
131 0226: NOP
132 0227: NOP
133 0228: BTFSC 77.7
134 0229: GOTO 212
135 022A: BTFSC 77.6
136 022B: GOTO 21A
137 022C: GOTO 214
138 022D: RETLW 00
139 *
140 0814: MOVLW FF
141 0815: BCF 03.5
142 0816: MOVWF 20
143 .................... #use rs232(STREAM=VRTULE,baud=600,parity=N,xmit=PIN_B2,rcv=PIN_B4,bits=8)
144 *
145 0348: BSF 03.5
146 0349: BCF 06.2
147 034A: BCF 03.5
148 034B: BCF 06.2
149 034C: MOVLW 08
150 034D: MOVWF 78
151 034E: NOP
152 034F: NOP
153 0350: NOP
154 0351: BSF 78.7
155 0352: GOTO 362
156 0353: BCF 78.7
157 0354: RRF 52,F
158 0355: BTFSC 03.0
159 0356: BSF 06.2
160 0357: BTFSS 03.0
161 0358: BCF 06.2
162 0359: BSF 78.6
163 035A: GOTO 362
164 035B: BCF 78.6
165 035C: DECFSZ 78,F
166 035D: GOTO 354
167 035E: NOP
168 035F: NOP
169 0360: NOP
170 0361: BSF 06.2
171 0362: MOVLW 09
172 0363: MOVWF 77
173 0364: CLRF 04
174 0365: DECFSZ 04,F
175 0366: GOTO 365
176 0367: DECFSZ 77,F
177 0368: GOTO 364
178 0369: MOVLW F0
179 036A: MOVWF 04
180 036B: DECFSZ 04,F
181 036C: GOTO 36B
182 036D: NOP
183 036E: NOP
184 036F: BTFSC 78.7
185 0370: GOTO 353
186 0371: BTFSC 78.6
187 0372: GOTO 35B
188 0373: RETLW 00
223 kapl 189 ....................
190 ....................
191 ....................
240 kaklik 192 .................... #include <stdio.h>
193 .................... ///////////////////////////////////////////////////////////////////////////
194 .................... //// (C) Copyright 1996,2003 Custom Computer Services ////
195 .................... //// This source code may only be used by licensed users of the CCS C ////
196 .................... //// compiler. This source code may only be distributed to other ////
197 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
198 .................... //// or distribution is permitted without written permission. ////
199 .................... //// Derivative programs created using this software in object code ////
200 .................... //// form are not restricted in any way. ////
201 .................... ///////////////////////////////////////////////////////////////////////////
223 kapl 202 ....................
240 kaklik 203 .................... #ifndef _STDIO
204 .................... #define _STDIO
205 .................... #include <string.h>
206 .................... ////////////////////////////////////////////////////////////////////////////
207 .................... //// (C) Copyright 1996,2003 Custom Computer Services ////
208 .................... //// This source code may only be used by licensed users of the CCS C ////
209 .................... //// compiler. This source code may only be distributed to other ////
210 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
211 .................... //// or distribution is permitted without written permission. ////
212 .................... //// Derivative programs created using this software in object code ////
213 .................... //// form are not restricted in any way. ////
214 .................... ////////////////////////////////////////////////////////////////////////////
223 kapl 215 ....................
240 kaklik 216 .................... #ifndef _STRING
217 .................... #define _STRING
218 .................... #include <stddef.h>
219 .................... ///////////////////////////////////////////////////////////////////////////
220 .................... //// (C) Copyright 1996,2003 Custom Computer Services ////
221 .................... //// This source code may only be used by licensed users of the CCS C ////
222 .................... //// compiler. This source code may only be distributed to other ////
223 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
224 .................... //// or distribution is permitted without written permission. ////
225 .................... //// Derivative programs created using this software in object code ////
226 .................... //// form are not restricted in any way. ////
227 .................... ///////////////////////////////////////////////////////////////////////////
223 kapl 228 ....................
240 kaklik 229 .................... #ifndef _STDDEF
223 kapl 230 ....................
240 kaklik 231 .................... #define _STDDEF
223 kapl 232 ....................
240 kaklik 233 .................... #if sizeof(int *)==1
234 .................... #define ptrdiff_t int
235 .................... #else
236 .................... #define ptrdiff_t long
237 .................... #endif
223 kapl 238 ....................
240 kaklik 239 .................... #define size_t int
240 .................... #define wchar_t char
241 .................... #define NULL 0
223 kapl 242 ....................
240 kaklik 243 .................... #define offsetof(s,f) (offsetofbit(s,f)/8)
223 kapl 244 ....................
240 kaklik 245 .................... #endif
223 kapl 246 ....................
240 kaklik 247 .................... #include <ctype.h>
248 .................... ////////////////////////////////////////////////////////////////////////////
249 .................... //// (C) Copyright 1996,2003 Custom Computer Services ////
250 .................... //// This source code may only be used by licensed users of the CCS C ////
251 .................... //// compiler. This source code may only be distributed to other ////
252 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
253 .................... //// or distribution is permitted without written permission. ////
254 .................... //// Derivative programs created using this software in object code ////
255 .................... //// form are not restricted in any way. ////
256 .................... ////////////////////////////////////////////////////////////////////////////
223 kapl 257 ....................
240 kaklik 258 .................... #ifndef _CTYPE
259 .................... #define _CTYPE
223 kapl 260 ....................
240 kaklik 261 .................... #define islower(x) isamong(x,"abcdefghijklmnopqrstuvwxyz")
262 .................... #define isupper(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZ")
263 .................... #define isalnum(x) isamong(x,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
264 .................... #define isalpha(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
265 .................... #define isdigit(x) isamong(x,"0123456789")
266 .................... #define isspace(x) (x==' ')
267 .................... #define isxdigit(x) isamong(x,"0123456789ABCDEFabcdef")
268 .................... #define iscntrl(x) (x<' ')
269 .................... #define isprint(x) (x>=' ')
270 .................... #define isgraph(x) (x>' ')
271 .................... #define ispunct(x) ((x>' ')&&!isalnum(x))
223 kapl 272 ....................
240 kaklik 273 .................... #endif
274 ....................
275 ....................
276 ....................
277 ....................
278 ....................
279 .................... //////////////////////////////////////////////
280 .................... //// Uncomment the following define to ////
281 .................... //// allow some functions to use a ////
282 .................... //// quicker algorithm, but use more ROM ////
283 .................... //// ////
284 .................... //// #define FASTER_BUT_MORE_ROM ////
285 .................... //////////////////////////////////////////////
286 ....................
287 ....................
288 ....................
289 .................... /*Copying functions*/
290 .................... /* standard template:
291 .................... void *memmove(void *s1, void *s2, size_t n).
292 .................... Copies max of n characters safely (not following ending '\0')
293 .................... from s2 in s1; if s2 has less than n characters, appends 0 */
294 ....................
295 .................... char *memmove(void *s1,char *s2,size_t n)
223 kapl 296 .................... {
240 kaklik 297 .................... char *sc1;
298 .................... char *sc2;
299 .................... sc1=s1;
300 .................... sc2=s2;
301 .................... if(sc2<sc1 && sc1 <sc2 +n)
302 .................... for(sc1+=n,sc2+=n;0<n;--n)
303 .................... *--sc1=*--sc2;
304 .................... else
305 .................... for(;0<n;--n)
306 .................... *sc1++=*sc2++;
307 .................... return s1;
308 .................... }
223 kapl 309 ....................
240 kaklik 310 .................... /* compiler ignored the name 'strcpy()'; perhaps, it's reserved?
311 .................... Standard template: char *strcpy(char *s1, const char *s2)
312 .................... copies the string s2 including the null character to s1*/
223 kapl 313 ....................
240 kaklik 314 .................... char *strcopy(char *s1, char *s2)
223 kapl 315 .................... {
240 kaklik 316 .................... char *s;
317 ....................
318 .................... for (s = s1; *s2 != 0; s++, s2++) {
319 .................... *s = *s2;
320 .................... }
321 .................... *s = *s2;
322 .................... return(s1);
223 kapl 323 .................... }
324 ....................
240 kaklik 325 .................... /* standard template:
326 .................... char *strncpy(char *s1, const char *s2, size_t n).
327 .................... Copies max of n characters (not following ending '\0')
328 .................... from s2 in s1; if s2 has less than n characters, appends 0 */
223 kapl 329 ....................
240 kaklik 330 .................... char *strncpy(char *s1, char *s2, size_t n)
223 kapl 331 .................... {
240 kaklik 332 .................... char *s;
333 ....................
334 .................... for (s = s1; n > 0 && *s2 != '\0'; n--)
335 .................... *s++ = *s2++;
336 .................... for (; n > 0; n--)
337 .................... *s++ = '\0';
338 ....................
339 .................... return(s1);
340 .................... }
341 .................... /***********************************************************/
342 ....................
343 .................... /*concatenation functions*/
344 .................... /* standard template: char *strcat(char *s1, const char *s2)
345 .................... appends s2 to s1*/
346 ....................
347 .................... char *strcat(char *s1, char *s2)
348 .................... {
349 .................... char *s;
350 ....................
351 .................... for (s = s1; *s != '\0'; ++s);
352 .................... while(*s2 != '\0')
353 .................... {
354 .................... *s = *s2;
355 .................... ++s;
356 .................... ++s2;
357 .................... }
358 ....................
359 .................... *s = '\0';
360 .................... return(s1);
361 .................... }
362 .................... /* standard template: char *strncat(char *s1, char *s2,size_t n)
363 .................... appends not more than n characters from s2 to s1*/
364 ....................
365 .................... char *strncat(char *s1, char *s2, size_t n)
366 .................... {
367 .................... char *s;
368 ....................
369 .................... for (s = s1; *s != '\0'; ++s);
370 .................... while(*s2 != '\0' && 0<n)
371 .................... {
372 .................... *s = *s2;
373 .................... ++s;
374 .................... ++s2;
375 .................... --n;
376 .................... }
377 ....................
378 .................... *s = '\0';
379 .................... return(s1);
380 .................... }
381 ....................
382 .................... /***********************************************************/
383 ....................
384 ....................
385 .................... /*comparison functions*/
386 .................... /* standard template: signed int memcmp(void *s1, void *s2).
387 .................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
388 ....................
389 .................... signed int memcmp(void * s1,char *s2,size_t n)
390 .................... {
391 .................... char *su1, *su2;
392 .................... for(su1=s1, su2=s2; 0<n; ++su1, ++su2, --n)
393 .................... {
394 .................... if(*su1!=*su2)
395 .................... return ((*su1<*su2)?-1:+1);
396 .................... }
397 .................... return 0;
398 .................... }
399 ....................
400 .................... /* standard template: int strcmp(const char *s1, const char *s2).
401 .................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
402 ....................
403 .................... signed int strcmp(char *s1, char *s2)
404 .................... {
405 .................... for (; *s1 == *s2; s1++, s2++)
406 .................... if (*s1 == '\0')
407 .................... return(0);
408 .................... return((*s1 < *s2) ? -1: 1);
409 .................... }
410 .................... /* standard template: int strcoll(const char *s1, const char *s2).
411 .................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
412 ....................
413 .................... signed int strcoll(char *s1, char *s2)
414 .................... {
415 .................... for (; *s1 == *s2; s1++, s2++)
416 .................... if (*s1 == '\0')
417 .................... return(0);
418 .................... return((*s1 < *s2) ? -1: 1);
419 .................... }
420 ....................
421 .................... /* standard template:
422 .................... int strncmp(const char *s1, const char *s2, size_t n).
423 .................... Compares max of n characters (not following 0) from s1 to s2;
424 .................... returns same as strcmp */
425 ....................
426 .................... signed int strncmp(char *s1, char *s2, size_t n)
427 .................... {
428 .................... for (; n > 0; s1++, s2++, n--)
429 .................... if (*s1 != *s2)
430 .................... return((*s1 <*s2) ? -1: 1);
431 .................... else if (*s1 == '\0')
432 .................... return(0);
433 .................... return(0);
434 .................... }
435 .................... /* standard template:
436 .................... int strxfrm(const char *s1, const char *s2, size_t n).
437 .................... transforms maximum of n characters from s2 and places them into s1*/
438 .................... size_t strxfrm(char *s1, char *s2, size_t n)
439 .................... {
440 .................... char *s;
441 .................... int n1;
442 .................... n1=n;
443 .................... for (s = s1; n > 0 && *s2 != '\0'; n--)
444 .................... *s++ = *s2++;
445 .................... for (; n > 0; n--)
446 .................... *s++ = '\0';
447 ....................
448 .................... return(n1);
449 .................... }
450 ....................
451 ....................
452 ....................
453 ....................
454 ....................
455 .................... /***********************************************************/
456 .................... /*Search functions*/
457 .................... /* standard template: void *memchr(const char *s, int c).
458 .................... Finds first occurrence of c in n characters of s */
459 ....................
460 .................... char *memchr(void *s,int c,size_t n)
461 .................... {
462 .................... char uc;
463 .................... char *su;
464 .................... uc=c;
245 kaklik 465 *
246 kaklik 466 03A0: BSF 03.5
467 03A1: MOVF 47,W
468 03A2: MOVWF 49
240 kaklik 469 .................... for(su=s;0<n;++su,--n)
246 kaklik 470 03A3: MOVF 46,W
471 03A4: MOVWF 4A
472 03A5: MOVF 48,W
473 03A6: SUBLW 00
474 03A7: BTFSC 03.0
475 03A8: GOTO 3B5
240 kaklik 476 .................... if(*su==uc)
246 kaklik 477 03A9: MOVF 4A,W
478 03AA: MOVWF 04
479 03AB: MOVF 49,W
480 03AC: SUBWF 00,W
481 03AD: BTFSS 03.2
482 03AE: GOTO 3B2
240 kaklik 483 .................... return su;
246 kaklik 484 03AF: MOVF 4A,W
485 03B0: MOVWF 78
486 03B1: GOTO 3B7
487 03B2: INCF 4A,F
488 03B3: DECF 48,F
489 03B4: GOTO 3A5
240 kaklik 490 .................... return NULL;
246 kaklik 491 03B5: MOVLW 00
492 03B6: MOVWF 78
240 kaklik 493 .................... }
246 kaklik 494 03B7: BCF 03.5
495 03B8: RETLW 00
240 kaklik 496 ....................
497 .................... /* standard template: char *strchr(const char *s, int c).
498 .................... Finds first occurrence of c in s */
499 ....................
500 .................... char *strchr(char *s, int c)
501 .................... {
502 .................... for (; *s != c; s++)
503 .................... if (*s == '\0')
504 .................... return(0);
505 .................... return(s);
506 .................... }
507 .................... /* standard template:
508 .................... size_t strcspn(const char *s1, const char *s2).
509 .................... Computes length of max initial segment of s1 that
510 .................... consists entirely of characters NOT from s2*/
511 ....................
512 .................... int *strcspn(char *s1, char *s2)
513 .................... {
514 .................... char *sc1, *sc2;
515 ....................
516 .................... for (sc1 = s1; *sc1 != 0; sc1++)
517 .................... for (sc2 = s2; *sc2 != 0; sc2++)
518 .................... if (*sc1 == *sc2)
519 .................... return(sc1 - s1);
520 .................... return(sc1 - s1);
521 .................... }
522 .................... /* standard template:
523 .................... char *strpbrk(const char *s1, const char *s2).
524 .................... Locates first occurence of any character from s2 in s1;
525 .................... returns s1 if s2 is empty string */
526 ....................
527 .................... char *strpbrk(char *s1, char *s2)
528 .................... {
529 .................... char *sc1, *sc2;
530 ....................
531 .................... for (sc1 = s1; *sc1 != 0; sc1++)
532 .................... for (sc2 = s2; *sc2 != 0; sc2++)
533 .................... if (*sc1 == *sc2)
534 .................... return(sc1);
535 .................... return(0);
536 .................... }
537 ....................
538 ....................
539 .................... /* standard template: char *strrchr(const char *s, int c).
540 .................... Finds last occurrence of c in s */
541 ....................
542 .................... char *strrchr(char *s, int c)
543 .................... {
544 .................... char *p;
545 ....................
546 .................... for (p = 0; ; s++)
547 .................... {
548 .................... if (*s == c)
549 .................... p = s;
550 .................... if (*s == '\0')
551 .................... return(p);
552 .................... }
553 .................... }
554 .................... /* computes length of max initial segment of s1 consisting
555 .................... entirely of characters from s2 */
556 ....................
557 .................... int *strspn(char *s1, char *s2)
558 .................... {
559 .................... char *sc1, *sc2;
560 ....................
561 .................... for (sc1 = s1; *sc1 != 0; sc1++)
562 .................... for (sc2 = s2; ; sc2++)
563 .................... if (*sc2 == '\0')
564 .................... return(sc1 - s1);
565 .................... else if (*sc1 == *sc2)
566 .................... break;
567 .................... return(sc1 - s1);
568 .................... }
569 .................... /* standard template:
570 .................... char *strstr(const char *s1, const char *s2);
571 .................... Locates first occurence of character sequence s2 in s1;
572 .................... returns 0 if s2 is empty string
573 ....................
574 .................... Uncomment #define FASTER_BUT_MORE_ROM at the top of the
575 .................... file to use the faster algorithm */
576 .................... char *strstr(char *s1, char *s2)
577 .................... {
578 .................... char *s, *t;
579 ....................
580 .................... #ifdef FASTER_BUT_MORE_ROM
581 .................... if (*s2 == '\0')
582 .................... return(s1);
583 .................... #endif
584 ....................
585 .................... while (*s1)
586 .................... {
587 .................... for(s = s1, t = s2; *t && *s == *t; ++s, ++t);
588 ....................
589 .................... if (*t == '\0')
590 .................... return s1;
591 .................... ++s1;
592 .................... #ifdef FASTER_BUT_MORE_ROM
593 .................... while(*s1 != '\0' && *s1 != *s2)
594 .................... ++s1;
595 .................... #endif
596 .................... }
597 .................... return 0;
598 .................... }
599 ....................
600 .................... /* standard template: char *strtok(char *s1, const char *s2).
601 ....................
602 .................... Finds next token in s1 delimited by a character from separator
603 .................... string s2 (which can be different from call to call). First call
604 .................... starts at beginning of s1 searching for first character NOT
605 .................... contained in s2; returns 0 if none is found.
606 .................... If one is found, it is the start of first token (return value).
607 .................... Function then searches from there for a character contained in s2.
608 .................... If none is found, current token extends to end of s1, and subsequent
609 .................... searches for a token will return 0. If one is found, it is
610 .................... overwritten by '\0', which terminates current token. Function saves
611 .................... pointer to following character from which next search will start.
612 .................... Each subsequent call, with 0 as first argument, starts searching
613 .................... from saved pointer */
614 ....................
615 .................... char *strtok(char *s1, char *s2)
616 .................... {
617 .................... char *beg, *end;
618 .................... static char *save;
239 kaklik 619 *
246 kaklik 620 0817: CLRF 21
240 kaklik 621 ....................
622 .................... beg = (s1)? s1: save;
623 .................... beg += strspn(beg, s2);
624 .................... if (*beg == '\0')
625 .................... {
626 .................... *save = ' ';
627 .................... return(0);
628 .................... }
629 .................... end = strpbrk(beg, s2);
630 .................... if (*end != '\0')
631 .................... {
632 .................... *end = '\0';
633 .................... end++;
634 .................... }
635 .................... save = end;
636 .................... return(beg);
223 kapl 637 .................... }
638 ....................
240 kaklik 639 .................... /*****************************************************************/
640 .................... /*Miscellaneous functions*/
641 .................... /* standard template
642 .................... maps error number in errnum to an error message string
643 .................... Returns: Pointer to string
644 .................... */
645 .................... #ifdef _ERRNO
646 .................... char * strerror(int errnum)
647 .................... {
648 .................... char s[15];
649 .................... switch( errnum)
650 .................... {
651 .................... case 0:
652 .................... strcpy(s,"no errors");
653 .................... return s;
654 .................... case EDOM :
655 .................... strcpy(s,"domain error");
656 .................... return s;
657 .................... case ERANGE:
658 .................... strcpy(s,"range error");
659 .................... return s;
660 .................... }
661 .................... }
662 .................... #ENDIF
663 .................... /* standard template: size_t strlen(const char *s).
664 .................... Computes length of s1 (preceding terminating 0) */
223 kapl 665 ....................
240 kaklik 666 .................... int *strlen(char *s)
223 kapl 667 .................... {
240 kaklik 668 .................... char *sc;
223 kapl 669 ....................
240 kaklik 670 .................... for (sc = s; *sc != 0; sc++);
671 .................... return(sc - s);
672 .................... }
223 kapl 673 ....................
240 kaklik 674 .................... /* standard template: size_t stricmp(const char *s1, const char *s2).
675 .................... Compares s1 to s2 ignoring case (upper vs. lower) */
223 kapl 676 ....................
240 kaklik 677 .................... signed int stricmp(char *s1, char *s2)
678 .................... {
679 .................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32));
680 .................... s1++, s2++)
681 .................... if (*s1 == '\0')
682 .................... return(0);
683 .................... return((*s1 < *s2) ? -1: 1);
684 .................... }
223 kapl 685 ....................
686 ....................
240 kaklik 687 .................... /* standard template: char *strlwr(char *s).
688 .................... Replaces uppercase letters by lowercase;
689 .................... returns pointer to new string s */
690 ....................
691 .................... char *strlwr(char *s)
692 .................... {
693 .................... char *p;
694 ....................
695 .................... for (p = s; *p != '\0'; p++)
696 .................... if (*p >= 'A' && *p <='Z')
697 .................... *p += 'a' - 'A';
698 .................... return(s);
699 .................... }
700 ....................
701 ....................
702 .................... /************************************************************/
703 ....................
704 ....................
705 .................... #endif
706 ....................
707 .................... #ifndef getc
708 .................... #define getc getch
709 .................... #define getchar getch
710 .................... #define puts(s) {printf(s); putchar(13); putchar(10);}
711 .................... #define putc putchar
712 .................... #endif
713 .................... /* maps error number to an error message. Writes a sequence of characters to
714 .................... stderr stream thus: if s is not null then string pointed to by s follwed by
715 .................... a colon (:) and a space and the appropriate error message returned by strerror
716 .................... function with argument errno
717 ....................
718 .................... Returns: no value
719 .................... */
720 ....................
721 .................... #ifdef _ERRNO
722 .................... void perror(char *s)
723 .................... {
724 .................... if(s)
725 .................... fprintf(STDERR,"%s: ",s);
726 .................... fprintf(STDERR,"%s\r\n",strerror(errno));
727 .................... }
728 .................... #endif
729 .................... #endif
730 ....................
731 .................... #include <string.h>
732 .................... ////////////////////////////////////////////////////////////////////////////
733 .................... //// (C) Copyright 1996,2003 Custom Computer Services ////
734 .................... //// This source code may only be used by licensed users of the CCS C ////
735 .................... //// compiler. This source code may only be distributed to other ////
736 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
737 .................... //// or distribution is permitted without written permission. ////
738 .................... //// Derivative programs created using this software in object code ////
739 .................... //// form are not restricted in any way. ////
740 .................... ////////////////////////////////////////////////////////////////////////////
741 ....................
742 .................... #ifndef _STRING
743 .................... #define _STRING
744 .................... #include <stddef.h>
745 .................... #include <ctype.h>
746 ....................
747 ....................
748 ....................
749 .................... //////////////////////////////////////////////
750 .................... //// Uncomment the following define to ////
751 .................... //// allow some functions to use a ////
752 .................... //// quicker algorithm, but use more ROM ////
753 .................... //// ////
754 .................... //// #define FASTER_BUT_MORE_ROM ////
755 .................... //////////////////////////////////////////////
756 ....................
757 ....................
758 ....................
759 .................... /*Copying functions*/
760 .................... /* standard template:
761 .................... void *memmove(void *s1, void *s2, size_t n).
762 .................... Copies max of n characters safely (not following ending '\0')
763 .................... from s2 in s1; if s2 has less than n characters, appends 0 */
764 ....................
765 .................... char *memmove(void *s1,char *s2,size_t n)
766 .................... {
767 .................... char *sc1;
768 .................... char *sc2;
769 .................... sc1=s1;
770 .................... sc2=s2;
771 .................... if(sc2<sc1 && sc1 <sc2 +n)
772 .................... for(sc1+=n,sc2+=n;0<n;--n)
773 .................... *--sc1=*--sc2;
774 .................... else
775 .................... for(;0<n;--n)
776 .................... *sc1++=*sc2++;
777 .................... return s1;
778 .................... }
779 ....................
780 .................... /* compiler ignored the name 'strcpy()'; perhaps, it's reserved?
781 .................... Standard template: char *strcpy(char *s1, const char *s2)
782 .................... copies the string s2 including the null character to s1*/
783 ....................
784 .................... char *strcopy(char *s1, char *s2)
785 .................... {
786 .................... char *s;
787 ....................
788 .................... for (s = s1; *s2 != 0; s++, s2++) {
789 .................... *s = *s2;
790 .................... }
791 .................... *s = *s2;
792 .................... return(s1);
793 .................... }
794 ....................
795 .................... /* standard template:
796 .................... char *strncpy(char *s1, const char *s2, size_t n).
797 .................... Copies max of n characters (not following ending '\0')
798 .................... from s2 in s1; if s2 has less than n characters, appends 0 */
799 ....................
800 .................... char *strncpy(char *s1, char *s2, size_t n)
801 .................... {
802 .................... char *s;
803 ....................
804 .................... for (s = s1; n > 0 && *s2 != '\0'; n--)
805 .................... *s++ = *s2++;
806 .................... for (; n > 0; n--)
807 .................... *s++ = '\0';
808 ....................
809 .................... return(s1);
810 .................... }
811 .................... /***********************************************************/
812 ....................
813 .................... /*concatenation functions*/
814 .................... /* standard template: char *strcat(char *s1, const char *s2)
815 .................... appends s2 to s1*/
816 ....................
817 .................... char *strcat(char *s1, char *s2)
818 .................... {
819 .................... char *s;
820 ....................
821 .................... for (s = s1; *s != '\0'; ++s);
822 .................... while(*s2 != '\0')
223 kapl 823 .................... {
240 kaklik 824 .................... *s = *s2;
825 .................... ++s;
826 .................... ++s2;
223 kapl 827 .................... }
828 ....................
240 kaklik 829 .................... *s = '\0';
830 .................... return(s1);
831 .................... }
832 .................... /* standard template: char *strncat(char *s1, char *s2,size_t n)
833 .................... appends not more than n characters from s2 to s1*/
223 kapl 834 ....................
240 kaklik 835 .................... char *strncat(char *s1, char *s2, size_t n)
836 .................... {
837 .................... char *s;
838 ....................
839 .................... for (s = s1; *s != '\0'; ++s);
840 .................... while(*s2 != '\0' && 0<n)
223 kapl 841 .................... {
240 kaklik 842 .................... *s = *s2;
843 .................... ++s;
844 .................... ++s2;
845 .................... --n;
223 kapl 846 .................... }
240 kaklik 847 ....................
848 .................... *s = '\0';
849 .................... return(s1);
223 kapl 850 .................... }
851 ....................
240 kaklik 852 .................... /***********************************************************/
223 kapl 853 ....................
240 kaklik 854 ....................
855 .................... /*comparison functions*/
856 .................... /* standard template: signed int memcmp(void *s1, void *s2).
857 .................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
858 ....................
859 .................... signed int memcmp(void * s1,char *s2,size_t n)
223 kapl 860 .................... {
240 kaklik 861 .................... char *su1, *su2;
862 .................... for(su1=s1, su2=s2; 0<n; ++su1, ++su2, --n)
863 .................... {
864 .................... if(*su1!=*su2)
865 .................... return ((*su1<*su2)?-1:+1);
866 .................... }
867 .................... return 0;
868 .................... }
223 kapl 869 ....................
240 kaklik 870 .................... /* standard template: int strcmp(const char *s1, const char *s2).
871 .................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
223 kapl 872 ....................
240 kaklik 873 .................... signed int strcmp(char *s1, char *s2)
874 .................... {
875 .................... for (; *s1 == *s2; s1++, s2++)
876 .................... if (*s1 == '\0')
877 .................... return(0);
878 .................... return((*s1 < *s2) ? -1: 1);
879 .................... }
880 .................... /* standard template: int strcoll(const char *s1, const char *s2).
881 .................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
882 ....................
883 .................... signed int strcoll(char *s1, char *s2)
884 .................... {
885 .................... for (; *s1 == *s2; s1++, s2++)
886 .................... if (*s1 == '\0')
887 .................... return(0);
888 .................... return((*s1 < *s2) ? -1: 1);
889 .................... }
890 ....................
891 .................... /* standard template:
892 .................... int strncmp(const char *s1, const char *s2, size_t n).
893 .................... Compares max of n characters (not following 0) from s1 to s2;
894 .................... returns same as strcmp */
895 ....................
896 .................... signed int strncmp(char *s1, char *s2, size_t n)
897 .................... {
898 .................... for (; n > 0; s1++, s2++, n--)
899 .................... if (*s1 != *s2)
900 .................... return((*s1 <*s2) ? -1: 1);
901 .................... else if (*s1 == '\0')
902 .................... return(0);
903 .................... return(0);
904 .................... }
905 .................... /* standard template:
906 .................... int strxfrm(const char *s1, const char *s2, size_t n).
907 .................... transforms maximum of n characters from s2 and places them into s1*/
908 .................... size_t strxfrm(char *s1, char *s2, size_t n)
909 .................... {
910 .................... char *s;
911 .................... int n1;
912 .................... n1=n;
913 .................... for (s = s1; n > 0 && *s2 != '\0'; n--)
914 .................... *s++ = *s2++;
915 .................... for (; n > 0; n--)
916 .................... *s++ = '\0';
917 ....................
918 .................... return(n1);
919 .................... }
920 ....................
921 ....................
922 ....................
923 ....................
924 ....................
925 .................... /***********************************************************/
926 .................... /*Search functions*/
927 .................... /* standard template: void *memchr(const char *s, int c).
928 .................... Finds first occurrence of c in n characters of s */
929 ....................
930 .................... char *memchr(void *s,int c,size_t n)
931 .................... {
932 .................... char uc;
933 .................... char *su;
934 .................... uc=c;
935 .................... for(su=s;0<n;++su,--n)
936 .................... if(*su==uc)
937 .................... return su;
938 .................... return NULL;
939 .................... }
940 ....................
941 .................... /* standard template: char *strchr(const char *s, int c).
942 .................... Finds first occurrence of c in s */
943 ....................
944 .................... char *strchr(char *s, int c)
945 .................... {
946 .................... for (; *s != c; s++)
947 .................... if (*s == '\0')
948 .................... return(0);
949 .................... return(s);
950 .................... }
951 .................... /* standard template:
952 .................... size_t strcspn(const char *s1, const char *s2).
953 .................... Computes length of max initial segment of s1 that
954 .................... consists entirely of characters NOT from s2*/
955 ....................
956 .................... int *strcspn(char *s1, char *s2)
957 .................... {
958 .................... char *sc1, *sc2;
959 ....................
960 .................... for (sc1 = s1; *sc1 != 0; sc1++)
961 .................... for (sc2 = s2; *sc2 != 0; sc2++)
962 .................... if (*sc1 == *sc2)
963 .................... return(sc1 - s1);
964 .................... return(sc1 - s1);
965 .................... }
966 .................... /* standard template:
967 .................... char *strpbrk(const char *s1, const char *s2).
968 .................... Locates first occurence of any character from s2 in s1;
969 .................... returns s1 if s2 is empty string */
970 ....................
971 .................... char *strpbrk(char *s1, char *s2)
972 .................... {
973 .................... char *sc1, *sc2;
974 ....................
975 .................... for (sc1 = s1; *sc1 != 0; sc1++)
976 .................... for (sc2 = s2; *sc2 != 0; sc2++)
977 .................... if (*sc1 == *sc2)
978 .................... return(sc1);
979 .................... return(0);
980 .................... }
981 ....................
982 ....................
983 .................... /* standard template: char *strrchr(const char *s, int c).
984 .................... Finds last occurrence of c in s */
985 ....................
986 .................... char *strrchr(char *s, int c)
987 .................... {
988 .................... char *p;
989 ....................
990 .................... for (p = 0; ; s++)
223 kapl 991 .................... {
240 kaklik 992 .................... if (*s == c)
993 .................... p = s;
994 .................... if (*s == '\0')
995 .................... return(p);
223 kapl 996 .................... }
240 kaklik 997 .................... }
998 .................... /* computes length of max initial segment of s1 consisting
999 .................... entirely of characters from s2 */
223 kapl 1000 ....................
240 kaklik 1001 .................... int *strspn(char *s1, char *s2)
1002 .................... {
1003 .................... char *sc1, *sc2;
1004 ....................
1005 .................... for (sc1 = s1; *sc1 != 0; sc1++)
1006 .................... for (sc2 = s2; ; sc2++)
1007 .................... if (*sc2 == '\0')
1008 .................... return(sc1 - s1);
1009 .................... else if (*sc1 == *sc2)
1010 .................... break;
1011 .................... return(sc1 - s1);
223 kapl 1012 .................... }
240 kaklik 1013 .................... /* standard template:
1014 .................... char *strstr(const char *s1, const char *s2);
1015 .................... Locates first occurence of character sequence s2 in s1;
1016 .................... returns 0 if s2 is empty string
223 kapl 1017 ....................
240 kaklik 1018 .................... Uncomment #define FASTER_BUT_MORE_ROM at the top of the
1019 .................... file to use the faster algorithm */
1020 .................... char *strstr(char *s1, char *s2)
1021 .................... {
1022 .................... char *s, *t;
223 kapl 1023 ....................
240 kaklik 1024 .................... #ifdef FASTER_BUT_MORE_ROM
1025 .................... if (*s2 == '\0')
1026 .................... return(s1);
1027 .................... #endif
1028 ....................
1029 .................... while (*s1)
1030 .................... {
1031 .................... for(s = s1, t = s2; *t && *s == *t; ++s, ++t);
1032 ....................
1033 .................... if (*t == '\0')
1034 .................... return s1;
1035 .................... ++s1;
1036 .................... #ifdef FASTER_BUT_MORE_ROM
1037 .................... while(*s1 != '\0' && *s1 != *s2)
1038 .................... ++s1;
1039 .................... #endif
1040 .................... }
1041 .................... return 0;
1042 .................... }
1043 ....................
1044 .................... /* standard template: char *strtok(char *s1, const char *s2).
1045 ....................
1046 .................... Finds next token in s1 delimited by a character from separator
1047 .................... string s2 (which can be different from call to call). First call
1048 .................... starts at beginning of s1 searching for first character NOT
1049 .................... contained in s2; returns 0 if none is found.
1050 .................... If one is found, it is the start of first token (return value).
1051 .................... Function then searches from there for a character contained in s2.
1052 .................... If none is found, current token extends to end of s1, and subsequent
1053 .................... searches for a token will return 0. If one is found, it is
1054 .................... overwritten by '\0', which terminates current token. Function saves
1055 .................... pointer to following character from which next search will start.
1056 .................... Each subsequent call, with 0 as first argument, starts searching
1057 .................... from saved pointer */
1058 ....................
1059 .................... char *strtok(char *s1, char *s2)
223 kapl 1060 .................... {
240 kaklik 1061 .................... char *beg, *end;
1062 .................... static char *save;
223 kapl 1063 ....................
240 kaklik 1064 .................... beg = (s1)? s1: save;
1065 .................... beg += strspn(beg, s2);
1066 .................... if (*beg == '\0')
223 kapl 1067 .................... {
240 kaklik 1068 .................... *save = ' ';
1069 .................... return(0);
223 kapl 1070 .................... }
240 kaklik 1071 .................... end = strpbrk(beg, s2);
1072 .................... if (*end != '\0')
1073 .................... {
1074 .................... *end = '\0';
1075 .................... end++;
1076 .................... }
1077 .................... save = end;
1078 .................... return(beg);
223 kapl 1079 .................... }
1080 ....................
240 kaklik 1081 .................... /*****************************************************************/
1082 .................... /*Miscellaneous functions*/
1083 .................... /* standard template
1084 .................... maps error number in errnum to an error message string
1085 .................... Returns: Pointer to string
1086 .................... */
1087 .................... #ifdef _ERRNO
1088 .................... char * strerror(int errnum)
1089 .................... {
1090 .................... char s[15];
1091 .................... switch( errnum)
1092 .................... {
1093 .................... case 0:
1094 .................... strcpy(s,"no errors");
1095 .................... return s;
1096 .................... case EDOM :
1097 .................... strcpy(s,"domain error");
1098 .................... return s;
1099 .................... case ERANGE:
1100 .................... strcpy(s,"range error");
1101 .................... return s;
1102 .................... }
1103 .................... }
1104 .................... #ENDIF
1105 .................... /* standard template: size_t strlen(const char *s).
1106 .................... Computes length of s1 (preceding terminating 0) */
223 kapl 1107 ....................
240 kaklik 1108 .................... int *strlen(char *s)
223 kapl 1109 .................... {
240 kaklik 1110 .................... char *sc;
1111 ....................
1112 .................... for (sc = s; *sc != 0; sc++);
1113 .................... return(sc - s);
223 kapl 1114 .................... }
1115 ....................
240 kaklik 1116 .................... /* standard template: size_t stricmp(const char *s1, const char *s2).
1117 .................... Compares s1 to s2 ignoring case (upper vs. lower) */
223 kapl 1118 ....................
240 kaklik 1119 .................... signed int stricmp(char *s1, char *s2)
223 kapl 1120 .................... {
240 kaklik 1121 .................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32));
1122 .................... s1++, s2++)
1123 .................... if (*s1 == '\0')
1124 .................... return(0);
1125 .................... return((*s1 < *s2) ? -1: 1);
223 kapl 1126 .................... }
1127 ....................
1128 ....................
240 kaklik 1129 .................... /* standard template: char *strlwr(char *s).
1130 .................... Replaces uppercase letters by lowercase;
1131 .................... returns pointer to new string s */
223 kapl 1132 ....................
240 kaklik 1133 .................... char *strlwr(char *s)
1134 .................... {
1135 .................... char *p;
223 kapl 1136 ....................
240 kaklik 1137 .................... for (p = s; *p != '\0'; p++)
1138 .................... if (*p >= 'A' && *p <='Z')
1139 .................... *p += 'a' - 'A';
1140 .................... return(s);
1141 .................... }
1142 ....................
1143 ....................
1144 .................... /************************************************************/
1145 ....................
1146 ....................
1147 .................... #endif
1148 ....................
1149 .................... #include <stdlib.h>
1150 .................... ///////////////////////////////////////////////////////////////////////////
1151 .................... //// (C) Copyright 1996,2003 Custom Computer Services ////
1152 .................... //// This source code may only be used by licensed users of the CCS C ////
1153 .................... //// compiler. This source code may only be distributed to other ////
1154 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
1155 .................... //// or distribution is permitted without written permission. ////
1156 .................... //// Derivative programs created using this software in object code ////
1157 .................... //// form are not restricted in any way. ////
1158 .................... ///////////////////////////////////////////////////////////////////////////
1159 ....................
1160 .................... #ifndef _STDLIB
1161 .................... #define _STDLIB
1162 ....................
1163 .................... //---------------------------------------------------------------------------
1164 .................... // Definitions and types
1165 .................... //---------------------------------------------------------------------------
1166 ....................
1167 .................... #ifndef RAND_MAX
1168 .................... #define RAND_MAX 32767 // The value of which is the maximum value
1169 .................... // ... returned by the rand function
1170 .................... #endif
1171 ....................
1172 .................... typedef struct {
1173 .................... signed int quot;
1174 .................... signed int rem;
1175 .................... } div_t;
1176 ....................
1177 .................... typedef struct {
1178 .................... signed long quot;
1179 .................... signed long rem;
1180 .................... } ldiv_t;
1181 ....................
1182 .................... #include <stddef.h>
1183 .................... ///////////////////////////////////////////////////////////////////////////
1184 .................... //// (C) Copyright 1996,2003 Custom Computer Services ////
1185 .................... //// This source code may only be used by licensed users of the CCS C ////
1186 .................... //// compiler. This source code may only be distributed to other ////
1187 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
1188 .................... //// or distribution is permitted without written permission. ////
1189 .................... //// Derivative programs created using this software in object code ////
1190 .................... //// form are not restricted in any way. ////
1191 .................... ///////////////////////////////////////////////////////////////////////////
1192 ....................
1193 .................... #ifndef _STDDEF
1194 ....................
1195 .................... #define _STDDEF
1196 ....................
1197 .................... #if sizeof(int *)==1
1198 .................... #define ptrdiff_t int
1199 .................... #else
1200 .................... #define ptrdiff_t long
1201 .................... #endif
1202 ....................
1203 .................... #define size_t int
1204 .................... #define wchar_t char
1205 .................... #define NULL 0
1206 ....................
1207 .................... #define offsetof(s,f) (offsetofbit(s,f)/8)
1208 ....................
1209 .................... #endif
1210 ....................
1211 ....................
1212 .................... //---------------------------------------------------------------------------
1213 .................... // String conversion functions
1214 .................... //---------------------------------------------------------------------------
1215 ....................
1216 .................... /* Standard template: float atof(char * s)
1217 .................... * converts the initial portion of the string s to a float.
1218 .................... * returns the converted value if any, 0 otherwise
1219 .................... */
1220 .................... float atof(char * s);
1221 ....................
1222 .................... /* Standard template: float atoe(char * s)
1223 .................... * converts the initial portion of the string s to a float.
1224 .................... * returns the converted value if any, 0 otherwise
1225 .................... * also handles E format numbers
1226 .................... */
1227 .................... float atoe(char * s);
1228 ....................
1229 .................... /* Standard template: signed int atoi(char * s)
1230 .................... * converts the initial portion of the string s to a signed int
1231 .................... * returns the converted value if any, 0 otherwise
1232 .................... */
1233 .................... signed int atoi(char *s);
1234 ....................
1235 .................... /* Syntax: signed int32 atoi32(char * s)
1236 .................... converts the initial portion of the string s to a signed int32
1237 .................... returns the converted value if any, 0 otherwise*/
1238 .................... signed int32 atoi32(char *s);
1239 ....................
1240 .................... /* Syntax: char * itoa(signed int32 num, int8 base, char * s)
1241 .................... converts the signed int32 to a string and
1242 .................... returns the converted value if any, 0 otherwise*/
1243 .................... char * itoa(signed int32 num, int8 base, char * s);
1244 ....................
1245 .................... /* Standard template: signed long atol(char * s)
1246 .................... * converts the initial portion of the string s to a signed long
1247 .................... * returns the converted value if any, 0 otherwise
1248 .................... */
1249 .................... signed long atol(char *s);
1250 ....................
1251 .................... /* Standard template: float strtol(char * s,char *endptr)
1252 .................... * converts the initial portion of the string s to a float
1253 .................... * returns the converted value if any, 0 otherwise
1254 .................... * the final string is returned in the endptr, if endptr is not null
1255 .................... */
1256 .................... float strtod(char *s,char *endptr);
1257 ....................
1258 .................... /* Standard template: long strtoul(char * s,char *endptr,signed int base)
1259 .................... * converts the initial portion of the string s, represented as an
1260 .................... * integral value of radix base to a signed long.
1261 .................... * Returns the converted value if any, 0 otherwise
1262 .................... * the final string is returned in the endptr, if endptr is not null
1263 .................... */
1264 .................... signed long strtol(char *s,char *endptr,signed int base);
1265 ....................
1266 .................... /* Standard template: long strtoul(char * s,char *endptr,signed int base)
1267 .................... * converts the initial portion of the string s, represented as an
1268 .................... * integral value of radix base to a unsigned long.
1269 .................... * returns the converted value if any, 0 otherwise
1270 .................... * the final string is returned in the endptr, if endptr is not null
1271 .................... */
1272 .................... long strtoul(char *s,char *endptr,signed int base);
1273 ....................
1274 .................... //---------------------------------------------------------------------------
1275 .................... // Pseudo-random sequence generation functions
1276 .................... //---------------------------------------------------------------------------
1277 ....................
1278 .................... /* The rand function computes a sequence of pseudo-random integers in
1279 .................... * the range 0 to RAND_MAX
1280 .................... *
1281 .................... * Parameters:
1282 .................... * (none)
1283 .................... *
1284 .................... * Returns:
1285 .................... * The pseudo-random integer
1286 .................... */
1287 .................... long rand(void);
1288 ....................
1289 .................... /* The srand function uses the argument as a seed for a new sequence of
1290 .................... * pseudo-random numbers to be returned by subsequent calls to rand.
1291 .................... *
1292 .................... * Parameters:
1293 .................... * [in] seed: The seed value to start from. You might need to pass
1294 .................... *
1295 .................... * Returns:
1296 .................... * (none)
1297 .................... *
1298 .................... * Remarks
1299 .................... * The srand function sets the starting point for generating
1300 .................... * a series of pseudorandom integers. To reinitialize the
1301 .................... * generator, use 1 as the seed argument. Any other value for
1302 .................... * seed sets the generator to a random starting point. rand
1303 .................... * retrieves the pseudorandom numbers that are generated.
1304 .................... * Calling rand before any call to srand generates the same
1305 .................... * sequence as calling srand with seed passed as 1.
1306 .................... * Usually, you need to pass a time here from outer source
1307 .................... * so that the numbers will be different every time you run.
1308 .................... */
1309 .................... void srand(unsigned int32 seed);
1310 ....................
1311 .................... //---------------------------------------------------------------------------
1312 .................... // Memory management functions
1313 .................... //---------------------------------------------------------------------------
1314 ....................
1315 .................... // Comming soon
1316 ....................
1317 .................... //---------------------------------------------------------------------------
1318 .................... // Communication with the environment
1319 .................... //---------------------------------------------------------------------------
1320 ....................
1321 .................... /* The function returns 0 always
1322 .................... */
1323 .................... signed int system(char *string);
1324 ....................
1325 .................... //---------------------------------------------------------------------------
1326 .................... // Searching and sorting utilities
1327 .................... //---------------------------------------------------------------------------
1328 ....................
1329 .................... /* Performs a binary search of a sorted array..
1330 .................... *
1331 .................... * Parameters:
1332 .................... * [in] key: Object to search for
1333 .................... * [in] base: Pointer to base of search data
1334 .................... * [in] num: Number of elements
1335 .................... * [in] width: Width of elements
1336 .................... * [in] compare: Function that compares two elements
1337 .................... *
1338 .................... * Returns:
1339 .................... * bsearch returns a pointer to an occurrence of key in the array pointed
1340 .................... * to by base. If key is not found, the function returns NULL. If the
1341 .................... * array is not in order or contains duplicate records with identical keys,
1342 .................... * the result is unpredictable.
1343 .................... */
1344 .................... //void *bsearch(const void *key, const void *base, size_t num, size_t width,
1345 .................... // int (*compare)(const void *, const void *));
1346 ....................
1347 .................... /* Performs the shell-metzner sort (not the quick sort algorithm). The contents
1348 .................... * of the array are sorted into ascending order according to a comparison
1349 .................... * function pointed to by compar.
1350 .................... *
1351 .................... * Parameters:
1352 .................... * [in] base: Pointer to base of search data
1353 .................... * [in] num: Number of elements
1354 .................... * [in] width: Width of elements
1355 .................... * [in] compare: Function that compares two elements
1356 .................... *
1357 .................... * Returns:
1358 .................... * (none)
1359 .................... */
1360 .................... //void *qsort(const void *base, size_t num, size_t width,
1361 .................... // int (*compare)(const void *, const void *));
1362 ....................
1363 .................... //---------------------------------------------------------------------------
1364 .................... // Integer arithmetic functions
1365 .................... //---------------------------------------------------------------------------
1366 ....................
1367 .................... #define labs abs
1368 ....................
1369 .................... div_t div(signed int numer,signed int denom);
1370 .................... ldiv_t ldiv(signed long numer,signed long denom);
1371 ....................
1372 .................... //---------------------------------------------------------------------------
1373 .................... // Multibyte character functions
1374 .................... //---------------------------------------------------------------------------
1375 ....................
1376 .................... // Not supported
1377 ....................
1378 .................... //---------------------------------------------------------------------------
1379 .................... // Multibyte string functions
1380 .................... //---------------------------------------------------------------------------
1381 ....................
1382 .................... // Not supported
1383 ....................
1384 ....................
1385 .................... //---------------------------------------------------------------------------
1386 .................... // Internal implementation
1387 .................... //---------------------------------------------------------------------------
1388 ....................
1389 .................... #include <stddef.h>
1390 .................... ///////////////////////////////////////////////////////////////////////////
1391 .................... //// (C) Copyright 1996,2003 Custom Computer Services ////
1392 .................... //// This source code may only be used by licensed users of the CCS C ////
1393 .................... //// compiler. This source code may only be distributed to other ////
1394 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
1395 .................... //// or distribution is permitted without written permission. ////
1396 .................... //// Derivative programs created using this software in object code ////
1397 .................... //// form are not restricted in any way. ////
1398 .................... ///////////////////////////////////////////////////////////////////////////
1399 ....................
1400 .................... #ifndef _STDDEF
1401 ....................
1402 .................... #define _STDDEF
1403 ....................
1404 .................... #if sizeof(int *)==1
1405 .................... #define ptrdiff_t int
1406 .................... #else
1407 .................... #define ptrdiff_t long
1408 .................... #endif
1409 ....................
1410 .................... #define size_t int
1411 .................... #define wchar_t char
1412 .................... #define NULL 0
1413 ....................
1414 .................... #define offsetof(s,f) (offsetofbit(s,f)/8)
1415 ....................
1416 .................... #endif
1417 ....................
1418 .................... #include <string.h>
1419 .................... ////////////////////////////////////////////////////////////////////////////
1420 .................... //// (C) Copyright 1996,2003 Custom Computer Services ////
1421 .................... //// This source code may only be used by licensed users of the CCS C ////
1422 .................... //// compiler. This source code may only be distributed to other ////
1423 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
1424 .................... //// or distribution is permitted without written permission. ////
1425 .................... //// Derivative programs created using this software in object code ////
1426 .................... //// form are not restricted in any way. ////
1427 .................... ////////////////////////////////////////////////////////////////////////////
1428 ....................
1429 .................... #ifndef _STRING
1430 .................... #define _STRING
1431 .................... #include <stddef.h>
1432 .................... #include <ctype.h>
1433 ....................
1434 ....................
1435 ....................
1436 .................... //////////////////////////////////////////////
1437 .................... //// Uncomment the following define to ////
1438 .................... //// allow some functions to use a ////
1439 .................... //// quicker algorithm, but use more ROM ////
1440 .................... //// ////
1441 .................... //// #define FASTER_BUT_MORE_ROM ////
1442 .................... //////////////////////////////////////////////
1443 ....................
1444 ....................
1445 ....................
1446 .................... /*Copying functions*/
1447 .................... /* standard template:
1448 .................... void *memmove(void *s1, void *s2, size_t n).
1449 .................... Copies max of n characters safely (not following ending '\0')
1450 .................... from s2 in s1; if s2 has less than n characters, appends 0 */
1451 ....................
1452 .................... char *memmove(void *s1,char *s2,size_t n)
223 kapl 1453 .................... {
240 kaklik 1454 .................... char *sc1;
1455 .................... char *sc2;
1456 .................... sc1=s1;
1457 .................... sc2=s2;
1458 .................... if(sc2<sc1 && sc1 <sc2 +n)
1459 .................... for(sc1+=n,sc2+=n;0<n;--n)
1460 .................... *--sc1=*--sc2;
1461 .................... else
1462 .................... for(;0<n;--n)
1463 .................... *sc1++=*sc2++;
1464 .................... return s1;
1465 .................... }
1466 ....................
1467 .................... /* compiler ignored the name 'strcpy()'; perhaps, it's reserved?
1468 .................... Standard template: char *strcpy(char *s1, const char *s2)
1469 .................... copies the string s2 including the null character to s1*/
1470 ....................
1471 .................... char *strcopy(char *s1, char *s2)
1472 .................... {
1473 .................... char *s;
1474 ....................
1475 .................... for (s = s1; *s2 != 0; s++, s2++) {
1476 .................... *s = *s2;
1477 .................... }
1478 .................... *s = *s2;
1479 .................... return(s1);
223 kapl 1480 .................... }
1481 ....................
240 kaklik 1482 .................... /* standard template:
1483 .................... char *strncpy(char *s1, const char *s2, size_t n).
1484 .................... Copies max of n characters (not following ending '\0')
1485 .................... from s2 in s1; if s2 has less than n characters, appends 0 */
223 kapl 1486 ....................
240 kaklik 1487 .................... char *strncpy(char *s1, char *s2, size_t n)
1488 .................... {
1489 .................... char *s;
223 kapl 1490 ....................
240 kaklik 1491 .................... for (s = s1; n > 0 && *s2 != '\0'; n--)
1492 .................... *s++ = *s2++;
1493 .................... for (; n > 0; n--)
1494 .................... *s++ = '\0';
223 kapl 1495 ....................
240 kaklik 1496 .................... return(s1);
1497 .................... }
1498 .................... /***********************************************************/
223 kapl 1499 ....................
240 kaklik 1500 .................... /*concatenation functions*/
1501 .................... /* standard template: char *strcat(char *s1, const char *s2)
1502 .................... appends s2 to s1*/
223 kapl 1503 ....................
240 kaklik 1504 .................... char *strcat(char *s1, char *s2)
1505 .................... {
1506 .................... char *s;
223 kapl 1507 ....................
240 kaklik 1508 .................... for (s = s1; *s != '\0'; ++s);
1509 .................... while(*s2 != '\0')
1510 .................... {
1511 .................... *s = *s2;
1512 .................... ++s;
1513 .................... ++s2;
1514 .................... }
223 kapl 1515 ....................
240 kaklik 1516 .................... *s = '\0';
1517 .................... return(s1);
1518 .................... }
1519 .................... /* standard template: char *strncat(char *s1, char *s2,size_t n)
1520 .................... appends not more than n characters from s2 to s1*/
223 kapl 1521 ....................
240 kaklik 1522 .................... char *strncat(char *s1, char *s2, size_t n)
1523 .................... {
1524 .................... char *s;
223 kapl 1525 ....................
240 kaklik 1526 .................... for (s = s1; *s != '\0'; ++s);
1527 .................... while(*s2 != '\0' && 0<n)
1528 .................... {
1529 .................... *s = *s2;
1530 .................... ++s;
1531 .................... ++s2;
1532 .................... --n;
1533 .................... }
1534 ....................
1535 .................... *s = '\0';
1536 .................... return(s1);
1537 .................... }
1538 ....................
1539 .................... /***********************************************************/
1540 ....................
1541 ....................
1542 .................... /*comparison functions*/
1543 .................... /* standard template: signed int memcmp(void *s1, void *s2).
1544 .................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
1545 ....................
1546 .................... signed int memcmp(void * s1,char *s2,size_t n)
223 kapl 1547 .................... {
240 kaklik 1548 .................... char *su1, *su2;
1549 .................... for(su1=s1, su2=s2; 0<n; ++su1, ++su2, --n)
1550 .................... {
1551 .................... if(*su1!=*su2)
1552 .................... return ((*su1<*su2)?-1:+1);
1553 .................... }
1554 .................... return 0;
1555 .................... }
223 kapl 1556 ....................
240 kaklik 1557 .................... /* standard template: int strcmp(const char *s1, const char *s2).
1558 .................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
239 kaklik 1559 ....................
240 kaklik 1560 .................... signed int strcmp(char *s1, char *s2)
1561 .................... {
1562 .................... for (; *s1 == *s2; s1++, s2++)
1563 .................... if (*s1 == '\0')
1564 .................... return(0);
1565 .................... return((*s1 < *s2) ? -1: 1);
1566 .................... }
1567 .................... /* standard template: int strcoll(const char *s1, const char *s2).
1568 .................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */
1569 ....................
1570 .................... signed int strcoll(char *s1, char *s2)
1571 .................... {
1572 .................... for (; *s1 == *s2; s1++, s2++)
1573 .................... if (*s1 == '\0')
1574 .................... return(0);
1575 .................... return((*s1 < *s2) ? -1: 1);
1576 .................... }
1577 ....................
1578 .................... /* standard template:
1579 .................... int strncmp(const char *s1, const char *s2, size_t n).
1580 .................... Compares max of n characters (not following 0) from s1 to s2;
1581 .................... returns same as strcmp */
1582 ....................
1583 .................... signed int strncmp(char *s1, char *s2, size_t n)
1584 .................... {
1585 .................... for (; n > 0; s1++, s2++, n--)
1586 .................... if (*s1 != *s2)
1587 .................... return((*s1 <*s2) ? -1: 1);
1588 .................... else if (*s1 == '\0')
1589 .................... return(0);
1590 .................... return(0);
1591 .................... }
1592 .................... /* standard template:
1593 .................... int strxfrm(const char *s1, const char *s2, size_t n).
1594 .................... transforms maximum of n characters from s2 and places them into s1*/
1595 .................... size_t strxfrm(char *s1, char *s2, size_t n)
1596 .................... {
1597 .................... char *s;
1598 .................... int n1;
1599 .................... n1=n;
1600 .................... for (s = s1; n > 0 && *s2 != '\0'; n--)
1601 .................... *s++ = *s2++;
1602 .................... for (; n > 0; n--)
1603 .................... *s++ = '\0';
1604 ....................
1605 .................... return(n1);
1606 .................... }
1607 ....................
1608 ....................
1609 ....................
1610 ....................
1611 ....................
1612 .................... /***********************************************************/
1613 .................... /*Search functions*/
1614 .................... /* standard template: void *memchr(const char *s, int c).
1615 .................... Finds first occurrence of c in n characters of s */
1616 ....................
1617 .................... char *memchr(void *s,int c,size_t n)
1618 .................... {
1619 .................... char uc;
1620 .................... char *su;
1621 .................... uc=c;
1622 .................... for(su=s;0<n;++su,--n)
1623 .................... if(*su==uc)
1624 .................... return su;
1625 .................... return NULL;
1626 .................... }
1627 ....................
1628 .................... /* standard template: char *strchr(const char *s, int c).
1629 .................... Finds first occurrence of c in s */
1630 ....................
1631 .................... char *strchr(char *s, int c)
1632 .................... {
1633 .................... for (; *s != c; s++)
1634 .................... if (*s == '\0')
1635 .................... return(0);
1636 .................... return(s);
1637 .................... }
1638 .................... /* standard template:
1639 .................... size_t strcspn(const char *s1, const char *s2).
1640 .................... Computes length of max initial segment of s1 that
1641 .................... consists entirely of characters NOT from s2*/
1642 ....................
1643 .................... int *strcspn(char *s1, char *s2)
1644 .................... {
1645 .................... char *sc1, *sc2;
1646 ....................
1647 .................... for (sc1 = s1; *sc1 != 0; sc1++)
1648 .................... for (sc2 = s2; *sc2 != 0; sc2++)
1649 .................... if (*sc1 == *sc2)
1650 .................... return(sc1 - s1);
1651 .................... return(sc1 - s1);
1652 .................... }
1653 .................... /* standard template:
1654 .................... char *strpbrk(const char *s1, const char *s2).
1655 .................... Locates first occurence of any character from s2 in s1;
1656 .................... returns s1 if s2 is empty string */
1657 ....................
1658 .................... char *strpbrk(char *s1, char *s2)
1659 .................... {
1660 .................... char *sc1, *sc2;
1661 ....................
1662 .................... for (sc1 = s1; *sc1 != 0; sc1++)
1663 .................... for (sc2 = s2; *sc2 != 0; sc2++)
1664 .................... if (*sc1 == *sc2)
1665 .................... return(sc1);
1666 .................... return(0);
1667 .................... }
1668 ....................
1669 ....................
1670 .................... /* standard template: char *strrchr(const char *s, int c).
1671 .................... Finds last occurrence of c in s */
1672 ....................
1673 .................... char *strrchr(char *s, int c)
1674 .................... {
1675 .................... char *p;
1676 ....................
1677 .................... for (p = 0; ; s++)
223 kapl 1678 .................... {
240 kaklik 1679 .................... if (*s == c)
1680 .................... p = s;
1681 .................... if (*s == '\0')
1682 .................... return(p);
1683 .................... }
1684 .................... }
1685 .................... /* computes length of max initial segment of s1 consisting
1686 .................... entirely of characters from s2 */
239 kaklik 1687 ....................
240 kaklik 1688 .................... int *strspn(char *s1, char *s2)
1689 .................... {
1690 .................... char *sc1, *sc2;
239 kaklik 1691 ....................
240 kaklik 1692 .................... for (sc1 = s1; *sc1 != 0; sc1++)
1693 .................... for (sc2 = s2; ; sc2++)
1694 .................... if (*sc2 == '\0')
1695 .................... return(sc1 - s1);
1696 .................... else if (*sc1 == *sc2)
1697 .................... break;
1698 .................... return(sc1 - s1);
1699 .................... }
1700 .................... /* standard template:
1701 .................... char *strstr(const char *s1, const char *s2);
1702 .................... Locates first occurence of character sequence s2 in s1;
1703 .................... returns 0 if s2 is empty string
238 kaklik 1704 ....................
240 kaklik 1705 .................... Uncomment #define FASTER_BUT_MORE_ROM at the top of the
1706 .................... file to use the faster algorithm */
1707 .................... char *strstr(char *s1, char *s2)
1708 .................... {
1709 .................... char *s, *t;
238 kaklik 1710 ....................
240 kaklik 1711 .................... #ifdef FASTER_BUT_MORE_ROM
1712 .................... if (*s2 == '\0')
1713 .................... return(s1);
1714 .................... #endif
238 kaklik 1715 ....................
240 kaklik 1716 .................... while (*s1)
1717 .................... {
1718 .................... for(s = s1, t = s2; *t && *s == *t; ++s, ++t);
1719 ....................
1720 .................... if (*t == '\0')
1721 .................... return s1;
1722 .................... ++s1;
1723 .................... #ifdef FASTER_BUT_MORE_ROM
1724 .................... while(*s1 != '\0' && *s1 != *s2)
1725 .................... ++s1;
1726 .................... #endif
1727 .................... }
1728 .................... return 0;
1729 .................... }
1730 ....................
1731 .................... /* standard template: char *strtok(char *s1, const char *s2).
1732 ....................
1733 .................... Finds next token in s1 delimited by a character from separator
1734 .................... string s2 (which can be different from call to call). First call
1735 .................... starts at beginning of s1 searching for first character NOT
1736 .................... contained in s2; returns 0 if none is found.
1737 .................... If one is found, it is the start of first token (return value).
1738 .................... Function then searches from there for a character contained in s2.
1739 .................... If none is found, current token extends to end of s1, and subsequent
1740 .................... searches for a token will return 0. If one is found, it is
1741 .................... overwritten by '\0', which terminates current token. Function saves
1742 .................... pointer to following character from which next search will start.
1743 .................... Each subsequent call, with 0 as first argument, starts searching
1744 .................... from saved pointer */
1745 ....................
1746 .................... char *strtok(char *s1, char *s2)
1747 .................... {
1748 .................... char *beg, *end;
1749 .................... static char *save;
1750 ....................
1751 .................... beg = (s1)? s1: save;
1752 .................... beg += strspn(beg, s2);
1753 .................... if (*beg == '\0')
1754 .................... {
1755 .................... *save = ' ';
1756 .................... return(0);
1757 .................... }
1758 .................... end = strpbrk(beg, s2);
1759 .................... if (*end != '\0')
1760 .................... {
1761 .................... *end = '\0';
1762 .................... end++;
1763 .................... }
1764 .................... save = end;
1765 .................... return(beg);
1766 .................... }
1767 ....................
1768 .................... /*****************************************************************/
1769 .................... /*Miscellaneous functions*/
1770 .................... /* standard template
1771 .................... maps error number in errnum to an error message string
1772 .................... Returns: Pointer to string
238 kaklik 1773 .................... */
240 kaklik 1774 .................... #ifdef _ERRNO
1775 .................... char * strerror(int errnum)
1776 .................... {
1777 .................... char s[15];
1778 .................... switch( errnum)
1779 .................... {
1780 .................... case 0:
1781 .................... strcpy(s,"no errors");
1782 .................... return s;
1783 .................... case EDOM :
1784 .................... strcpy(s,"domain error");
1785 .................... return s;
1786 .................... case ERANGE:
1787 .................... strcpy(s,"range error");
1788 .................... return s;
1789 .................... }
1790 .................... }
1791 .................... #ENDIF
1792 .................... /* standard template: size_t strlen(const char *s).
1793 .................... Computes length of s1 (preceding terminating 0) */
239 kaklik 1794 ....................
240 kaklik 1795 .................... int *strlen(char *s)
1796 .................... {
1797 .................... char *sc;
239 kaklik 1798 ....................
240 kaklik 1799 .................... for (sc = s; *sc != 0; sc++);
1800 .................... return(sc - s);
1801 .................... }
238 kaklik 1802 ....................
240 kaklik 1803 .................... /* standard template: size_t stricmp(const char *s1, const char *s2).
1804 .................... Compares s1 to s2 ignoring case (upper vs. lower) */
238 kaklik 1805 ....................
240 kaklik 1806 .................... signed int stricmp(char *s1, char *s2)
1807 .................... {
1808 .................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32));
1809 .................... s1++, s2++)
1810 .................... if (*s1 == '\0')
1811 .................... return(0);
1812 .................... return((*s1 < *s2) ? -1: 1);
1813 .................... }
238 kaklik 1814 ....................
1815 ....................
240 kaklik 1816 .................... /* standard template: char *strlwr(char *s).
1817 .................... Replaces uppercase letters by lowercase;
1818 .................... returns pointer to new string s */
1819 ....................
1820 .................... char *strlwr(char *s)
1821 .................... {
1822 .................... char *p;
1823 ....................
1824 .................... for (p = s; *p != '\0'; p++)
1825 .................... if (*p >= 'A' && *p <='Z')
1826 .................... *p += 'a' - 'A';
1827 .................... return(s);
1828 .................... }
1829 ....................
1830 ....................
1831 .................... /************************************************************/
1832 ....................
1833 ....................
1834 .................... #endif
1835 ....................
1836 ....................
1837 .................... div_t div(signed int numer,signed int denom)
1838 .................... {
1839 .................... div_t val;
1840 .................... val.quot = numer / denom;
1841 .................... val.rem = numer - (denom * val.quot);
1842 .................... return (val);
1843 .................... }
1844 ....................
1845 .................... ldiv_t ldiv(signed long numer,signed long denom)
1846 .................... {
1847 .................... ldiv_t val;
1848 .................... val.quot = numer / denom;
1849 .................... val.rem = numer - (denom * val.quot);
1850 .................... return (val);
1851 .................... }
1852 ....................
1853 .................... float atof(char * s)
1854 .................... {
1855 .................... float pow10 = 1.0;
1856 .................... float result = 0.0;
1857 .................... int sign = 0;
1858 .................... char c;
1859 .................... int ptr = 0;
1860 ....................
1861 .................... c = s[ptr++];
1862 ....................
1863 .................... if ((c>='0' && c<='9') || c=='+' || c=='-' || c=='.') {
1864 .................... if(c == '-') {
1865 .................... sign = 1;
1866 .................... c = s[ptr++];
1867 .................... }
1868 .................... if(c == '+')
1869 .................... c = s[ptr++];
1870 ....................
1871 .................... while((c >= '0' && c <= '9')) {
1872 .................... result = 10*result + c - '0';
1873 .................... c = s[ptr++];
1874 .................... }
1875 ....................
1876 .................... if (c == '.') {
1877 .................... c = s[ptr++];
1878 .................... while((c >= '0' && c <= '9')) {
1879 .................... pow10 = pow10*10;
1880 .................... result += (c - '0')/pow10;
1881 .................... c = s[ptr++];
1882 .................... }
1883 .................... }
1884 ....................
1885 .................... }
1886 ....................
1887 .................... if (sign == 1)
1888 .................... result = -1*result;
1889 .................... return(result);
1890 .................... }
1891 ....................
1892 .................... float atoe(char * s)
1893 .................... {
1894 .................... float pow10 = 1.0;
1895 .................... float result = 0.0;
1896 .................... int sign = 0;
1897 .................... int expsign = 0;
1898 .................... char c;
1899 .................... int ptr = 0;
1900 .................... int i;
1901 .................... float exp = 1.0;
1902 .................... int expcnt = 0;
1903 ....................
1904 .................... c = s[ptr++];
1905 ....................
1906 .................... if ((c>='0' && c<='9') || c=='+' || c=='-' || c=='.' || c=='E' || c=='e') {
1907 .................... if(c == '-') {
1908 .................... sign = 1;
1909 .................... c = s[ptr++];
1910 .................... }
1911 .................... if(c == '+')
1912 .................... c = s[ptr++];
1913 ....................
1914 .................... while((c >= '0' && c <= '9')) {
1915 .................... result = 10*result + c - '0';
1916 .................... c = s[ptr++];
1917 .................... }
1918 ....................
1919 .................... if (c == '.') {
1920 .................... c = s[ptr++];
1921 .................... while((c >= '0' && c <= '9')) {
1922 .................... pow10 = pow10*10;
1923 .................... result += (c - '0')/pow10;
1924 .................... c = s[ptr++];
1925 .................... }
1926 .................... }
1927 ....................
1928 .................... // Handling the exponent
1929 .................... if (c=='e' || c=='E') {
1930 .................... c = s[ptr++];
1931 ....................
1932 .................... if(c == '-') {
1933 .................... expsign = 1;
1934 .................... c = s[ptr++];
1935 .................... }
1936 .................... if(c == '+')
1937 .................... c = s[ptr++];
1938 ....................
1939 .................... while((c >= '0' && c <= '9')) {
1940 .................... expcnt = 10*expcnt + c - '0';
1941 .................... c = s[ptr++];
1942 .................... }
1943 ....................
1944 .................... for(i=0;i<expcnt;i++)
1945 .................... exp*=10;
1946 ....................
1947 .................... if(expsign==1)
1948 .................... result/=exp;
1949 .................... else
1950 .................... result*=exp;
1951 .................... }
1952 .................... }
1953 ....................
1954 .................... if (sign == 1)
1955 .................... result = -1*result;
1956 .................... return(result);
1957 .................... }
1958 ....................
1959 .................... signed int atoi(char *s)
1960 .................... {
1961 .................... signed int result;
1962 .................... int sign, base, index;
1963 .................... char c;
1964 ....................
1965 .................... index = 0;
1966 .................... sign = 0;
1967 .................... base = 10;
1968 .................... result = 0;
1969 ....................
1970 .................... if (!s)
1971 .................... return 0;
1972 .................... // Omit all preceeding alpha characters
1973 .................... c = s[index++];
1974 ....................
1975 .................... // increase index if either positive or negative sign is detected
1976 .................... if (c == '-')
223 kapl 1977 .................... {
240 kaklik 1978 .................... sign = 1; // Set the sign to negative
1979 .................... c = s[index++];
239 kaklik 1980 .................... }
240 kaklik 1981 .................... else if (c == '+')
1982 .................... {
1983 .................... c = s[index++];
1984 .................... }
1985 ....................
1986 .................... if (c >= '0' && c <= '9')
1987 .................... {
1988 ....................
1989 .................... // Check for hexa number
1990 .................... if (c == '0' && (s[index] == 'x' || s[index] == 'X'))
1991 .................... {
1992 .................... base = 16;
1993 .................... index++;
1994 .................... c = s[index++];
1995 .................... }
1996 ....................
1997 .................... // The number is a decimal number
1998 .................... if (base == 10)
1999 .................... {
2000 .................... while (c >= '0' && c <= '9')
2001 .................... {
2002 .................... result = 10*result + (c - '0');
2003 .................... c = s[index++];
2004 .................... }
2005 .................... }
2006 .................... else if (base == 16) // The number is a hexa number
2007 .................... {
2008 .................... c = toupper(c);
2009 .................... while ( (c >= '0' && c <= '9') || (c >= 'A' && c<='F'))
2010 .................... {
2011 .................... if (c >= '0' && c <= '9')
2012 .................... result = (result << 4) + (c - '0');
2013 .................... else
2014 .................... result = (result << 4) + (c - 'A' + 10);
2015 ....................
2016 .................... c = s[index++];
2017 .................... c = toupper(c);
2018 .................... }
2019 .................... }
2020 .................... }
2021 ....................
2022 .................... if (sign == 1 && base == 10)
2023 .................... result = -result;
2024 ....................
2025 .................... return(result);
2026 .................... }
2027 ....................
2028 .................... signed long atol(char *s)
2029 .................... {
2030 .................... signed long result;
2031 .................... int sign, base, index;
2032 .................... char c;
2033 ....................
2034 .................... index = 0;
2035 .................... sign = 0;
2036 .................... base = 10;
2037 .................... result = 0;
2038 ....................
2039 .................... if (!s)
2040 .................... return 0;
2041 .................... c = s[index++];
2042 ....................
2043 .................... // increase index if either positive or negative sign is detected
2044 .................... if (c == '-')
2045 .................... {
2046 .................... sign = 1; // Set the sign to negative
2047 .................... c = s[index++];
2048 .................... }
2049 .................... else if (c == '+')
2050 .................... {
2051 .................... c = s[index++];
2052 .................... }
2053 ....................
2054 .................... if (c >= '0' && c <= '9')
2055 .................... {
2056 .................... if (c == '0' && (s[index] == 'x' || s[index] == 'X'))
2057 .................... {
2058 .................... base = 16;
2059 .................... index++;
2060 .................... c = s[index++];
2061 .................... }
2062 ....................
2063 .................... // The number is a decimal number
2064 .................... if (base == 10)
2065 .................... {
2066 .................... while (c >= '0' && c <= '9')
2067 .................... {
2068 .................... result = 10*result + (c - '0');
2069 .................... c = s[index++];
2070 .................... }
2071 .................... }
2072 .................... else if (base == 16) // The number is a hexa number
2073 .................... {
2074 .................... c = toupper(c);
2075 .................... while ( (c >= '0' && c <= '9') || (c >= 'A' && c <='F'))
2076 .................... {
2077 .................... if (c >= '0' && c <= '9')
2078 .................... result = (result << 4) + (c - '0');
2079 .................... else
2080 .................... result = (result << 4) + (c - 'A' + 10);
2081 ....................
2082 .................... c = s[index++];c = toupper(c);
2083 .................... }
2084 .................... }
2085 .................... }
2086 ....................
2087 .................... if (base == 10 && sign == 1)
2088 .................... result = -result;
2089 ....................
2090 .................... return(result);
2091 .................... }
2092 ....................
2093 .................... /* A fast routine to multiply by 10
2094 .................... */
2095 .................... signed int32 mult_with10(int32 num)
2096 .................... {
2097 .................... return ( (num << 1) + (num << 3) );
2098 .................... }
2099 ....................
2100 .................... signed int32 atoi32(char *s)
2101 .................... {
2102 .................... signed int32 result;
2103 .................... int sign, base, index;
2104 .................... char c;
2105 ....................
2106 .................... index = 0;
2107 .................... sign = 0;
2108 .................... base = 10;
2109 .................... result = 0;
2110 ....................
2111 .................... if (!s)
2112 .................... return 0;
2113 .................... c = s[index++];
2114 ....................
2115 .................... // increase index if either positive or negative sign is detected
2116 .................... if (c == '-')
2117 .................... {
2118 .................... sign = 1; // Set the sign to negative
2119 .................... c = s[index++];
2120 .................... }
2121 .................... else if (c == '+')
2122 .................... {
2123 .................... c = s[index++];
2124 .................... }
2125 ....................
2126 .................... if (c >= '0' && c <= '9')
2127 .................... {
2128 .................... if (c == '0' && (s[index] == 'x' || s[index] == 'X'))
2129 .................... {
2130 .................... base = 16;
2131 .................... index++;
2132 .................... c = s[index++];
2133 .................... }
2134 ....................
2135 .................... // The number is a decimal number
2136 .................... if (base == 10)
2137 .................... {
2138 .................... while (c >= '0' && c <= '9') {
2139 .................... result = (result << 1) + (result << 3); // result *= 10;
2140 .................... result += (c - '0');
2141 .................... c = s[index++];
2142 .................... }
2143 .................... }
2144 .................... else if (base == 16) // The number is a hexa number
2145 .................... {
2146 .................... c = toupper(c);
2147 .................... while ((c >= '0' && c <= '9') || (c >= 'A' && c <='F'))
2148 .................... {
2149 .................... if (c >= '0' && c <= '9')
2150 .................... result = (result << 4) + (c - '0');
2151 .................... else
2152 .................... result = (result << 4) + (c - 'A' + 10);
2153 ....................
2154 .................... c = s[index++];c = toupper(c);
2155 .................... }
2156 .................... }
2157 .................... }
2158 ....................
2159 .................... if (base == 10 && sign == 1)
2160 .................... result = -result;
2161 ....................
2162 .................... return(result);
2163 .................... }
2164 ....................
2165 .................... char * itoa(signed int32 num, int8 base, char *s)
2166 .................... {
2167 .................... int32 temp=1;
2168 .................... int8 i,sign=0,cnt=0;
2169 .................... char c;
2170 ....................
2171 .................... if(num<0) {
2172 .................... sign=1; // Check for negative number
2173 .................... num*=-1;
2174 .................... }
2175 ....................
2176 .................... while(temp>0) {
2177 .................... temp=(num/base);
2178 .................... s[cnt]=(num%base)+'0'; // Conversion
2179 ....................
2180 .................... if(s[cnt]>0x39)
2181 .................... s[cnt]+=0x7;
2182 ....................
2183 .................... cnt++;
2184 .................... num=temp;
2185 .................... }
2186 ....................
2187 .................... if(sign==1) {
2188 .................... s[cnt]=0x2D; // Negative sign
2189 .................... cnt++;
2190 .................... }
2191 ....................
2192 .................... for(i = 0;i<(int8)(cnt/2);i++) {
2193 ....................
2194 .................... c=s[i];
2195 .................... s[i]=s[cnt-i-1]; // Reverse the number
2196 .................... s[cnt-i-1]=c;
2197 .................... }
2198 .................... s[cnt]='\0'; // End the string
2199 .................... return s;
2200 .................... }
2201 ....................
2202 .................... float strtod(char *s,char *endptr) {
2203 .................... float pow10 = 1.0;
2204 .................... float result = 0.0;
2205 .................... int sign = 0, point = 0;
2206 .................... char c;
2207 .................... int ptr = 0;
2208 ....................
2209 .................... if (!s)
2210 .................... return 0;
2211 .................... c=s[ptr++];
2212 ....................
2213 ....................
2214 .................... while((c>='0' && c<='9') || c=='+' || c=='-' || c=='.') {
2215 .................... if(c == '-') {
2216 .................... sign = 1;
2217 .................... c = s[ptr++];
2218 .................... }
2219 ....................
2220 .................... while((c >= '0' && c <= '9') && point == 0) {
2221 .................... result = 10*result + c - '0';
2222 .................... c = s[ptr++];
2223 .................... }
2224 ....................
2225 .................... if (c == '.') {
2226 .................... point = 1;
2227 .................... c = s[ptr++];
2228 .................... }
2229 ....................
2230 .................... while((c >= '0' && c <= '9') && point == 1) {
2231 .................... pow10 = pow10*10;
2232 .................... result += (c - '0')/pow10;
2233 .................... c = s[ptr++];
2234 .................... }
2235 ....................
2236 .................... if (c == '+') {
2237 .................... c = s[ptr++];
2238 .................... }
2239 .................... }
2240 ....................
2241 .................... if (sign == 1)
2242 .................... result = -1*result;
2243 .................... if(endptr)
2244 .................... {
2245 .................... if (ptr) {
2246 .................... ptr--;
2247 .................... *((char *)endptr)=s+ptr;
2248 .................... }
2249 .................... else
2250 .................... *((char *)endptr)=s;
2251 .................... }
2252 ....................
2253 .................... return(result);
2254 .................... }
2255 ....................
2256 .................... long strtoul(char *s,char *endptr,signed int base)
2257 .................... {
2258 .................... char *sc,*s1,*sd;
2259 .................... unsigned long x=0;
245 kaklik 2260 *
246 kaklik 2261 03D2: CLRF 57
2262 03D3: CLRF 58
240 kaklik 2263 .................... char sign;
2264 .................... char digits[]="0123456789abcdefghijklmnopqstuvwxyz";
246 kaklik 2265 03D4: MOVLW 30
2266 03D5: BSF 03.5
2267 03D6: MOVWF 20
2268 03D7: MOVLW 31
2269 03D8: MOVWF 21
2270 03D9: MOVLW 32
2271 03DA: MOVWF 22
2272 03DB: MOVLW 33
2273 03DC: MOVWF 23
2274 03DD: MOVLW 34
2275 03DE: MOVWF 24
2276 03DF: MOVLW 35
2277 03E0: MOVWF 25
2278 03E1: MOVLW 36
2279 03E2: MOVWF 26
2280 03E3: MOVLW 37
2281 03E4: MOVWF 27
2282 03E5: MOVLW 38
2283 03E6: MOVWF 28
2284 03E7: MOVLW 39
2285 03E8: MOVWF 29
2286 03E9: MOVLW 61
2287 03EA: MOVWF 2A
2288 03EB: MOVLW 62
2289 03EC: MOVWF 2B
2290 03ED: MOVLW 63
2291 03EE: MOVWF 2C
2292 03EF: MOVLW 64
2293 03F0: MOVWF 2D
2294 03F1: MOVLW 65
2295 03F2: MOVWF 2E
2296 03F3: MOVLW 66
2297 03F4: MOVWF 2F
2298 03F5: MOVLW 67
2299 03F6: MOVWF 30
2300 03F7: MOVLW 68
2301 03F8: MOVWF 31
2302 03F9: MOVLW 69
2303 03FA: MOVWF 32
2304 03FB: MOVLW 6A
2305 03FC: MOVWF 33
2306 03FD: MOVLW 6B
2307 03FE: MOVWF 34
2308 03FF: MOVLW 6C
2309 0400: MOVWF 35
2310 0401: MOVLW 6D
2311 0402: MOVWF 36
2312 0403: MOVLW 6E
2313 0404: MOVWF 37
2314 0405: MOVLW 6F
2315 0406: MOVWF 38
2316 0407: MOVLW 70
2317 0408: MOVWF 39
2318 0409: MOVLW 71
2319 040A: MOVWF 3A
2320 040B: MOVLW 73
2321 040C: MOVWF 3B
2322 040D: MOVLW 74
2323 040E: MOVWF 3C
2324 040F: MOVLW 75
2325 0410: MOVWF 3D
2326 0411: MOVLW 76
2327 0412: MOVWF 3E
2328 0413: MOVLW 77
2329 0414: MOVWF 3F
2330 0415: MOVLW 78
2331 0416: MOVWF 40
2332 0417: MOVLW 79
2333 0418: MOVWF 41
2334 0419: MOVLW 7A
2335 041A: MOVWF 42
2336 041B: CLRF 43
240 kaklik 2337 .................... for(sc=s;isspace(*sc);++sc);
246 kaklik 2338 041C: BCF 03.5
2339 041D: MOVF 51,W
2340 041E: MOVWF 54
2341 041F: MOVF 54,W
2342 0420: MOVWF 04
2343 0421: MOVF 00,W
2344 0422: SUBLW 20
2345 0423: BTFSS 03.2
2346 0424: GOTO 427
2347 0425: INCF 54,F
2348 0426: GOTO 41F
240 kaklik 2349 .................... sign=*sc=='-'||*sc=='+'?*sc++:'+';
246 kaklik 2350 0427: MOVF 54,W
2351 0428: MOVWF 04
2352 0429: MOVF 00,W
2353 042A: SUBLW 2D
2354 042B: BTFSC 03.2
2355 042C: GOTO 433
2356 042D: MOVF 54,W
2357 042E: MOVWF 04
2358 042F: MOVF 00,W
2359 0430: SUBLW 2B
2360 0431: BTFSS 03.2
2361 0432: GOTO 438
2362 0433: MOVF 54,W
2363 0434: INCF 54,F
2364 0435: MOVWF 04
2365 0436: MOVF 00,W
2366 0437: GOTO 439
2367 0438: MOVLW 2B
2368 0439: MOVWF 59
240 kaklik 2369 .................... if(sign=='-')
246 kaklik 2370 043A: MOVF 59,W
2371 043B: SUBLW 2D
2372 043C: BTFSS 03.2
2373 043D: GOTO 449
240 kaklik 2374 .................... {
2375 .................... if (endptr)
246 kaklik 2376 043E: MOVF 52,F
2377 043F: BTFSC 03.2
2378 0440: GOTO 445
240 kaklik 2379 .................... {
2380 .................... *((char *)endptr)=s;
246 kaklik 2381 0441: MOVF 52,W
2382 0442: MOVWF 04
2383 0443: MOVF 51,W
2384 0444: MOVWF 00
240 kaklik 2385 .................... }
2386 .................... return 0;
246 kaklik 2387 0445: MOVLW 00
2388 0446: MOVWF 78
2389 0447: MOVWF 79
2390 0448: GOTO 555
240 kaklik 2391 .................... }
2392 ....................
2393 .................... if (base <0 || base ==1|| base >36) // invalid base
246 kaklik 2394 0449: BTFSC 53.7
2395 044A: GOTO 454
2396 044B: DECFSZ 53,W
2397 044C: GOTO 44E
2398 044D: GOTO 454
2399 044E: BTFSC 53.7
2400 044F: GOTO 460
2401 0450: MOVF 53,W
2402 0451: SUBLW 24
2403 0452: BTFSC 03.0
2404 0453: GOTO 460
240 kaklik 2405 .................... {
2406 .................... if (endptr)
246 kaklik 2407 0454: MOVF 52,F
2408 0455: BTFSC 03.2
2409 0456: GOTO 45B
240 kaklik 2410 .................... {
2411 .................... *((char *)endptr)=s;
246 kaklik 2412 0457: MOVF 52,W
2413 0458: MOVWF 04
2414 0459: MOVF 51,W
2415 045A: MOVWF 00
240 kaklik 2416 .................... }
2417 .................... return 0;
246 kaklik 2418 045B: MOVLW 00
2419 045C: MOVWF 78
2420 045D: MOVWF 79
2421 045E: GOTO 555
240 kaklik 2422 .................... }
2423 .................... else if (base)
246 kaklik 2424 045F: GOTO 4C6
2425 0460: MOVF 53,F
2426 0461: BTFSC 03.2
2427 0462: GOTO 49D
240 kaklik 2428 .................... {
2429 .................... if(base==16 && *sc =='0'&&(sc[1]=='x' || sc[1]=='X'))
246 kaklik 2430 0463: MOVF 53,W
2431 0464: SUBLW 10
2432 0465: BTFSS 03.2
2433 0466: GOTO 47D
2434 0467: MOVF 54,W
2435 0468: MOVWF 04
2436 0469: MOVF 00,W
2437 046A: SUBLW 30
2438 046B: BTFSS 03.2
2439 046C: GOTO 47D
2440 046D: MOVLW 01
2441 046E: ADDWF 54,W
2442 046F: MOVWF 04
2443 0470: MOVF 00,W
2444 0471: SUBLW 78
2445 0472: BTFSC 03.2
2446 0473: GOTO 47B
2447 0474: MOVLW 01
2448 0475: ADDWF 54,W
2449 0476: MOVWF 04
2450 0477: MOVF 00,W
2451 0478: SUBLW 58
2452 0479: BTFSS 03.2
2453 047A: GOTO 47D
240 kaklik 2454 .................... sc+=2;
246 kaklik 2455 047B: MOVLW 02
2456 047C: ADDWF 54,F
240 kaklik 2457 .................... if(base==8 && *sc =='0')
246 kaklik 2458 047D: MOVF 53,W
2459 047E: SUBLW 08
2460 047F: BTFSS 03.2
2461 0480: GOTO 489
2462 0481: MOVF 54,W
2463 0482: MOVWF 04
2464 0483: MOVF 00,W
2465 0484: SUBLW 30
2466 0485: BTFSS 03.2
2467 0486: GOTO 489
240 kaklik 2468 .................... sc+=1;
246 kaklik 2469 0487: MOVLW 01
2470 0488: ADDWF 54,F
240 kaklik 2471 .................... if(base==2 && *sc =='0'&&sc[1]=='b')
246 kaklik 2472 0489: MOVF 53,W
2473 048A: SUBLW 02
2474 048B: BTFSS 03.2
2475 048C: GOTO 49C
2476 048D: MOVF 54,W
2477 048E: MOVWF 04
2478 048F: MOVF 00,W
2479 0490: SUBLW 30
2480 0491: BTFSS 03.2
2481 0492: GOTO 49C
2482 0493: MOVLW 01
2483 0494: ADDWF 54,W
2484 0495: MOVWF 04
2485 0496: MOVF 00,W
2486 0497: SUBLW 62
2487 0498: BTFSS 03.2
2488 0499: GOTO 49C
240 kaklik 2489 .................... sc+=2;
246 kaklik 2490 049A: MOVLW 02
2491 049B: ADDWF 54,F
240 kaklik 2492 ....................
2493 .................... }
2494 .................... else if(*sc!='0') // base is 0, find base
246 kaklik 2495 049C: GOTO 4C6
2496 049D: MOVF 54,W
2497 049E: MOVWF 04
2498 049F: MOVF 00,W
2499 04A0: SUBLW 30
2500 04A1: BTFSC 03.2
2501 04A2: GOTO 4A6
240 kaklik 2502 .................... base=10;
246 kaklik 2503 04A3: MOVLW 0A
2504 04A4: MOVWF 53
240 kaklik 2505 .................... else if (sc[1]=='x' || sc[1]=='X')
246 kaklik 2506 04A5: GOTO 4C6
2507 04A6: MOVLW 01
2508 04A7: ADDWF 54,W
2509 04A8: MOVWF 04
2510 04A9: MOVF 00,W
2511 04AA: SUBLW 78
2512 04AB: BTFSC 03.2
2513 04AC: GOTO 4B4
2514 04AD: MOVLW 01
2515 04AE: ADDWF 54,W
2516 04AF: MOVWF 04
2517 04B0: MOVF 00,W
2518 04B1: SUBLW 58
2519 04B2: BTFSS 03.2
2520 04B3: GOTO 4B9
240 kaklik 2521 .................... base =16,sc+=2;
246 kaklik 2522 04B4: MOVLW 10
2523 04B5: MOVWF 53
2524 04B6: MOVLW 02
2525 04B7: ADDWF 54,F
240 kaklik 2526 .................... else if(sc[1]=='b')
246 kaklik 2527 04B8: GOTO 4C6
2528 04B9: MOVLW 01
2529 04BA: ADDWF 54,W
2530 04BB: MOVWF 04
2531 04BC: MOVF 00,W
2532 04BD: SUBLW 62
2533 04BE: BTFSS 03.2
2534 04BF: GOTO 4C4
240 kaklik 2535 .................... base=2,sc+=2;
246 kaklik 2536 04C0: MOVLW 02
2537 04C1: MOVWF 53
2538 04C2: ADDWF 54,F
239 kaklik 2539 .................... else
246 kaklik 2540 04C3: GOTO 4C6
240 kaklik 2541 .................... base=8;
246 kaklik 2542 04C4: MOVLW 08
2543 04C5: MOVWF 53
240 kaklik 2544 .................... for (s1=sc;*sc=='0';++sc);// skip leading zeroes
246 kaklik 2545 04C6: MOVF 54,W
2546 04C7: MOVWF 55
2547 04C8: MOVF 54,W
2548 04C9: MOVWF 04
2549 04CA: MOVF 00,W
2550 04CB: SUBLW 30
2551 04CC: BTFSS 03.2
2552 04CD: GOTO 4D0
2553 04CE: INCF 54,F
2554 04CF: GOTO 4C8
240 kaklik 2555 .................... sd=memchr(digits,tolower(*sc),base);
246 kaklik 2556 04D0: MOVF 54,W
2557 04D1: MOVWF 04
2558 04D2: MOVF 00,W
2559 04D3: MOVWF 5A
2560 04D4: SUBLW 40
2561 04D5: BTFSC 03.0
2562 04D6: GOTO 4DE
2563 04D7: MOVF 5A,W
2564 04D8: SUBLW 5A
2565 04D9: BTFSS 03.0
2566 04DA: GOTO 4DE
2567 04DB: MOVF 5A,W
2568 04DC: IORLW 20
2569 04DD: GOTO 4DF
2570 04DE: MOVF 5A,W
2571 04DF: MOVWF 5B
2572 04E0: MOVLW A0
2573 04E1: BSF 03.5
2574 04E2: MOVWF 46
2575 04E3: BCF 03.5
2576 04E4: MOVF 5A,W
2577 04E5: BSF 03.5
2578 04E6: MOVWF 47
2579 04E7: BCF 03.5
2580 04E8: MOVF 53,W
2581 04E9: BSF 03.5
2582 04EA: MOVWF 48
2583 04EB: BCF 03.5
2584 04EC: CALL 3A0
2585 04ED: MOVF 78,W
2586 04EE: MOVWF 56
240 kaklik 2587 .................... for(; sd!=0; )
246 kaklik 2588 04EF: MOVF 56,F
2589 04F0: BTFSC 03.2
2590 04F1: GOTO 53B
223 kapl 2591 .................... {
240 kaklik 2592 .................... x=x*base+(int16)(sd-digits);
246 kaklik 2593 04F2: CLRF 7A
2594 04F3: MOVF 53,W
2595 04F4: MOVWF 77
2596 04F5: BTFSC 53.7
2597 04F6: DECF 7A,F
2598 04F7: MOVWF 5A
2599 04F8: MOVF 7A,W
2600 04F9: MOVWF 5B
2601 04FA: MOVF 58,W
2602 04FB: BSF 03.5
2603 04FC: MOVWF 47
2604 04FD: BCF 03.5
2605 04FE: MOVF 57,W
2606 04FF: BSF 03.5
2607 0500: MOVWF 46
2608 0501: BCF 03.5
2609 0502: MOVF 7A,W
2610 0503: BSF 03.5
2611 0504: MOVWF 49
2612 0505: BCF 03.5
2613 0506: MOVF 5A,W
2614 0507: BSF 03.5
2615 0508: MOVWF 48
2616 0509: BCF 03.5
2617 050A: GOTO 3B9
2618 050B: MOVF 78,W
2619 050C: MOVWF 5B
2620 050D: MOVLW A0
2621 050E: SUBWF 56,W
2622 050F: CLRF 7A
2623 0510: ADDWF 78,W
2624 0511: MOVWF 78
2625 0512: BTFSC 03.0
2626 0513: INCF 7A,F
2627 0514: MOVF 79,W
2628 0515: ADDWF 7A,F
2629 0516: MOVF 78,W
2630 0517: MOVWF 57
2631 0518: MOVF 7A,W
2632 0519: MOVWF 58
240 kaklik 2633 .................... ++sc;
246 kaklik 2634 051A: INCF 54,F
240 kaklik 2635 .................... sd=memchr(digits,tolower(*sc),base);
246 kaklik 2636 051B: MOVF 54,W
2637 051C: MOVWF 04
2638 051D: MOVF 00,W
2639 051E: MOVWF 5A
2640 051F: SUBLW 40
2641 0520: BTFSC 03.0
2642 0521: GOTO 529
2643 0522: MOVF 5A,W
2644 0523: SUBLW 5A
2645 0524: BTFSS 03.0
2646 0525: GOTO 529
2647 0526: MOVF 5A,W
2648 0527: IORLW 20
2649 0528: GOTO 52A
2650 0529: MOVF 5A,W
2651 052A: MOVWF 5B
2652 052B: MOVLW A0
2653 052C: BSF 03.5
2654 052D: MOVWF 46
2655 052E: BCF 03.5
2656 052F: MOVF 5A,W
2657 0530: BSF 03.5
2658 0531: MOVWF 47
2659 0532: BCF 03.5
2660 0533: MOVF 53,W
2661 0534: BSF 03.5
2662 0535: MOVWF 48
2663 0536: BCF 03.5
2664 0537: CALL 3A0
2665 0538: MOVF 78,W
2666 0539: MOVWF 56
240 kaklik 2667 .................... }
246 kaklik 2668 053A: GOTO 4EF
240 kaklik 2669 .................... if(s1==sc)
246 kaklik 2670 053B: MOVF 54,W
2671 053C: SUBWF 55,W
2672 053D: BTFSS 03.2
2673 053E: GOTO 54A
240 kaklik 2674 .................... {
2675 .................... if (endptr)
246 kaklik 2676 053F: MOVF 52,F
2677 0540: BTFSC 03.2
2678 0541: GOTO 546
240 kaklik 2679 .................... {
2680 .................... *((char *)endptr)=s;
246 kaklik 2681 0542: MOVF 52,W
2682 0543: MOVWF 04
2683 0544: MOVF 51,W
2684 0545: MOVWF 00
240 kaklik 2685 .................... }
2686 .................... return 0;
246 kaklik 2687 0546: MOVLW 00
2688 0547: MOVWF 78
2689 0548: MOVWF 79
2690 0549: GOTO 555
240 kaklik 2691 .................... }
2692 .................... if (endptr)
246 kaklik 2693 054A: MOVF 52,F
2694 054B: BTFSC 03.2
2695 054C: GOTO 551
240 kaklik 2696 .................... *((char *)endptr)=sc;
246 kaklik 2697 054D: MOVF 52,W
2698 054E: MOVWF 04
2699 054F: MOVF 54,W
2700 0550: MOVWF 00
240 kaklik 2701 .................... return x;
246 kaklik 2702 0551: MOVF 57,W
2703 0552: MOVWF 78
2704 0553: MOVF 58,W
2705 0554: MOVWF 79
240 kaklik 2706 .................... }
246 kaklik 2707 0555: BSF 0A.3
2708 0556: BCF 0A.4
2709 0557: GOTO 503 (RETURN)
240 kaklik 2710 ....................
2711 ....................
2712 .................... signed long strtol(char *s,char *endptr,signed int base)
2713 .................... {
2714 .................... char *sc,*s1,*sd;
2715 .................... signed long x=0;
2716 .................... char sign;
2717 .................... char digits[]="0123456789abcdefghijklmnopqstuvwxyz";
2718 .................... for(sc=s;isspace(*sc);++sc);
2719 .................... sign=*sc=='-'||*sc=='+'?*sc++:'+';
2720 .................... if (base <0 || base ==1|| base >36) // invalid base
2721 .................... {
2722 .................... if (endptr)
2723 .................... {
2724 .................... *((char *)endptr)=s;
2725 .................... }
2726 .................... return 0;
2727 .................... }
2728 .................... else if (base)
2729 .................... {
2730 .................... if(base==16 && *sc =='0'&&(sc[1]=='x' || sc[1]=='X'))
2731 .................... sc+=2;
2732 .................... if(base==8 && *sc =='0')
2733 .................... sc+=1;
2734 .................... if(base==2 && *sc =='0'&&sc[1]=='b')
2735 .................... sc+=2;
2736 ....................
2737 .................... }
2738 .................... else if(*sc!='0') // base is 0, find base
2739 .................... base=10;
2740 .................... else if (sc[1]=='x' || sc[1]=='X')
2741 .................... base =16,sc+=2;
2742 .................... else if(sc[1]=='b')
2743 .................... base=2,sc+=2;
2744 .................... else
2745 .................... base=8;
2746 .................... for (s1=sc;*sc=='0';++sc);// skip leading zeroes
2747 ....................
2748 .................... sd=memchr(digits,tolower(*sc),base);
2749 .................... for(;sd!=0;)
2750 .................... {
2751 .................... x=x*base+(int16)(sd-digits);
2752 .................... ++sc;
2753 .................... sd=memchr(digits,tolower(*sc),base);
2754 .................... }
2755 .................... if(s1==sc)
2756 .................... {
2757 .................... if (endptr)
2758 .................... {
2759 .................... *((char *)endptr)=s;
2760 .................... }
2761 .................... return 0;
2762 .................... }
2763 .................... if(sign=='-')
2764 .................... x =-x;
2765 .................... if (endptr)
2766 .................... *((char *)endptr)=sc;
2767 .................... return x;
2768 .................... }
2769 ....................
2770 .................... signed int system(char *string)
2771 .................... {
2772 .................... return 0;
2773 .................... }
2774 ....................
2775 .................... int mblen(char *s,size_t n)
2776 .................... {
2777 .................... return strlen(s);
2778 .................... }
2779 ....................
2780 .................... int mbtowc(wchar_t *pwc,char *s,size_t n)
2781 .................... {
2782 .................... *pwc=*s;
2783 .................... return 1;
2784 .................... }
2785 ....................
2786 .................... int wctomb(char *s,wchar_t wchar)
2787 .................... {
2788 .................... *s=wchar;
2789 .................... return 1;
2790 .................... }
2791 ....................
2792 .................... size_t mbstowcs(wchar_t *pwcs,char *s,size_t n)
2793 .................... {
2794 .................... strncpy(pwcs,s,n);
2795 .................... return strlen(pwcs);
2796 .................... }
2797 ....................
2798 .................... size_t wcstombs(char *s,wchar_t *pwcs,size_t n)
2799 .................... {
2800 .................... strncpy(s,pwcs,n);
2801 .................... return strlen(s);
2802 .................... }
2803 ....................
2804 .................... //---------------------------------------------------------------------------
2805 .................... // The random number implementation
2806 .................... //---------------------------------------------------------------------------
2807 ....................
2808 .................... unsigned int32 _Randseed = 1;
245 kaklik 2809 *
246 kaklik 2810 0818: MOVLW 01
2811 0819: MOVWF 22
2812 081A: CLRF 23
2813 081B: CLRF 24
2814 081C: CLRF 25
240 kaklik 2815 ....................
2816 .................... long rand(void)
2817 .................... {
2818 .................... _Randseed = _Randseed * 1103515245 + 12345;
2819 .................... return ((unsigned long)(_Randseed >> 16) % RAND_MAX);
2820 .................... }
2821 ....................
2822 .................... void srand(unsigned int32 seed)
2823 .................... {
2824 .................... _Randseed = seed;
2825 .................... }
2826 ....................
2827 .................... //---------------------------------------------------------------------------
2828 .................... // Searching and sorting utilities implementation
2829 .................... //---------------------------------------------------------------------------
2830 ....................
2831 .................... typedef signed int (*_Cmpfun)(char * p1,char * p2);
2832 ....................
2833 .................... void qsort(char * qdata, int qitems, int qsize, _Cmpfun cmp) {
2834 .................... int m,j,i,l;
2835 .................... short done;
2836 .................... BYTE t[16];
2837 ....................
2838 .................... m = qitems/2;
2839 .................... while( m > 0 ) {
2840 .................... for(j=0; j<(qitems-m); ++j) {
2841 .................... i = j;
2842 .................... do
2843 .................... {
2844 .................... done=TRUE;
2845 .................... l = i+m;
2846 .................... if( (*cmp)(qdata+i*qsize, qdata+l*qsize) > 0 ) {
2847 .................... memcpy(t, qdata+i*qsize, qsize);
2848 .................... memcpy(qdata+i*qsize, qdata+l*qsize, qsize);
2849 .................... memcpy(qdata+l*qsize, t, qsize);
2850 .................... if(m <= i)
2851 .................... i -= m;
2852 .................... done = FALSE;
2853 .................... }
2854 .................... } while(!done);
2855 .................... }
2856 .................... m = m/2;
2857 .................... }
2858 .................... }
2859 ....................
2860 ....................
2861 .................... char *bsearch(char *key, char *base, size_t num, size_t width,_Cmpfun cmp)
2862 .................... {
2863 .................... char *p, *q;
2864 .................... size_t n;
2865 .................... size_t pivot;
2866 .................... signed int val;
2867 ....................
2868 .................... p = base;
2869 .................... n = num;
2870 ....................
2871 .................... while (n > 0)
2872 .................... {
2873 .................... pivot = n >> 1;
2874 .................... q = p + width * pivot;
2875 ....................
2876 .................... val = (*cmp)(key, q);
2877 ....................
2878 .................... if (val < 0)
2879 .................... n = pivot;
2880 .................... else if (val == 0)
2881 .................... return ((char *)q);
2882 .................... else {
2883 .................... p = q + width;
2884 .................... n -= pivot + 1;
2885 .................... }
2886 .................... }
2887 ....................
2888 .................... return NULL; // There's no match
2889 .................... }
2890 ....................
2891 ....................
2892 .................... #endif
2893 ....................
2894 ....................
2895 .................... #define DELKA 40
246 kaklik 2896 .................... #define VYKON 100
240 kaklik 2897 ....................
2898 .................... char odp[DELKA];
2899 ....................
2900 .................... int1 check_new_sms()
2901 .................... {
246 kaklik 2902 .................... fprintf(MOBIL,"AT+CMGL=0\r"); //vycti prijate SMS (0=nove;1=vsechny)
245 kaklik 2903 *
246 kaklik 2904 022E: CLRF 51
2905 022F: MOVF 51,W
2906 0230: CALL 004
2907 0231: IORLW 00
2908 0232: BTFSC 03.2
2909 0233: GOTO 238
2910 0234: INCF 51,F
2911 0235: MOVWF 53
2912 0236: CALL 1DE
2913 0237: GOTO 22F
240 kaklik 2914 .................... while(fgetc(MOBIL)!=0x0A); // predkoc prvni radek odpovedi
246 kaklik 2915 0238: CALL 206
2916 0239: MOVF 78,W
2917 023A: SUBLW 0A
2918 023B: BTFSS 03.2
2919 023C: GOTO 238
240 kaklik 2920 .................... odp[0]=fgetc(MOBIL); // Nacti prvni dva znaky druheho radku odpovedi
246 kaklik 2921 023D: CALL 206
2922 023E: MOVF 78,W
2923 023F: MOVWF 26
240 kaklik 2924 .................... odp[1]=fgetc(MOBIL);
246 kaklik 2925 0240: CALL 206
2926 0241: MOVF 78,W
2927 0242: MOVWF 27
240 kaklik 2928 .................... while(fgetc(MOBIL)!=0x0A); // Preskoc zbytek radku
246 kaklik 2929 0243: CALL 206
2930 0244: MOVF 78,W
2931 0245: SUBLW 0A
2932 0246: BTFSS 03.2
2933 0247: GOTO 243
240 kaklik 2934 ....................
2935 .................... if(odp[0] == 'O' && odp[1] == 'K') return 1;
246 kaklik 2936 0248: MOVF 26,W
2937 0249: SUBLW 4F
2938 024A: BTFSS 03.2
2939 024B: GOTO 254
2940 024C: MOVF 27,W
2941 024D: SUBLW 4B
2942 024E: BTFSS 03.2
2943 024F: GOTO 254
2944 0250: MOVLW 01
2945 0251: MOVWF 78
2946 0252: GOTO 257
240 kaklik 2947 .................... else return 0;
246 kaklik 2948 0253: GOTO 257
2949 0254: MOVLW 00
2950 0255: MOVWF 78
2951 0256: GOTO 257
240 kaklik 2952 .................... }
246 kaklik 2953 0257: BSF 0A.3
2954 0258: BCF 0A.4
2955 0259: GOTO 0A1 (RETURN)
240 kaklik 2956 ....................
2957 .................... read_sms()
2958 .................... {
2959 .................... int pom,pom2,pom3,odkl,odkl2,maskovadlo;
238 kaklik 2960 .................... for(pom=0;pom<54;pom++) //preskoc nedulezite informace
246 kaklik 2961 025A: CLRF 51
2962 025B: MOVF 51,W
2963 025C: SUBLW 35
2964 025D: BTFSS 03.0
2965 025E: GOTO 262
223 kapl 2966 .................... {
238 kaklik 2967 .................... fgetc(MOBIL);
246 kaklik 2968 025F: CALL 206
239 kaklik 2969 .................... }
246 kaklik 2970 0260: INCF 51,F
2971 0261: GOTO 25B
239 kaklik 2972 ....................
223 kapl 2973 .................... //gets(odp); //uloz zakodovany text SMS
239 kaklik 2974 ....................
238 kaklik 2975 .................... odp[0]=fgetc(MOBIL);
246 kaklik 2976 0262: CALL 206
2977 0263: MOVF 78,W
2978 0264: MOVWF 26
238 kaklik 2979 .................... odp[1]=fgetc(MOBIL);
246 kaklik 2980 0265: CALL 206
2981 0266: MOVF 78,W
2982 0267: MOVWF 27
238 kaklik 2983 .................... odp[2]=fgetc(MOBIL);
246 kaklik 2984 0268: CALL 206
2985 0269: MOVF 78,W
2986 026A: MOVWF 28
238 kaklik 2987 .................... odp[3]=fgetc(MOBIL);
246 kaklik 2988 026B: CALL 206
2989 026C: MOVF 78,W
2990 026D: MOVWF 29
238 kaklik 2991 .................... odp[4]=fgetc(MOBIL);
246 kaklik 2992 026E: CALL 206
2993 026F: MOVF 78,W
2994 0270: MOVWF 2A
238 kaklik 2995 .................... odp[5]=fgetc(MOBIL);
246 kaklik 2996 0271: CALL 206
2997 0272: MOVF 78,W
2998 0273: MOVWF 2B
238 kaklik 2999 .................... odp[6]=fgetc(MOBIL);
246 kaklik 3000 0274: CALL 206
3001 0275: MOVF 78,W
3002 0276: MOVWF 2C
238 kaklik 3003 .................... odp[7]=fgetc(MOBIL);
246 kaklik 3004 0277: CALL 206
3005 0278: MOVF 78,W
3006 0279: MOVWF 2D
238 kaklik 3007 ....................
223 kapl 3008 .................... /*lcd_gotoxy(1,1);
3009 .................... printf(lcd_putc,"\f%s\n",odp);*/
239 kaklik 3010 ....................
3011 .................... if(odp[0]==0) odp[1]='0'; // Prevod z ASCII do BIN
246 kaklik 3012 027A: MOVF 26,F
3013 027B: BTFSS 03.2
3014 027C: GOTO 27F
3015 027D: MOVLW 30
3016 027E: MOVWF 27
223 kapl 3017 .................... odp[0]=odp[0] - '0';
246 kaklik 3018 027F: MOVLW 30
3019 0280: SUBWF 26,F
223 kapl 3020 .................... odp[1]=odp[1] - '0';
246 kaklik 3021 0281: SUBWF 27,F
223 kapl 3022 .................... if(odp[0]>9) odp[0]=odp[0]-7;
246 kaklik 3023 0282: MOVF 26,W
3024 0283: SUBLW 09
3025 0284: BTFSC 03.0
3026 0285: GOTO 288
3027 0286: MOVLW 07
3028 0287: SUBWF 26,F
223 kapl 3029 .................... if(odp[1]>9) odp[1]=odp[1]-7;
246 kaklik 3030 0288: MOVF 27,W
3031 0289: SUBLW 09
3032 028A: BTFSC 03.0
3033 028B: GOTO 28E
3034 028C: MOVLW 07
3035 028D: SUBWF 27,F
223 kapl 3036 .................... odp[0]=odp[0] << 4;
246 kaklik 3037 028E: SWAPF 26,F
3038 028F: MOVLW F0
3039 0290: ANDWF 26,F
223 kapl 3040 .................... odp[0] |= odp[1];
246 kaklik 3041 0291: MOVF 27,W
3042 0292: IORWF 26,F
239 kaklik 3043 ....................
223 kapl 3044 .................... if(odp[2]==0) odp[3]='0';
246 kaklik 3045 0293: MOVF 28,F
3046 0294: BTFSS 03.2
3047 0295: GOTO 298
3048 0296: MOVLW 30
3049 0297: MOVWF 29
223 kapl 3050 .................... odp[2]=odp[2] - '0';
246 kaklik 3051 0298: MOVLW 30
3052 0299: SUBWF 28,F
223 kapl 3053 .................... odp[3]=odp[3] - '0';
246 kaklik 3054 029A: SUBWF 29,F
223 kapl 3055 .................... if(odp[2]>9) odp[2]=odp[2]-7;
246 kaklik 3056 029B: MOVF 28,W
3057 029C: SUBLW 09
3058 029D: BTFSC 03.0
3059 029E: GOTO 2A1
3060 029F: MOVLW 07
3061 02A0: SUBWF 28,F
223 kapl 3062 .................... if(odp[3]>9) odp[3]=odp[3]-7;
246 kaklik 3063 02A1: MOVF 29,W
3064 02A2: SUBLW 09
3065 02A3: BTFSC 03.0
3066 02A4: GOTO 2A7
3067 02A5: MOVLW 07
3068 02A6: SUBWF 29,F
223 kapl 3069 .................... odp[2]=odp[2] << 4;
246 kaklik 3070 02A7: SWAPF 28,F
3071 02A8: MOVLW F0
3072 02A9: ANDWF 28,F
223 kapl 3073 .................... odp[2] |= odp[3];
246 kaklik 3074 02AA: MOVF 29,W
3075 02AB: IORWF 28,F
239 kaklik 3076 ....................
223 kapl 3077 .................... if(odp[4]==0) odp[5]='0';
246 kaklik 3078 02AC: MOVF 2A,F
3079 02AD: BTFSS 03.2
3080 02AE: GOTO 2B1
3081 02AF: MOVLW 30
3082 02B0: MOVWF 2B
223 kapl 3083 .................... odp[4]=odp[4] - '0';
246 kaklik 3084 02B1: MOVLW 30
3085 02B2: SUBWF 2A,F
223 kapl 3086 .................... odp[5]=odp[5] - '0';
246 kaklik 3087 02B3: SUBWF 2B,F
223 kapl 3088 .................... if(odp[4]>9) odp[4]=odp[4]-7;
246 kaklik 3089 02B4: MOVF 2A,W
3090 02B5: SUBLW 09
3091 02B6: BTFSC 03.0
3092 02B7: GOTO 2BA
3093 02B8: MOVLW 07
3094 02B9: SUBWF 2A,F
223 kapl 3095 .................... if(odp[5]>9) odp[5]=odp[5]-7;
246 kaklik 3096 02BA: MOVF 2B,W
3097 02BB: SUBLW 09
3098 02BC: BTFSC 03.0
3099 02BD: GOTO 2C0
3100 02BE: MOVLW 07
3101 02BF: SUBWF 2B,F
223 kapl 3102 .................... odp[4]=odp[4] << 4;
246 kaklik 3103 02C0: SWAPF 2A,F
3104 02C1: MOVLW F0
3105 02C2: ANDWF 2A,F
223 kapl 3106 .................... odp[4] |= odp[5];
246 kaklik 3107 02C3: MOVF 2B,W
3108 02C4: IORWF 2A,F
239 kaklik 3109 ....................
223 kapl 3110 .................... if(odp[6]==0) odp[7]='0';
246 kaklik 3111 02C5: MOVF 2C,F
3112 02C6: BTFSS 03.2
3113 02C7: GOTO 2CA
3114 02C8: MOVLW 30
3115 02C9: MOVWF 2D
223 kapl 3116 .................... odp[6]=odp[6] - '0';
246 kaklik 3117 02CA: MOVLW 30
3118 02CB: SUBWF 2C,F
223 kapl 3119 .................... odp[7]=odp[7] - '0';
246 kaklik 3120 02CC: SUBWF 2D,F
223 kapl 3121 .................... if(odp[6]>9) odp[6]=odp[6]-7;
246 kaklik 3122 02CD: MOVF 2C,W
3123 02CE: SUBLW 09
3124 02CF: BTFSC 03.0
3125 02D0: GOTO 2D3
3126 02D1: MOVLW 07
3127 02D2: SUBWF 2C,F
223 kapl 3128 .................... if(odp[7]>9) odp[7]=odp[7]-7;
246 kaklik 3129 02D3: MOVF 2D,W
3130 02D4: SUBLW 09
3131 02D5: BTFSC 03.0
3132 02D6: GOTO 2D9
3133 02D7: MOVLW 07
3134 02D8: SUBWF 2D,F
223 kapl 3135 .................... odp[6]=odp[6] << 4;
246 kaklik 3136 02D9: SWAPF 2C,F
3137 02DA: MOVLW F0
3138 02DB: ANDWF 2C,F
223 kapl 3139 .................... odp[6] |= odp[7];
246 kaklik 3140 02DC: MOVF 2D,W
3141 02DD: IORWF 2C,F
223 kapl 3142 ....................
3143 .................... odp[1]=odp[2];
246 kaklik 3144 02DE: MOVF 28,W
3145 02DF: MOVWF 27
223 kapl 3146 .................... odp[2]=odp[4];
246 kaklik 3147 02E0: MOVF 2A,W
3148 02E1: MOVWF 28
223 kapl 3149 .................... odp[3]=odp[6];
246 kaklik 3150 02E2: MOVF 2C,W
3151 02E3: MOVWF 29
239 kaklik 3152 .................... odp[4]=odp[5]=odp[6]=0;
246 kaklik 3153 02E4: CLRF 2C
3154 02E5: MOVF 2C,W
3155 02E6: MOVWF 2B
3156 02E7: MOVWF 2A
239 kaklik 3157 ....................
3158 .................... /*lcd_gotoxy(1,2);
223 kapl 3159 .................... printf(lcd_putc,"%u %u %u %u",odp[0],odp[1],odp[2]odp[3]); */
239 kaklik 3160 ....................
223 kapl 3161 .................... pom3=0;
246 kaklik 3162 02E8: CLRF 53
239 kaklik 3163 .................... for (pom = 0; pom < 4;pom++)
246 kaklik 3164 02E9: CLRF 51
3165 02EA: MOVF 51,W
3166 02EB: SUBLW 03
3167 02EC: BTFSS 03.0
3168 02ED: GOTO 341
223 kapl 3169 .................... {
3170 .................... maskovadlo = maskovadlo >> 1; //rotace promene urcene pro maskovani
246 kaklik 3171 02EE: BCF 03.0
3172 02EF: RRF 56,F
223 kapl 3173 .................... maskovadlo = maskovadlo | 0x80;
246 kaklik 3174 02F0: BSF 56.7
223 kapl 3175 .................... odkl = odp[pom] & maskovadlo; //odlozeni "prenosu" do odkl pomoci maskovadla
246 kaklik 3176 02F1: MOVLW 26
3177 02F2: ADDWF 51,W
3178 02F3: MOVWF 04
3179 02F4: MOVF 00,W
3180 02F5: ANDWF 56,W
3181 02F6: MOVWF 54
223 kapl 3182 .................... odp[pom] = odp[pom] << pom3; //rotace znaku
246 kaklik 3183 02F7: MOVLW 26
3184 02F8: ADDWF 51,W
3185 02F9: MOVWF 57
3186 02FA: MOVLW 26
3187 02FB: ADDWF 51,W
3188 02FC: MOVWF 04
3189 02FD: MOVF 00,W
3190 02FE: MOVWF 77
3191 02FF: MOVF 53,W
3192 0300: MOVWF 78
3193 0301: BTFSC 03.2
3194 0302: GOTO 307
3195 0303: BCF 03.0
3196 0304: RLF 77,F
3197 0305: DECFSZ 78,F
3198 0306: GOTO 303
3199 0307: MOVF 57,W
3200 0308: MOVWF 04
3201 0309: MOVF 77,W
3202 030A: MOVWF 00
223 kapl 3203 .................... for (pom2 = 0; pom2 < (8-pom3);pom2++) //rotace odkl2
246 kaklik 3204 030B: CLRF 52
3205 030C: MOVF 53,W
3206 030D: SUBLW 08
3207 030E: SUBWF 52,W
3208 030F: BTFSC 03.0
3209 0310: GOTO 316
223 kapl 3210 .................... {
3211 .................... odkl2 = odkl2 >> 1;
246 kaklik 3212 0311: BCF 03.0
3213 0312: RRF 55,F
239 kaklik 3214 .................... odkl2 = odkl2 & 127;
246 kaklik 3215 0313: BCF 55.7
223 kapl 3216 .................... }
246 kaklik 3217 0314: INCF 52,F
3218 0315: GOTO 30C
223 kapl 3219 .................... odp[pom] = odp[pom] | odkl2; //pridani odkl2 ke znaku
246 kaklik 3220 0316: MOVLW 26
3221 0317: ADDWF 51,W
3222 0318: MOVWF 57
3223 0319: MOVLW 26
3224 031A: ADDWF 51,W
3225 031B: MOVWF 04
3226 031C: MOVF 00,W
3227 031D: IORWF 55,W
3228 031E: MOVWF 59
3229 031F: MOVF 57,W
3230 0320: MOVWF 04
3231 0321: MOVF 59,W
3232 0322: MOVWF 00
223 kapl 3233 .................... odp[pom] = odp[pom] & 127; //smazani nejvysiho bitu
246 kaklik 3234 0323: MOVLW 26
3235 0324: ADDWF 51,W
3236 0325: MOVWF 57
3237 0326: MOVLW 26
3238 0327: ADDWF 51,W
3239 0328: MOVWF 04
3240 0329: MOVF 00,W
3241 032A: ANDLW 7F
3242 032B: MOVWF 59
3243 032C: MOVF 57,W
3244 032D: MOVWF 04
3245 032E: MOVF 59,W
3246 032F: MOVWF 00
223 kapl 3247 .................... odkl2 = odkl; //ulozeni odlk na dalsi pruchod
246 kaklik 3248 0330: MOVF 54,W
3249 0331: MOVWF 55
223 kapl 3250 .................... pom3++; //inkrementace citace rotace
246 kaklik 3251 0332: INCF 53,F
223 kapl 3252 .................... if (pom3 == 8) //kazdy 8my znak
246 kaklik 3253 0333: MOVF 53,W
3254 0334: SUBLW 08
3255 0335: BTFSS 03.2
3256 0336: GOTO 33F
223 kapl 3257 .................... {
3258 .................... pom3 = 0; //smaz citac
246 kaklik 3259 0337: CLRF 53
223 kapl 3260 .................... odp[pom+1] = odkl2; //uloz 8my znak vznikly z "prenosu"
246 kaklik 3261 0338: MOVLW 01
3262 0339: ADDWF 51,W
3263 033A: ADDLW 26
3264 033B: MOVWF 04
3265 033C: MOVF 55,W
3266 033D: MOVWF 00
223 kapl 3267 .................... maskovadlo = 0; //smaz maskovadlo
246 kaklik 3268 033E: CLRF 56
223 kapl 3269 .................... }
3270 .................... }
246 kaklik 3271 033F: INCF 51,F
3272 0340: GOTO 2EA
239 kaklik 3273 .................... odp[pom]='\0';
246 kaklik 3274 0341: MOVLW 26
3275 0342: ADDWF 51,W
3276 0343: MOVWF 04
3277 0344: CLRF 00
240 kaklik 3278 .................... }
246 kaklik 3279 0345: BSF 0A.3
3280 0346: BCF 0A.4
3281 0347: GOTO 0B1 (RETURN)
239 kaklik 3282 ....................
240 kaklik 3283 .................... void read_time()
3284 .................... {
3285 .................... unsigned int8 n;
238 kaklik 3286 ....................
239 kaklik 3287 ....................
240 kaklik 3288 .................... fprintf(MOBIL,"AT+CCLK?\r");
245 kaklik 3289 *
246 kaklik 3290 037F: CLRF 52
3291 0380: MOVF 52,W
3292 0381: CALL 013
3293 0382: IORLW 00
3294 0383: BTFSC 03.2
3295 0384: GOTO 389
3296 0385: INCF 52,F
3297 0386: MOVWF 53
3298 0387: CALL 1DE
3299 0388: GOTO 380
240 kaklik 3300 .................... while(fgetc(MOBIL)!='"');
246 kaklik 3301 0389: CALL 206
3302 038A: MOVF 78,W
3303 038B: SUBLW 22
3304 038C: BTFSS 03.2
3305 038D: GOTO 389
240 kaklik 3306 .................... for(n=0;n<12;n++) //preskoc nedulezite informace
246 kaklik 3307 038E: CLRF 51
3308 038F: MOVF 51,W
3309 0390: SUBLW 0B
3310 0391: BTFSS 03.0
3311 0392: GOTO 396
240 kaklik 3312 .................... {
3313 .................... fgetc(MOBIL);
246 kaklik 3314 0393: CALL 206
240 kaklik 3315 .................... }
246 kaklik 3316 0394: INCF 51,F
3317 0395: GOTO 38F
240 kaklik 3318 .................... odp[0]=fgetc(MOBIL);
246 kaklik 3319 0396: CALL 206
3320 0397: MOVF 78,W
3321 0398: MOVWF 26
240 kaklik 3322 .................... odp[1]=fgetc(MOBIL);
246 kaklik 3323 0399: CALL 206
3324 039A: MOVF 78,W
3325 039B: MOVWF 27
240 kaklik 3326 .................... odp[2]=0;
246 kaklik 3327 039C: CLRF 28
240 kaklik 3328 .................... }
246 kaklik 3329 039D: BSF 0A.3
3330 039E: BCF 0A.4
3331 039F: GOTO 4FA (RETURN)
239 kaklik 3332 ....................
240 kaklik 3333 .................... void del_sms()
3334 .................... {
3335 .................... fprintf(MOBIL,"AT+CMGD=1\r"); //smaz prijatou SMSku
246 kaklik 3336 *
3337 0374: CLRF 51
3338 0375: MOVF 51,W
3339 0376: CALL 021
3340 0377: IORLW 00
3341 0378: BTFSC 03.2
3342 0379: GOTO 37E
3343 037A: INCF 51,F
3344 037B: MOVWF 53
3345 037C: CALL 1DE
3346 037D: GOTO 375
240 kaklik 3347 .................... }
246 kaklik 3348 037E: RETLW 00
239 kaklik 3349 ....................
240 kaklik 3350 .................... void main()
3351 .................... {
3352 *
246 kaklik 3353 0800: CLRF 04
3354 0801: MOVLW 1F
3355 0802: ANDWF 03,F
3356 0803: BCF 20.6
3357 0804: MOVF 20,W
3358 0805: BSF 03.5
3359 0806: MOVWF 07
3360 0807: BCF 03.5
3361 0808: BSF 07.6
3362 0809: BSF 03.5
3363 080A: BCF 06.2
3364 080B: BCF 03.5
3365 080C: BSF 06.2
3366 080D: BSF 03.5
3367 080E: BSF 1F.0
3368 080F: BSF 1F.1
3369 0810: BSF 1F.2
3370 0811: BCF 1F.3
3371 0812: MOVLW 07
3372 0813: MOVWF 1C
240 kaklik 3373 .................... setup_adc_ports(NO_ANALOGS);
3374 *
246 kaklik 3375 081D: BSF 03.5
3376 081E: BSF 1F.0
3377 081F: BSF 1F.1
3378 0820: BSF 1F.2
3379 0821: BCF 1F.3
240 kaklik 3380 .................... setup_adc(ADC_OFF);
246 kaklik 3381 0822: BCF 03.5
3382 0823: BCF 1F.0
240 kaklik 3383 .................... setup_spi(SPI_SS_DISABLED);
246 kaklik 3384 0824: BCF 14.5
3385 0825: BCF 20.5
3386 0826: MOVF 20,W
3387 0827: BSF 03.5
3388 0828: MOVWF 07
3389 0829: BCF 03.5
3390 082A: BSF 20.4
3391 082B: MOVF 20,W
3392 082C: BSF 03.5
3393 082D: MOVWF 07
3394 082E: BCF 03.5
3395 082F: BCF 20.3
3396 0830: MOVF 20,W
3397 0831: BSF 03.5
3398 0832: MOVWF 07
3399 0833: MOVLW 01
3400 0834: BCF 03.5
3401 0835: MOVWF 14
3402 0836: MOVLW 00
3403 0837: BSF 03.5
3404 0838: MOVWF 14
240 kaklik 3405 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
246 kaklik 3406 0839: MOVF 01,W
3407 083A: ANDLW C7
3408 083B: IORLW 08
3409 083C: MOVWF 01
240 kaklik 3410 .................... setup_timer_1(T1_DISABLED);
246 kaklik 3411 083D: BCF 03.5
3412 083E: CLRF 10
240 kaklik 3413 .................... setup_timer_2(T2_DIV_BY_4,255,1);
246 kaklik 3414 083F: MOVLW 00
3415 0840: MOVWF 78
3416 0841: IORLW 05
3417 0842: MOVWF 12
3418 0843: MOVLW FF
3419 0844: BSF 03.5
3420 0845: MOVWF 12
240 kaklik 3421 .................... setup_ccp1(CCP_PWM);
246 kaklik 3422 0846: BCF 03.5
3423 0847: BCF 20.2
3424 0848: MOVF 20,W
3425 0849: BSF 03.5
3426 084A: MOVWF 07
3427 084B: BCF 03.5
3428 084C: BCF 07.2
3429 084D: MOVLW 0C
3430 084E: MOVWF 17
240 kaklik 3431 .................... setup_ccp2(CCP_PWM);
246 kaklik 3432 084F: BCF 20.1
3433 0850: MOVF 20,W
3434 0851: BSF 03.5
3435 0852: MOVWF 07
3436 0853: BCF 03.5
3437 0854: BCF 07.1
3438 0855: MOVLW 0C
3439 0856: MOVWF 1D
240 kaklik 3440 .................... setup_comparator(NC_NC_NC_NC);
246 kaklik 3441 0857: MOVLW 07
3442 0858: BSF 03.5
3443 0859: MOVWF 1C
3444 085A: MOVF 05,W
3445 085B: CLRWDT
3446 085C: MOVLW 0E
3447 085D: MOVWF 77
3448 085E: DECFSZ 77,F
3449 085F: GOTO 05E
3450 0860: NOP
3451 0861: NOP
3452 0862: MOVF 1C,W
3453 0863: BCF 03.5
3454 0864: BCF 0D.6
240 kaklik 3455 .................... setup_vref(FALSE);
246 kaklik 3456 0865: BSF 03.5
3457 0866: CLRF 1D
240 kaklik 3458 .................... setup_wdt(WDT_2304MS);
246 kaklik 3459 0867: MOVLW 0F
3460 0868: MOVWF 77
3461 0869: MOVLW 07
3462 086A: BCF 03.5
3463 086B: CLRF 01
3464 086C: MOVLW 81
3465 086D: MOVWF 04
3466 086E: MOVF 00,W
3467 086F: ANDLW F0
3468 0870: IORLW 07
3469 0871: MOVWF 00
3470 0872: CLRWDT
3471 0873: MOVF 00,W
3472 0874: ANDLW F7
3473 0875: BTFSC 77.3
3474 0876: ANDLW F0
3475 0877: IORWF 77,W
3476 0878: MOVWF 00
239 kaklik 3477 ....................
240 kaklik 3478 .................... set_pwm1_duty(0);
246 kaklik 3479 0879: CLRF 15
240 kaklik 3480 .................... set_pwm2_duty(0);
246 kaklik 3481 087A: CLRF 1B
239 kaklik 3482 ....................
240 kaklik 3483 .................... while(TRUE)
3484 .................... {
246 kaklik 3485 .................... unsigned int8 n;
240 kaklik 3486 .................... char *ptr;
3487 .................... int time;
238 kaklik 3488 ....................
240 kaklik 3489 .................... output_low(PIN_A4) ;
246 kaklik 3490 087B: BSF 03.5
3491 087C: BCF 05.4
3492 087D: BCF 03.5
3493 087E: BCF 05.4
240 kaklik 3494 .................... delay_ms(150);
246 kaklik 3495 087F: MOVLW 96
3496 0880: MOVWF 52
3497 0881: BCF 0A.3
3498 0882: CALL 1C8
3499 0883: BSF 0A.3
240 kaklik 3500 .................... output_high(PIN_A4);
246 kaklik 3501 0884: BSF 03.5
3502 0885: BCF 05.4
3503 0886: BCF 03.5
3504 0887: BSF 05.4
240 kaklik 3505 .................... delay_ms(150);
246 kaklik 3506 0888: MOVLW 96
3507 0889: MOVWF 52
3508 088A: BCF 0A.3
3509 088B: CALL 1C8
3510 088C: BSF 0A.3
240 kaklik 3511 .................... output_low(PIN_A4) ;
246 kaklik 3512 088D: BSF 03.5
3513 088E: BCF 05.4
3514 088F: BCF 03.5
3515 0890: BCF 05.4
240 kaklik 3516 .................... delay_ms(150);
246 kaklik 3517 0891: MOVLW 96
3518 0892: MOVWF 52
3519 0893: BCF 0A.3
3520 0894: CALL 1C8
3521 0895: BSF 0A.3
240 kaklik 3522 .................... output_high(PIN_A4);
246 kaklik 3523 0896: BSF 03.5
3524 0897: BCF 05.4
3525 0898: BCF 03.5
3526 0899: BSF 05.4
240 kaklik 3527 .................... delay_ms(150);
246 kaklik 3528 089A: MOVLW 96
3529 089B: MOVWF 52
3530 089C: BCF 0A.3
3531 089D: CALL 1C8
3532 089E: BSF 0A.3
238 kaklik 3533 ....................
3534 ....................
245 kaklik 3535 .................... if(check_new_sms()) // Je odpoved "OK"?
246 kaklik 3536 089F: BCF 0A.3
3537 08A0: GOTO 22E
3538 08A1: BSF 0A.3
3539 08A2: MOVF 78,F
3540 08A3: BTFSC 03.2
3541 08A4: GOTO 0AF
240 kaklik 3542 .................... {
3543 .................... // printf(lcd_putc,"736 655 250");
247 kaklik 3544 .................... delay_ms(1000);
3545 08A5: MOVLW 04
246 kaklik 3546 08A6: MOVWF 51
3547 08A7: MOVLW FA
3548 08A8: MOVWF 52
3549 08A9: BCF 0A.3
3550 08AA: CALL 1C8
3551 08AB: BSF 0A.3
3552 08AC: DECFSZ 51,F
3553 08AD: GOTO 0A7
240 kaklik 3554 .................... }
3555 .................... else
246 kaklik 3556 08AE: GOTO 4F8
240 kaklik 3557 .................... {
3558 .................... read_sms();
246 kaklik 3559 08AF: BCF 0A.3
3560 08B0: GOTO 25A
3561 08B1: BSF 0A.3
240 kaklik 3562 ....................
246 kaklik 3563 .................... if (toupper(odp[0]) == 'A')
3564 08B2: MOVF 26,W
3565 08B3: SUBLW 60
3566 08B4: BTFSC 03.0
3567 08B5: GOTO 0BD
3568 08B6: MOVF 26,W
3569 08B7: SUBLW 7A
3570 08B8: BTFSS 03.0
3571 08B9: GOTO 0BD
3572 08BA: MOVF 26,W
3573 08BB: ANDLW DF
3574 08BC: GOTO 0BE
3575 08BD: MOVF 26,W
3576 08BE: SUBLW 41
3577 08BF: BTFSS 03.2
3578 08C0: GOTO 101
240 kaklik 3579 .................... {
246 kaklik 3580 .................... set_pwm1_duty(VYKON);
3581 08C1: MOVLW 64
3582 08C2: MOVWF 15
3583 .................... set_pwm2_duty(VYKON);
3584 08C3: MOVWF 1B
3585 .................... Delay_ms(10000);
3586 08C4: MOVLW 28
3587 08C5: MOVWF 51
3588 08C6: MOVLW FA
3589 08C7: MOVWF 52
3590 08C8: BCF 0A.3
3591 08C9: CALL 1C8
3592 08CA: BSF 0A.3
3593 08CB: DECFSZ 51,F
3594 08CC: GOTO 0C6
3595 .................... fprintf(VRTULE,"JACK[BARmk"); // "JACK BAR :)"
3596 08CD: CLRF 51
3597 08CE: MOVF 51,W
3598 08CF: BCF 0A.3
3599 08D0: CALL 030
3600 08D1: BSF 0A.3
3601 08D2: IORLW 00
3602 08D3: BTFSC 03.2
3603 08D4: GOTO 0DB
3604 08D5: INCF 51,F
3605 08D6: MOVWF 52
3606 08D7: BCF 0A.3
3607 08D8: CALL 348
3608 08D9: BSF 0A.3
3609 08DA: GOTO 0CE
3610 .................... Delay_ms(2000);
3611 08DB: MOVLW 08
3612 08DC: MOVWF 51
3613 08DD: MOVLW FA
3614 08DE: MOVWF 52
3615 08DF: BCF 0A.3
3616 08E0: CALL 1C8
3617 08E1: BSF 0A.3
3618 08E2: DECFSZ 51,F
3619 08E3: GOTO 0DD
3620 .................... fprintf(VRTULE,"JACK[BARmk"); // "JACK BAR :)"
3621 08E4: CLRF 51
3622 08E5: MOVF 51,W
3623 08E6: BCF 0A.3
3624 08E7: CALL 030
3625 08E8: BSF 0A.3
3626 08E9: IORLW 00
3627 08EA: BTFSC 03.2
3628 08EB: GOTO 0F2
3629 08EC: INCF 51,F
3630 08ED: MOVWF 52
3631 08EE: BCF 0A.3
3632 08EF: CALL 348
3633 08F0: BSF 0A.3
3634 08F1: GOTO 0E5
3635 .................... Delay_ms(5000);
3636 08F2: MOVLW 14
3637 08F3: MOVWF 51
3638 08F4: MOVLW FA
3639 08F5: MOVWF 52
3640 08F6: BCF 0A.3
3641 08F7: CALL 1C8
3642 08F8: BSF 0A.3
3643 08F9: DECFSZ 51,F
3644 08FA: GOTO 0F4
3645 .................... set_pwm1_duty(0);
3646 08FB: CLRF 15
3647 .................... set_pwm2_duty(0);
3648 08FC: CLRF 1B
3649 .................... del_sms();
3650 08FD: BCF 0A.3
3651 08FE: CALL 374
3652 08FF: BSF 0A.3
3653 .................... break;
3654 0900: GOTO 532
3655 .................... }
240 kaklik 3656 ....................
246 kaklik 3657 .................... if (toupper(odp[0]) == 'B')
3658 0901: MOVF 26,W
3659 0902: SUBLW 60
3660 0903: BTFSC 03.0
3661 0904: GOTO 10C
3662 0905: MOVF 26,W
3663 0906: SUBLW 7A
3664 0907: BTFSS 03.0
3665 0908: GOTO 10C
3666 0909: MOVF 26,W
3667 090A: ANDLW DF
3668 090B: GOTO 10D
3669 090C: MOVF 26,W
3670 090D: SUBLW 42
3671 090E: BTFSS 03.2
3672 090F: GOTO 160
245 kaklik 3673 .................... {
246 kaklik 3674 .................... set_pwm1_duty(VYKON);
3675 0910: MOVLW 64
3676 0911: MOVWF 15
3677 .................... set_pwm2_duty(VYKON);
3678 0912: MOVWF 1B
245 kaklik 3679 .................... Delay_ms(10000);
246 kaklik 3680 0913: MOVLW 28
3681 0914: MOVWF 51
3682 0915: MOVLW FA
3683 0916: MOVWF 52
3684 0917: BCF 0A.3
3685 0918: CALL 1C8
3686 0919: BSF 0A.3
3687 091A: DECFSZ 51,F
3688 091B: GOTO 115
3689 .................... for(n=0;n<=1;n++)
3690 091C: CLRF 4E
3691 091D: MOVF 4E,W
3692 091E: SUBLW 01
3693 091F: BTFSS 03.0
3694 0920: GOTO 151
3695 .................... {
3696 .................... fprintf(VRTULE,"[ERROR[d[["); // " ERROR 3 "
3697 0921: CLRF 51
3698 0922: MOVF 51,W
3699 0923: BCF 0A.3
3700 0924: CALL 03F
3701 0925: BSF 0A.3
3702 0926: IORLW 00
3703 0927: BTFSC 03.2
3704 0928: GOTO 12F
3705 0929: INCF 51,F
3706 092A: MOVWF 52
3707 092B: BCF 0A.3
3708 092C: CALL 348
3709 092D: BSF 0A.3
3710 092E: GOTO 122
3711 .................... Delay_ms(2000);
3712 092F: MOVLW 08
3713 0930: MOVWF 51
3714 0931: MOVLW FA
3715 0932: MOVWF 52
3716 0933: BCF 0A.3
3717 0934: CALL 1C8
3718 0935: BSF 0A.3
3719 0936: DECFSZ 51,F
3720 0937: GOTO 131
3721 .................... fprintf(VRTULE,"[OVERFLOW["); // " OVERFLOW "
3722 0938: CLRF 51
3723 0939: MOVF 51,W
3724 093A: BCF 0A.3
3725 093B: CALL 04E
3726 093C: BSF 0A.3
3727 093D: IORLW 00
3728 093E: BTFSC 03.2
3729 093F: GOTO 146
3730 0940: INCF 51,F
3731 0941: MOVWF 52
3732 0942: BCF 0A.3
3733 0943: CALL 348
3734 0944: BSF 0A.3
3735 0945: GOTO 139
3736 .................... Delay_ms(2000);
3737 0946: MOVLW 08
3738 0947: MOVWF 51
3739 0948: MOVLW FA
3740 0949: MOVWF 52
3741 094A: BCF 0A.3
3742 094B: CALL 1C8
3743 094C: BSF 0A.3
3744 094D: DECFSZ 51,F
3745 094E: GOTO 148
3746 .................... }
3747 094F: INCF 4E,F
3748 0950: GOTO 11D
3749 .................... Delay_ms(5000);
3750 0951: MOVLW 14
3751 0952: MOVWF 51
3752 0953: MOVLW FA
3753 0954: MOVWF 52
3754 0955: BCF 0A.3
3755 0956: CALL 1C8
3756 0957: BSF 0A.3
3757 0958: DECFSZ 51,F
3758 0959: GOTO 153
3759 .................... set_pwm1_duty(0);
3760 095A: CLRF 15
3761 .................... set_pwm2_duty(0);
3762 095B: CLRF 1B
3763 .................... del_sms();
3764 095C: BCF 0A.3
3765 095D: CALL 374
3766 095E: BSF 0A.3
3767 .................... break;
3768 095F: GOTO 532
3769 .................... }
3770 ....................
3771 .................... if (toupper(odp[0]) == 'C')
3772 0960: MOVF 26,W
3773 0961: SUBLW 60
3774 0962: BTFSC 03.0
3775 0963: GOTO 16B
3776 0964: MOVF 26,W
3777 0965: SUBLW 7A
3778 0966: BTFSS 03.0
3779 0967: GOTO 16B
3780 0968: MOVF 26,W
3781 0969: ANDLW DF
3782 096A: GOTO 16C
3783 096B: MOVF 26,W
3784 096C: SUBLW 43
3785 096D: BTFSS 03.2
3786 096E: GOTO 1D6
3787 .................... {
3788 .................... set_pwm1_duty(VYKON);
3789 096F: MOVLW 64
3790 0970: MOVWF 15
3791 .................... set_pwm2_duty(VYKON);
3792 0971: MOVWF 1B
3793 .................... Delay_ms(10000);
3794 0972: MOVLW 28
3795 0973: MOVWF 51
3796 0974: MOVLW FA
3797 0975: MOVWF 52
3798 0976: BCF 0A.3
3799 0977: CALL 1C8
3800 0978: BSF 0A.3
3801 0979: DECFSZ 51,F
3802 097A: GOTO 174
3803 .................... for(n=0;n<=1;n++)
3804 097B: CLRF 4E
3805 097C: MOVF 4E,W
3806 097D: SUBLW 01
3807 097E: BTFSS 03.0
3808 097F: GOTO 1C7
3809 .................... {
3810 .................... fprintf(VRTULE,"[ERROR[e[["); // " ERROR 4 "
3811 0980: CLRF 51
3812 0981: MOVF 51,W
3813 0982: BCF 0A.3
3814 0983: CALL 05D
3815 0984: BSF 0A.3
3816 0985: IORLW 00
3817 0986: BTFSC 03.2
3818 0987: GOTO 18E
3819 0988: INCF 51,F
3820 0989: MOVWF 52
3821 098A: BCF 0A.3
3822 098B: CALL 348
3823 098C: BSF 0A.3
3824 098D: GOTO 181
3825 .................... Delay_ms(2000);
3826 098E: MOVLW 08
3827 098F: MOVWF 51
3828 0990: MOVLW FA
3829 0991: MOVWF 52
3830 0992: BCF 0A.3
3831 0993: CALL 1C8
3832 0994: BSF 0A.3
3833 0995: DECFSZ 51,F
3834 0996: GOTO 190
3835 .................... fprintf(VRTULE,"[OPAKUJTE["); // " OPAKUJTE "
3836 0997: CLRF 51
3837 0998: MOVF 51,W
3838 0999: BCF 0A.3
3839 099A: CALL 06C
3840 099B: BSF 0A.3
3841 099C: IORLW 00
3842 099D: BTFSC 03.2
3843 099E: GOTO 1A5
3844 099F: INCF 51,F
3845 09A0: MOVWF 52
3846 09A1: BCF 0A.3
3847 09A2: CALL 348
3848 09A3: BSF 0A.3
3849 09A4: GOTO 198
3850 .................... Delay_ms(2000);
3851 09A5: MOVLW 08
3852 09A6: MOVWF 51
3853 09A7: MOVLW FA
3854 09A8: MOVWF 52
3855 09A9: BCF 0A.3
3856 09AA: CALL 1C8
3857 09AB: BSF 0A.3
3858 09AC: DECFSZ 51,F
3859 09AD: GOTO 1A7
3860 .................... fprintf(VRTULE,"[[VOLBU[[["); // " VOLBU "
3861 09AE: CLRF 51
3862 09AF: MOVF 51,W
3863 09B0: BCF 0A.3
3864 09B1: CALL 07B
3865 09B2: BSF 0A.3
3866 09B3: IORLW 00
3867 09B4: BTFSC 03.2
3868 09B5: GOTO 1BC
3869 09B6: INCF 51,F
3870 09B7: MOVWF 52
3871 09B8: BCF 0A.3
3872 09B9: CALL 348
3873 09BA: BSF 0A.3
3874 09BB: GOTO 1AF
3875 .................... Delay_ms(2000);
3876 09BC: MOVLW 08
3877 09BD: MOVWF 51
3878 09BE: MOVLW FA
3879 09BF: MOVWF 52
3880 09C0: BCF 0A.3
3881 09C1: CALL 1C8
3882 09C2: BSF 0A.3
3883 09C3: DECFSZ 51,F
3884 09C4: GOTO 1BE
3885 .................... }
3886 09C5: INCF 4E,F
3887 09C6: GOTO 17C
3888 .................... Delay_ms(3000);
3889 09C7: MOVLW 0C
3890 09C8: MOVWF 51
3891 09C9: MOVLW FA
3892 09CA: MOVWF 52
3893 09CB: BCF 0A.3
3894 09CC: CALL 1C8
3895 09CD: BSF 0A.3
3896 09CE: DECFSZ 51,F
3897 09CF: GOTO 1C9
3898 .................... set_pwm1_duty(0);
3899 09D0: CLRF 15
3900 .................... set_pwm2_duty(0);
3901 09D1: CLRF 1B
3902 .................... del_sms();
3903 09D2: BCF 0A.3
3904 09D3: CALL 374
3905 09D4: BSF 0A.3
3906 .................... break;
3907 09D5: GOTO 532
3908 .................... }
3909 ....................
3910 .................... if (toupper(odp[0]) == 'D')
3911 09D6: MOVF 26,W
3912 09D7: SUBLW 60
3913 09D8: BTFSC 03.0
3914 09D9: GOTO 1E1
3915 09DA: MOVF 26,W
3916 09DB: SUBLW 7A
3917 09DC: BTFSS 03.0
3918 09DD: GOTO 1E1
3919 09DE: MOVF 26,W
3920 09DF: ANDLW DF
3921 09E0: GOTO 1E2
3922 09E1: MOVF 26,W
3923 09E2: SUBLW 44
3924 09E3: BTFSS 03.2
3925 09E4: GOTO 225
3926 .................... {
3927 .................... set_pwm1_duty(VYKON);
3928 09E5: MOVLW 64
3929 09E6: MOVWF 15
3930 .................... set_pwm2_duty(VYKON);
3931 09E7: MOVWF 1B
3932 .................... Delay_ms(10000);
3933 09E8: MOVLW 28
3934 09E9: MOVWF 51
3935 09EA: MOVLW FA
3936 09EB: MOVWF 52
3937 09EC: BCF 0A.3
3938 09ED: CALL 1C8
3939 09EE: BSF 0A.3
3940 09EF: DECFSZ 51,F
3941 09F0: GOTO 1EA
3942 .................... fprintf(VRTULE,"[[PEACE[[["); // " PEACE "
3943 09F1: CLRF 51
3944 09F2: MOVF 51,W
3945 09F3: BCF 0A.3
3946 09F4: CALL 08A
3947 09F5: BSF 0A.3
3948 09F6: IORLW 00
3949 09F7: BTFSC 03.2
3950 09F8: GOTO 1FF
3951 09F9: INCF 51,F
3952 09FA: MOVWF 52
3953 09FB: BCF 0A.3
3954 09FC: CALL 348
3955 09FD: BSF 0A.3
3956 09FE: GOTO 1F2
245 kaklik 3957 .................... Delay_ms(2000);
246 kaklik 3958 09FF: MOVLW 08
3959 0A00: MOVWF 51
3960 0A01: MOVLW FA
3961 0A02: MOVWF 52
3962 0A03: BCF 0A.3
3963 0A04: CALL 1C8
3964 0A05: BSF 0A.3
3965 0A06: DECFSZ 51,F
3966 0A07: GOTO 201
3967 .................... fprintf(VRTULE,"[[PEACE[[[");
3968 0A08: CLRF 51
3969 0A09: MOVF 51,W
3970 0A0A: BCF 0A.3
3971 0A0B: CALL 08A
3972 0A0C: BSF 0A.3
3973 0A0D: IORLW 00
3974 0A0E: BTFSC 03.2
3975 0A0F: GOTO 216
3976 0A10: INCF 51,F
3977 0A11: MOVWF 52
3978 0A12: BCF 0A.3
3979 0A13: CALL 348
3980 0A14: BSF 0A.3
3981 0A15: GOTO 209
3982 .................... Delay_ms(3000);
3983 0A16: MOVLW 0C
3984 0A17: MOVWF 51
3985 0A18: MOVLW FA
3986 0A19: MOVWF 52
3987 0A1A: BCF 0A.3
3988 0A1B: CALL 1C8
3989 0A1C: BSF 0A.3
3990 0A1D: DECFSZ 51,F
3991 0A1E: GOTO 218
3992 .................... set_pwm1_duty(0);
3993 0A1F: CLRF 15
3994 .................... set_pwm2_duty(0);
3995 0A20: CLRF 1B
3996 .................... del_sms();
3997 0A21: BCF 0A.3
3998 0A22: CALL 374
3999 0A23: BSF 0A.3
4000 .................... break;
4001 0A24: GOTO 532
4002 .................... }
4003 ....................
4004 .................... if (toupper(odp[0]) == 'E')
4005 0A25: MOVF 26,W
4006 0A26: SUBLW 60
4007 0A27: BTFSC 03.0
4008 0A28: GOTO 230
4009 0A29: MOVF 26,W
4010 0A2A: SUBLW 7A
4011 0A2B: BTFSS 03.0
4012 0A2C: GOTO 230
4013 0A2D: MOVF 26,W
4014 0A2E: ANDLW DF
4015 0A2F: GOTO 231
4016 0A30: MOVF 26,W
4017 0A31: SUBLW 45
4018 0A32: BTFSS 03.2
4019 0A33: GOTO 284
4020 .................... {
4021 .................... set_pwm1_duty(VYKON);
4022 0A34: MOVLW 64
4023 0A35: MOVWF 15
4024 .................... set_pwm2_duty(VYKON);
4025 0A36: MOVWF 1B
4026 .................... Delay_ms(10000);
4027 0A37: MOVLW 28
4028 0A38: MOVWF 51
4029 0A39: MOVLW FA
4030 0A3A: MOVWF 52
4031 0A3B: BCF 0A.3
4032 0A3C: CALL 1C8
4033 0A3D: BSF 0A.3
4034 0A3E: DECFSZ 51,F
4035 0A3F: GOTO 239
4036 .................... for(n=0;n<=1;n++)
4037 0A40: CLRF 4E
4038 0A41: MOVF 4E,W
4039 0A42: SUBLW 01
4040 0A43: BTFSS 03.0
4041 0A44: GOTO 275
4042 .................... {
4043 .................... fprintf(VRTULE,"[[[MORE[[["); // " MORE "
4044 0A45: CLRF 51
4045 0A46: MOVF 51,W
4046 0A47: BCF 0A.3
4047 0A48: CALL 099
4048 0A49: BSF 0A.3
4049 0A4A: IORLW 00
4050 0A4B: BTFSC 03.2
4051 0A4C: GOTO 253
4052 0A4D: INCF 51,F
4053 0A4E: MOVWF 52
4054 0A4F: BCF 0A.3
4055 0A50: CALL 348
4056 0A51: BSF 0A.3
4057 0A52: GOTO 246
4058 .................... Delay_ms(2000);
4059 0A53: MOVLW 08
4060 0A54: MOVWF 51
4061 0A55: MOVLW FA
4062 0A56: MOVWF 52
4063 0A57: BCF 0A.3
4064 0A58: CALL 1C8
4065 0A59: BSF 0A.3
4066 0A5A: DECFSZ 51,F
4067 0A5B: GOTO 255
4068 .................... fprintf(VRTULE,"[[ZE[JO[[["); // " ZE JO "
4069 0A5C: CLRF 51
4070 0A5D: MOVF 51,W
4071 0A5E: BCF 0A.3
4072 0A5F: CALL 0A8
4073 0A60: BSF 0A.3
4074 0A61: IORLW 00
4075 0A62: BTFSC 03.2
4076 0A63: GOTO 26A
4077 0A64: INCF 51,F
4078 0A65: MOVWF 52
4079 0A66: BCF 0A.3
4080 0A67: CALL 348
4081 0A68: BSF 0A.3
4082 0A69: GOTO 25D
4083 .................... Delay_ms(2000);
4084 0A6A: MOVLW 08
4085 0A6B: MOVWF 51
4086 0A6C: MOVLW FA
4087 0A6D: MOVWF 52
4088 0A6E: BCF 0A.3
4089 0A6F: CALL 1C8
4090 0A70: BSF 0A.3
4091 0A71: DECFSZ 51,F
4092 0A72: GOTO 26C
4093 .................... }
4094 0A73: INCF 4E,F
4095 0A74: GOTO 241
245 kaklik 4096 .................... Delay_ms(5000);
246 kaklik 4097 0A75: MOVLW 14
4098 0A76: MOVWF 51
4099 0A77: MOVLW FA
4100 0A78: MOVWF 52
4101 0A79: BCF 0A.3
4102 0A7A: CALL 1C8
4103 0A7B: BSF 0A.3
4104 0A7C: DECFSZ 51,F
4105 0A7D: GOTO 277
245 kaklik 4106 .................... set_pwm1_duty(0);
246 kaklik 4107 0A7E: CLRF 15
245 kaklik 4108 .................... set_pwm2_duty(0);
246 kaklik 4109 0A7F: CLRF 1B
4110 .................... del_sms();
4111 0A80: BCF 0A.3
4112 0A81: CALL 374
4113 0A82: BSF 0A.3
4114 .................... break;
4115 0A83: GOTO 532
4116 .................... }
239 kaklik 4117 ....................
246 kaklik 4118 .................... if (toupper(odp[0]) == 'F')
4119 0A84: MOVF 26,W
4120 0A85: SUBLW 60
4121 0A86: BTFSC 03.0
4122 0A87: GOTO 28F
4123 0A88: MOVF 26,W
4124 0A89: SUBLW 7A
4125 0A8A: BTFSS 03.0
4126 0A8B: GOTO 28F
4127 0A8C: MOVF 26,W
4128 0A8D: ANDLW DF
4129 0A8E: GOTO 290
4130 0A8F: MOVF 26,W
4131 0A90: SUBLW 46
4132 0A91: BTFSS 03.2
4133 0A92: GOTO 2E3
245 kaklik 4134 .................... {
246 kaklik 4135 .................... set_pwm1_duty(VYKON);
4136 0A93: MOVLW 64
4137 0A94: MOVWF 15
4138 .................... set_pwm2_duty(VYKON);
4139 0A95: MOVWF 1B
245 kaklik 4140 .................... Delay_ms(10000);
246 kaklik 4141 0A96: MOVLW 28
4142 0A97: MOVWF 51
4143 0A98: MOVLW FA
4144 0A99: MOVWF 52
4145 0A9A: BCF 0A.3
4146 0A9B: CALL 1C8
4147 0A9C: BSF 0A.3
4148 0A9D: DECFSZ 51,F
4149 0A9E: GOTO 298
4150 .................... for(n=0;n<=1;n++)
4151 0A9F: CLRF 4E
4152 0AA0: MOVF 4E,W
4153 0AA1: SUBLW 01
4154 0AA2: BTFSS 03.0
4155 0AA3: GOTO 2D4
4156 .................... {
4157 .................... fprintf(VRTULE,"[ROZBITY[["); // " ROZBITY "
4158 0AA4: CLRF 51
4159 0AA5: MOVF 51,W
4160 0AA6: BCF 0A.3
4161 0AA7: CALL 0B7
4162 0AA8: BSF 0A.3
4163 0AA9: IORLW 00
4164 0AAA: BTFSC 03.2
4165 0AAB: GOTO 2B2
4166 0AAC: INCF 51,F
4167 0AAD: MOVWF 52
4168 0AAE: BCF 0A.3
4169 0AAF: CALL 348
4170 0AB0: BSF 0A.3
4171 0AB1: GOTO 2A5
4172 .................... Delay_ms(2000);
4173 0AB2: MOVLW 08
4174 0AB3: MOVWF 51
4175 0AB4: MOVLW FA
4176 0AB5: MOVWF 52
4177 0AB6: BCF 0A.3
4178 0AB7: CALL 1C8
4179 0AB8: BSF 0A.3
4180 0AB9: DECFSZ 51,F
4181 0ABA: GOTO 2B4
4182 .................... fprintf(VRTULE,"[[BUDIK[[["); // " BUDIK "
4183 0ABB: CLRF 51
4184 0ABC: MOVF 51,W
4185 0ABD: BCF 0A.3
4186 0ABE: CALL 0C6
4187 0ABF: BSF 0A.3
4188 0AC0: IORLW 00
4189 0AC1: BTFSC 03.2
4190 0AC2: GOTO 2C9
4191 0AC3: INCF 51,F
4192 0AC4: MOVWF 52
4193 0AC5: BCF 0A.3
4194 0AC6: CALL 348
4195 0AC7: BSF 0A.3
4196 0AC8: GOTO 2BC
4197 .................... Delay_ms(2000);
4198 0AC9: MOVLW 08
4199 0ACA: MOVWF 51
4200 0ACB: MOVLW FA
4201 0ACC: MOVWF 52
4202 0ACD: BCF 0A.3
4203 0ACE: CALL 1C8
4204 0ACF: BSF 0A.3
4205 0AD0: DECFSZ 51,F
4206 0AD1: GOTO 2CB
4207 .................... }
4208 0AD2: INCF 4E,F
4209 0AD3: GOTO 2A0
4210 .................... Delay_ms(5000);
4211 0AD4: MOVLW 14
4212 0AD5: MOVWF 51
4213 0AD6: MOVLW FA
4214 0AD7: MOVWF 52
4215 0AD8: BCF 0A.3
4216 0AD9: CALL 1C8
4217 0ADA: BSF 0A.3
4218 0ADB: DECFSZ 51,F
4219 0ADC: GOTO 2D6
4220 .................... set_pwm1_duty(0);
4221 0ADD: CLRF 15
4222 .................... set_pwm2_duty(0);
4223 0ADE: CLRF 1B
4224 .................... del_sms();
4225 0ADF: BCF 0A.3
4226 0AE0: CALL 374
4227 0AE1: BSF 0A.3
4228 .................... break;
4229 0AE2: GOTO 532
4230 .................... }
4231 ....................
4232 .................... if (toupper(odp[0]) == 'G')
4233 0AE3: MOVF 26,W
4234 0AE4: SUBLW 60
4235 0AE5: BTFSC 03.0
4236 0AE6: GOTO 2EE
4237 0AE7: MOVF 26,W
4238 0AE8: SUBLW 7A
4239 0AE9: BTFSS 03.0
4240 0AEA: GOTO 2EE
4241 0AEB: MOVF 26,W
4242 0AEC: ANDLW DF
4243 0AED: GOTO 2EF
4244 0AEE: MOVF 26,W
4245 0AEF: SUBLW 47
4246 0AF0: BTFSS 03.2
4247 0AF1: GOTO 342
4248 .................... {
4249 .................... set_pwm1_duty(VYKON);
4250 0AF2: MOVLW 64
4251 0AF3: MOVWF 15
4252 .................... set_pwm2_duty(VYKON);
4253 0AF4: MOVWF 1B
4254 .................... Delay_ms(10000);
4255 0AF5: MOVLW 28
4256 0AF6: MOVWF 51
4257 0AF7: MOVLW FA
4258 0AF8: MOVWF 52
4259 0AF9: BCF 0A.3
4260 0AFA: CALL 1C8
4261 0AFB: BSF 0A.3
4262 0AFC: DECFSZ 51,F
4263 0AFD: GOTO 2F7
4264 .................... for(n=0;n<=1;n++)
4265 0AFE: CLRF 4E
4266 0AFF: MOVF 4E,W
4267 0B00: SUBLW 01
4268 0B01: BTFSS 03.0
4269 0B02: GOTO 333
4270 .................... {
4271 .................... fprintf(VRTULE,"[ZAPOJIT[["); // " ZAPOJIT "
4272 0B03: CLRF 51
4273 0B04: MOVF 51,W
4274 0B05: BCF 0A.3
4275 0B06: CALL 0D5
4276 0B07: BSF 0A.3
4277 0B08: IORLW 00
4278 0B09: BTFSC 03.2
4279 0B0A: GOTO 311
4280 0B0B: INCF 51,F
4281 0B0C: MOVWF 52
4282 0B0D: BCF 0A.3
4283 0B0E: CALL 348
4284 0B0F: BSF 0A.3
4285 0B10: GOTO 304
4286 .................... Delay_ms(2000);
4287 0B11: MOVLW 08
4288 0B12: MOVWF 51
4289 0B13: MOVLW FA
4290 0B14: MOVWF 52
4291 0B15: BCF 0A.3
4292 0B16: CALL 1C8
4293 0B17: BSF 0A.3
4294 0B18: DECFSZ 51,F
4295 0B19: GOTO 313
4296 .................... fprintf(VRTULE,"[ZASUVKU[["); // " ZASUVKU "
4297 0B1A: CLRF 51
4298 0B1B: MOVF 51,W
4299 0B1C: BCF 0A.3
4300 0B1D: CALL 0E4
4301 0B1E: BSF 0A.3
4302 0B1F: IORLW 00
4303 0B20: BTFSC 03.2
4304 0B21: GOTO 328
4305 0B22: INCF 51,F
4306 0B23: MOVWF 52
4307 0B24: BCF 0A.3
4308 0B25: CALL 348
4309 0B26: BSF 0A.3
4310 0B27: GOTO 31B
4311 .................... Delay_ms(2000);
4312 0B28: MOVLW 08
4313 0B29: MOVWF 51
4314 0B2A: MOVLW FA
4315 0B2B: MOVWF 52
4316 0B2C: BCF 0A.3
4317 0B2D: CALL 1C8
4318 0B2E: BSF 0A.3
4319 0B2F: DECFSZ 51,F
4320 0B30: GOTO 32A
4321 .................... }
4322 0B31: INCF 4E,F
4323 0B32: GOTO 2FF
4324 .................... Delay_ms(5000);
4325 0B33: MOVLW 14
4326 0B34: MOVWF 51
4327 0B35: MOVLW FA
4328 0B36: MOVWF 52
4329 0B37: BCF 0A.3
4330 0B38: CALL 1C8
4331 0B39: BSF 0A.3
4332 0B3A: DECFSZ 51,F
4333 0B3B: GOTO 335
4334 .................... set_pwm1_duty(0);
4335 0B3C: CLRF 15
4336 .................... set_pwm2_duty(0);
4337 0B3D: CLRF 1B
4338 .................... del_sms();
4339 0B3E: BCF 0A.3
4340 0B3F: CALL 374
4341 0B40: BSF 0A.3
4342 .................... break;
4343 0B41: GOTO 532
4344 .................... }
247 kaklik 4345 ....................
246 kaklik 4346 .................... if (toupper(odp[0]) == 'H')
4347 0B42: MOVF 26,W
4348 0B43: SUBLW 60
4349 0B44: BTFSC 03.0
4350 0B45: GOTO 34D
4351 0B46: MOVF 26,W
4352 0B47: SUBLW 7A
4353 0B48: BTFSS 03.0
4354 0B49: GOTO 34D
4355 0B4A: MOVF 26,W
4356 0B4B: ANDLW DF
4357 0B4C: GOTO 34E
4358 0B4D: MOVF 26,W
4359 0B4E: SUBLW 48
4360 0B4F: BTFSS 03.2
4361 0B50: GOTO 3FD
4362 .................... {
4363 .................... set_pwm1_duty(VYKON);
4364 0B51: MOVLW 64
4365 0B52: MOVWF 15
4366 .................... set_pwm2_duty(VYKON);
4367 0B53: MOVWF 1B
4368 .................... Delay_ms(10000);
4369 0B54: MOVLW 28
4370 0B55: MOVWF 51
4371 0B56: MOVLW FA
4372 0B57: MOVWF 52
4373 0B58: BCF 0A.3
4374 0B59: CALL 1C8
4375 0B5A: BSF 0A.3
4376 0B5B: DECFSZ 51,F
4377 0B5C: GOTO 356
4378 .................... for(n=0;n<=1;n++)
4379 0B5D: CLRF 4E
4380 0B5E: MOVF 4E,W
4381 0B5F: SUBLW 01
4382 0B60: BTFSS 03.0
4383 0B61: GOTO 3EE
4384 .................... {
4385 .................... fprintf(VRTULE,"[[MARTIN[["); // " MARTIN "
4386 0B62: CLRF 51
4387 0B63: MOVF 51,W
4388 0B64: BCF 0A.3
4389 0B65: CALL 0F3
4390 0B66: BSF 0A.3
4391 0B67: IORLW 00
4392 0B68: BTFSC 03.2
4393 0B69: GOTO 370
4394 0B6A: INCF 51,F
4395 0B6B: MOVWF 52
4396 0B6C: BCF 0A.3
4397 0B6D: CALL 348
4398 0B6E: BSF 0A.3
4399 0B6F: GOTO 363
4400 .................... Delay_ms(2000);
4401 0B70: MOVLW 08
4402 0B71: MOVWF 51
4403 0B72: MOVLW FA
4404 0B73: MOVWF 52
4405 0B74: BCF 0A.3
4406 0B75: CALL 1C8
4407 0B76: BSF 0A.3
4408 0B77: DECFSZ 51,F
4409 0B78: GOTO 372
4410 .................... fprintf(VRTULE,"[[SVEJDA[["); // " SVEJDA "
4411 0B79: CLRF 51
4412 0B7A: MOVF 51,W
4413 0B7B: BCF 0A.3
4414 0B7C: CALL 105
4415 0B7D: BSF 0A.3
4416 0B7E: IORLW 00
4417 0B7F: BTFSC 03.2
4418 0B80: GOTO 387
4419 0B81: INCF 51,F
4420 0B82: MOVWF 52
4421 0B83: BCF 0A.3
4422 0B84: CALL 348
4423 0B85: BSF 0A.3
4424 0B86: GOTO 37A
4425 .................... Delay_ms(2000);
4426 0B87: MOVLW 08
4427 0B88: MOVWF 51
4428 0B89: MOVLW FA
4429 0B8A: MOVWF 52
4430 0B8B: BCF 0A.3
4431 0B8C: CALL 1C8
4432 0B8D: BSF 0A.3
4433 0B8E: DECFSZ 51,F
4434 0B8F: GOTO 389
4435 .................... fprintf(VRTULE,"[[TOMAS[[["); // " TOMAS "
4436 0B90: CLRF 51
4437 0B91: MOVF 51,W
4438 0B92: BCF 0A.3
4439 0B93: CALL 114
4440 0B94: BSF 0A.3
4441 0B95: IORLW 00
4442 0B96: BTFSC 03.2
4443 0B97: GOTO 39E
4444 0B98: INCF 51,F
4445 0B99: MOVWF 52
4446 0B9A: BCF 0A.3
4447 0B9B: CALL 348
4448 0B9C: BSF 0A.3
4449 0B9D: GOTO 391
4450 .................... Delay_ms(2000);
4451 0B9E: MOVLW 08
4452 0B9F: MOVWF 51
4453 0BA0: MOVLW FA
4454 0BA1: MOVWF 52
4455 0BA2: BCF 0A.3
4456 0BA3: CALL 1C8
4457 0BA4: BSF 0A.3
4458 0BA5: DECFSZ 51,F
4459 0BA6: GOTO 3A0
4460 .................... fprintf(VRTULE,"[[[KAPL[[["); // "KAPL"
4461 0BA7: CLRF 51
4462 0BA8: MOVF 51,W
4463 0BA9: BCF 0A.3
4464 0BAA: CALL 123
4465 0BAB: BSF 0A.3
4466 0BAC: IORLW 00
4467 0BAD: BTFSC 03.2
4468 0BAE: GOTO 3B5
4469 0BAF: INCF 51,F
4470 0BB0: MOVWF 52
4471 0BB1: BCF 0A.3
4472 0BB2: CALL 348
4473 0BB3: BSF 0A.3
4474 0BB4: GOTO 3A8
4475 .................... Delay_ms(2000);
4476 0BB5: MOVLW 08
4477 0BB6: MOVWF 51
4478 0BB7: MOVLW FA
4479 0BB8: MOVWF 52
4480 0BB9: BCF 0A.3
4481 0BBA: CALL 1C8
4482 0BBB: BSF 0A.3
4483 0BBC: DECFSZ 51,F
4484 0BBD: GOTO 3B7
4485 .................... fprintf(VRTULE,"[[JAKUB[[["); // " JAKUB "
4486 0BBE: CLRF 51
4487 0BBF: MOVF 51,W
4488 0BC0: BCF 0A.3
4489 0BC1: CALL 132
4490 0BC2: BSF 0A.3
4491 0BC3: IORLW 00
4492 0BC4: BTFSC 03.2
4493 0BC5: GOTO 3CC
4494 0BC6: INCF 51,F
4495 0BC7: MOVWF 52
4496 0BC8: BCF 0A.3
4497 0BC9: CALL 348
4498 0BCA: BSF 0A.3
4499 0BCB: GOTO 3BF
4500 .................... Delay_ms(2000);
4501 0BCC: MOVLW 08
4502 0BCD: MOVWF 51
4503 0BCE: MOVLW FA
4504 0BCF: MOVWF 52
4505 0BD0: BCF 0A.3
4506 0BD1: CALL 1C8
4507 0BD2: BSF 0A.3
4508 0BD3: DECFSZ 51,F
4509 0BD4: GOTO 3CE
4510 .................... fprintf(VRTULE,"[[KAKONA[["); // "KAKONA"
4511 0BD5: CLRF 51
4512 0BD6: MOVF 51,W
4513 0BD7: BCF 0A.3
4514 0BD8: CALL 141
4515 0BD9: BSF 0A.3
4516 0BDA: IORLW 00
4517 0BDB: BTFSC 03.2
4518 0BDC: GOTO 3E3
4519 0BDD: INCF 51,F
4520 0BDE: MOVWF 52
4521 0BDF: BCF 0A.3
4522 0BE0: CALL 348
4523 0BE1: BSF 0A.3
4524 0BE2: GOTO 3D6
4525 .................... Delay_ms(2000);
4526 0BE3: MOVLW 08
4527 0BE4: MOVWF 51
4528 0BE5: MOVLW FA
4529 0BE6: MOVWF 52
4530 0BE7: BCF 0A.3
4531 0BE8: CALL 1C8
4532 0BE9: BSF 0A.3
4533 0BEA: DECFSZ 51,F
4534 0BEB: GOTO 3E5
4535 .................... }
4536 0BEC: INCF 4E,F
4537 0BED: GOTO 35E
4538 .................... Delay_ms(3000);
4539 0BEE: MOVLW 0C
4540 0BEF: MOVWF 51
4541 0BF0: MOVLW FA
4542 0BF1: MOVWF 52
4543 0BF2: BCF 0A.3
4544 0BF3: CALL 1C8
4545 0BF4: BSF 0A.3
4546 0BF5: DECFSZ 51,F
4547 0BF6: GOTO 3F0
4548 .................... set_pwm1_duty(0);
4549 0BF7: CLRF 15
4550 .................... set_pwm2_duty(0);
4551 0BF8: CLRF 1B
4552 .................... del_sms();
4553 0BF9: BCF 0A.3
4554 0BFA: CALL 374
4555 0BFB: BSF 0A.3
4556 .................... break;
4557 0BFC: GOTO 532
4558 .................... }
4559 ....................
4560 .................... if (toupper(odp[0]) == 'I')
4561 0BFD: MOVF 26,W
4562 0BFE: SUBLW 60
4563 0BFF: BTFSC 03.0
4564 0C00: GOTO 408
4565 0C01: MOVF 26,W
4566 0C02: SUBLW 7A
4567 0C03: BTFSS 03.0
4568 0C04: GOTO 408
4569 0C05: MOVF 26,W
4570 0C06: ANDLW DF
4571 0C07: GOTO 409
4572 0C08: MOVF 26,W
4573 0C09: SUBLW 49
4574 0C0A: BTFSS 03.2
4575 0C0B: GOTO 4A2
4576 .................... {
4577 .................... set_pwm1_duty(VYKON);
4578 0C0C: MOVLW 64
4579 0C0D: MOVWF 15
4580 .................... set_pwm2_duty(VYKON);
4581 0C0E: MOVWF 1B
4582 .................... Delay_ms(10000);
4583 0C0F: MOVLW 28
4584 0C10: MOVWF 51
4585 0C11: MOVLW FA
4586 0C12: MOVWF 52
4587 0C13: BCF 0A.3
4588 0C14: CALL 1C8
4589 0C15: BSF 0A.3
4590 0C16: DECFSZ 51,F
4591 0C17: GOTO 411
4592 .................... for(n=0;n<=1;n++)
4593 0C18: CLRF 4E
4594 0C19: MOVF 4E,W
4595 0C1A: SUBLW 01
4596 0C1B: BTFSS 03.0
4597 0C1C: GOTO 492
4598 .................... {
4599 .................... fprintf(VRTULE,"ODPOVED[NA"); // "ODPOVED NA"
4600 0C1D: CLRF 51
4601 0C1E: MOVF 51,W
4602 0C1F: BCF 0A.3
4603 0C20: CALL 150
4604 0C21: BSF 0A.3
4605 0C22: IORLW 00
4606 0C23: BTFSC 03.2
4607 0C24: GOTO 42B
4608 0C25: INCF 51,F
4609 0C26: MOVWF 52
4610 0C27: BCF 0A.3
4611 0C28: CALL 348
4612 0C29: BSF 0A.3
4613 0C2A: GOTO 41E
4614 .................... Delay_ms(2000);
4615 0C2B: MOVLW 08
4616 0C2C: MOVWF 51
4617 0C2D: MOVLW FA
4618 0C2E: MOVWF 52
4619 0C2F: BCF 0A.3
4620 0C30: CALL 1C8
4621 0C31: BSF 0A.3
4622 0C32: DECFSZ 51,F
4623 0C33: GOTO 42D
4624 .................... fprintf(VRTULE,"[[VASI[[[["); // " VASI "
4625 0C34: CLRF 51
4626 0C35: MOVF 51,W
4627 0C36: BCF 0A.3
4628 0C37: CALL 15F
4629 0C38: BSF 0A.3
4630 0C39: IORLW 00
4631 0C3A: BTFSC 03.2
4632 0C3B: GOTO 442
4633 0C3C: INCF 51,F
4634 0C3D: MOVWF 52
4635 0C3E: BCF 0A.3
4636 0C3F: CALL 348
4637 0C40: BSF 0A.3
4638 0C41: GOTO 435
4639 .................... Delay_ms(2000);
4640 0C42: MOVLW 08
4641 0C43: MOVWF 51
4642 0C44: MOVLW FA
4643 0C45: MOVWF 52
4644 0C46: BCF 0A.3
4645 0C47: CALL 1C8
4646 0C48: BSF 0A.3
4647 0C49: DECFSZ 51,F
4648 0C4A: GOTO 444
4649 .................... fprintf(VRTULE,"[[OTAZKU[["); // " OTAZKU "
4650 0C4B: CLRF 51
4651 0C4C: MOVF 51,W
4652 0C4D: BCF 0A.3
4653 0C4E: CALL 16E
4654 0C4F: BSF 0A.3
4655 0C50: IORLW 00
4656 0C51: BTFSC 03.2
4657 0C52: GOTO 459
4658 0C53: INCF 51,F
4659 0C54: MOVWF 52
4660 0C55: BCF 0A.3
4661 0C56: CALL 348
4662 0C57: BSF 0A.3
4663 0C58: GOTO 44C
4664 .................... Delay_ms(2000);
4665 0C59: MOVLW 08
4666 0C5A: MOVWF 51
4667 0C5B: MOVLW FA
4668 0C5C: MOVWF 52
4669 0C5D: BCF 0A.3
4670 0C5E: CALL 1C8
4671 0C5F: BSF 0A.3
4672 0C60: DECFSZ 51,F
4673 0C61: GOTO 45B
4674 .................... fprintf(VRTULE,"[[[[JE[[[["); // "JE"
4675 0C62: CLRF 51
4676 0C63: MOVF 51,W
4677 0C64: BCF 0A.3
4678 0C65: CALL 17D
4679 0C66: BSF 0A.3
4680 0C67: IORLW 00
4681 0C68: BTFSC 03.2
4682 0C69: GOTO 470
4683 0C6A: INCF 51,F
4684 0C6B: MOVWF 52
4685 0C6C: BCF 0A.3
4686 0C6D: CALL 348
4687 0C6E: BSF 0A.3
4688 0C6F: GOTO 463
4689 .................... Delay_ms(2000);
4690 0C70: MOVLW 08
4691 0C71: MOVWF 51
4692 0C72: MOVLW FA
4693 0C73: MOVWF 52
4694 0C74: BCF 0A.3
4695 0C75: CALL 1C8
4696 0C76: BSF 0A.3
4697 0C77: DECFSZ 51,F
4698 0C78: GOTO 472
4699 .................... fprintf(VRTULE,"[[[[ec[[[["); // " 42 "
4700 0C79: CLRF 51
4701 0C7A: MOVF 51,W
4702 0C7B: BCF 0A.3
4703 0C7C: CALL 18C
4704 0C7D: BSF 0A.3
4705 0C7E: IORLW 00
4706 0C7F: BTFSC 03.2
4707 0C80: GOTO 487
4708 0C81: INCF 51,F
4709 0C82: MOVWF 52
4710 0C83: BCF 0A.3
4711 0C84: CALL 348
4712 0C85: BSF 0A.3
4713 0C86: GOTO 47A
4714 .................... Delay_ms(2000);
4715 0C87: MOVLW 08
4716 0C88: MOVWF 51
4717 0C89: MOVLW FA
4718 0C8A: MOVWF 52
4719 0C8B: BCF 0A.3
4720 0C8C: CALL 1C8
4721 0C8D: BSF 0A.3
4722 0C8E: DECFSZ 51,F
4723 0C8F: GOTO 489
4724 .................... }
4725 0C90: INCF 4E,F
4726 0C91: GOTO 419
4727 .................... Delay_ms(3000);
4728 0C92: MOVLW 0C
4729 0C93: MOVWF 51
4730 0C94: MOVLW FA
4731 0C95: MOVWF 52
4732 0C96: BCF 0A.3
4733 0C97: CALL 1C8
4734 0C98: BSF 0A.3
4735 0C99: DECFSZ 51,F
4736 0C9A: GOTO 494
4737 .................... set_pwm1_duty(0);
4738 0C9B: CLRF 15
4739 .................... set_pwm2_duty(0);
4740 0C9C: CLRF 1B
4741 .................... del_sms();
4742 0C9D: BCF 0A.3
4743 0C9E: CALL 374
4744 0C9F: BSF 0A.3
4745 .................... break;
4746 0CA0: GOTO 532
4747 .................... }
4748 .................... else
4749 0CA1: GOTO 4F8
4750 .................... {
4751 .................... set_pwm1_duty(VYKON);
4752 0CA2: MOVLW 64
4753 0CA3: MOVWF 15
4754 .................... set_pwm2_duty(VYKON);
4755 0CA4: MOVWF 1B
4756 .................... Delay_ms(10000);
4757 0CA5: MOVLW 28
4758 0CA6: MOVWF 51
4759 0CA7: MOVLW FA
4760 0CA8: MOVWF 52
4761 0CA9: BCF 0A.3
4762 0CAA: CALL 1C8
4763 0CAB: BSF 0A.3
4764 0CAC: DECFSZ 51,F
4765 0CAD: GOTO 4A7
4766 .................... fprintf(VRTULE,"[[NEUMIS[["); // "NEUMIS"
4767 0CAE: CLRF 51
4768 0CAF: MOVF 51,W
4769 0CB0: BCF 0A.3
4770 0CB1: CALL 19B
4771 0CB2: BSF 0A.3
4772 0CB3: IORLW 00
4773 0CB4: BTFSC 03.2
4774 0CB5: GOTO 4BC
4775 0CB6: INCF 51,F
4776 0CB7: MOVWF 52
4777 0CB8: BCF 0A.3
4778 0CB9: CALL 348
4779 0CBA: BSF 0A.3
4780 0CBB: GOTO 4AF
245 kaklik 4781 .................... Delay_ms(2000);
246 kaklik 4782 0CBC: MOVLW 08
4783 0CBD: MOVWF 51
4784 0CBE: MOVLW FA
4785 0CBF: MOVWF 52
4786 0CC0: BCF 0A.3
4787 0CC1: CALL 1C8
4788 0CC2: BSF 0A.3
4789 0CC3: DECFSZ 51,F
4790 0CC4: GOTO 4BE
4791 .................... fprintf(VRTULE,"[[[PSAT[[["); // " PSAT "
4792 0CC5: CLRF 51
4793 0CC6: MOVF 51,W
4794 0CC7: BCF 0A.3
4795 0CC8: CALL 1AA
4796 0CC9: BSF 0A.3
4797 0CCA: IORLW 00
4798 0CCB: BTFSC 03.2
4799 0CCC: GOTO 4D3
4800 0CCD: INCF 51,F
4801 0CCE: MOVWF 52
4802 0CCF: BCF 0A.3
4803 0CD0: CALL 348
4804 0CD1: BSF 0A.3
4805 0CD2: GOTO 4C6
245 kaklik 4806 .................... Delay_ms(2000);
246 kaklik 4807 0CD3: MOVLW 08
4808 0CD4: MOVWF 51
4809 0CD5: MOVLW FA
4810 0CD6: MOVWF 52
4811 0CD7: BCF 0A.3
4812 0CD8: CALL 1C8
4813 0CD9: BSF 0A.3
4814 0CDA: DECFSZ 51,F
4815 0CDB: GOTO 4D5
4816 .................... fprintf(VRTULE,"[[TRUBKO[["); // " TRUBKO "
4817 0CDC: CLRF 51
4818 0CDD: MOVF 51,W
4819 0CDE: BCF 0A.3
4820 0CDF: CALL 1B9
4821 0CE0: BSF 0A.3
4822 0CE1: IORLW 00
4823 0CE2: BTFSC 03.2
4824 0CE3: GOTO 4EA
4825 0CE4: INCF 51,F
4826 0CE5: MOVWF 52
4827 0CE6: BCF 0A.3
4828 0CE7: CALL 348
4829 0CE8: BSF 0A.3
4830 0CE9: GOTO 4DD
245 kaklik 4831 .................... Delay_ms(3000);
246 kaklik 4832 0CEA: MOVLW 0C
4833 0CEB: MOVWF 51
4834 0CEC: MOVLW FA
4835 0CED: MOVWF 52
4836 0CEE: BCF 0A.3
4837 0CEF: CALL 1C8
4838 0CF0: BSF 0A.3
4839 0CF1: DECFSZ 51,F
4840 0CF2: GOTO 4EC
245 kaklik 4841 .................... set_pwm1_duty(0);
246 kaklik 4842 0CF3: CLRF 15
245 kaklik 4843 .................... set_pwm2_duty(0);
246 kaklik 4844 0CF4: CLRF 1B
4845 .................... del_sms();
4846 0CF5: BCF 0A.3
4847 0CF6: CALL 374
4848 0CF7: BSF 0A.3
247 kaklik 4849 .................... }
240 kaklik 4850 .................... }
245 kaklik 4851 .................... read_time();
246 kaklik 4852 0CF8: BCF 0A.3
4853 0CF9: GOTO 37F
4854 0CFA: BSF 0A.3
240 kaklik 4855 .................... time=strtoul(odp,&ptr,10);
246 kaklik 4856 0CFB: MOVLW 26
4857 0CFC: MOVWF 51
4858 0CFD: MOVLW 4F
4859 0CFE: MOVWF 52
4860 0CFF: MOVLW 0A
4861 0D00: MOVWF 53
4862 0D01: BCF 0A.3
4863 0D02: GOTO 3D2
4864 0D03: BSF 0A.3
4865 0D04: MOVF 78,W
4866 0D05: MOVWF 50
4867 .................... if((time >= 30 && time <= 32) || (time >= 0 && time <= 2) || (time >= 45 && time <= 47) || (time >= 15 && time <= 17))
4868 0D06: MOVF 50,W
4869 0D07: SUBLW 1D
4870 0D08: BTFSC 03.0
4871 0D09: GOTO 50E
4872 0D0A: MOVF 50,W
4873 0D0B: SUBLW 20
4874 0D0C: BTFSC 03.0
4875 0D0D: GOTO 522
4876 0D0E: MOVF 50,W
4877 0D0F: SUBLW 02
4878 0D10: BTFSC 03.0
4879 0D11: GOTO 522
4880 0D12: MOVF 50,W
4881 0D13: SUBLW 2C
4882 0D14: BTFSC 03.0
4883 0D15: GOTO 51A
4884 0D16: MOVF 50,W
4885 0D17: SUBLW 2F
4886 0D18: BTFSC 03.0
4887 0D19: GOTO 522
4888 0D1A: MOVF 50,W
4889 0D1B: SUBLW 0E
4890 0D1C: BTFSC 03.0
4891 0D1D: GOTO 526
4892 0D1E: MOVF 50,W
4893 0D1F: SUBLW 11
4894 0D20: BTFSS 03.0
4895 0D21: GOTO 526
238 kaklik 4896 .................... {
246 kaklik 4897 .................... set_pwm1_duty(VYKON);
4898 0D22: MOVLW 64
4899 0D23: MOVWF 15
4900 .................... set_pwm2_duty(VYKON);
4901 0D24: MOVWF 1B
240 kaklik 4902 .................... }
4903 .................... else
246 kaklik 4904 0D25: GOTO 528
240 kaklik 4905 .................... {
4906 .................... set_pwm1_duty(0);
246 kaklik 4907 0D26: CLRF 15
240 kaklik 4908 .................... set_pwm2_duty(0);
246 kaklik 4909 0D27: CLRF 1B
245 kaklik 4910 .................... }
223 kapl 4911 ....................
238 kaklik 4912 .................... delay_ms(1000);
246 kaklik 4913 0D28: MOVLW 04
4914 0D29: MOVWF 51
4915 0D2A: MOVLW FA
4916 0D2B: MOVWF 52
4917 0D2C: BCF 0A.3
4918 0D2D: CALL 1C8
4919 0D2E: BSF 0A.3
4920 0D2F: DECFSZ 51,F
4921 0D30: GOTO 52A
223 kapl 4922 .................... }
246 kaklik 4923 0D31: GOTO 07B
223 kapl 4924 .................... }
246 kaklik 4925 0D32: SLEEP
223 kapl 4926  
4927 Configuration Fuses:
246 kaklik 4928 Word 1: 3F3E HS WDT NOPUT NODEBUG NOPROTECT NOBROWNOUT NOLVP NOCPD NOWRT