Rev Author Line No. Line
1045 jacho 1 CCS PCM C Compiler, Version 4.106, 47914 23-4-13 11:23
2  
3 Filename: C:\Users\Honza\Documents\pic\I2C_akcelerometr\main.lst
4  
5 ROM used: 4183 words (51%)
6 Largest free fragment is 2048
7 RAM used: 10 (3%) at main() level
8 70 (19%) worst case
9 Stack: 2 locations
10  
11 *
12 0000: MOVLW 10
13 0001: MOVWF 0A
14 0002: GOTO 000
15 0003: NOP
16 .................... //For AKCE
17 .................... //ADRESA pro èteni 0x39
18 .................... //pro zápis 0x38
19 ....................
20 ....................
21 ....................
22 .................... #include "C:\Users\Honza\Documents\pic\I2C_akcelerometr\main.h"
23 .................... #include <16F887.h>
24 .................... //////// Standard Header file for the PIC16F887 device ////////////////
25 .................... #device PIC16F887
26 .................... #list
27 ....................
28 .................... #device adc=8
29 ....................
30 .................... #FUSES NOWDT //No Watch Dog Timer
31 .................... #FUSES INTRC //Internal RC Osc
32 .................... #FUSES NOPUT //No Power Up Timer
33 .................... #FUSES MCLR //Master Clear pin enabled
34 .................... #FUSES NOPROTECT //Code not protected from reading
35 .................... #FUSES NOCPD //No EE protection
36 .................... #FUSES NOBROWNOUT //No brownout reset
37 .................... #FUSES IESO //Internal External Switch Over mode enabled
38 .................... #FUSES FCMEN //Fail-safe clock monitor enabled
39 .................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
40 .................... #FUSES NODEBUG //No Debug mode for ICD
41 .................... #FUSES NOWRT //Program memory not write protected
42 .................... #FUSES BORV40 //Brownout reset at 4.0V
43 ....................
44 .................... #use delay(clock=8000000)
45 *
46 075E: MOVLW 3D
47 075F: MOVWF 04
48 0760: BCF 03.7
49 0761: MOVF 00,W
50 0762: BTFSC 03.2
51 0763: GOTO 771
52 0764: MOVLW 02
53 0765: MOVWF 78
54 0766: CLRF 77
55 0767: DECFSZ 77,F
56 0768: GOTO 767
57 0769: DECFSZ 78,F
58 076A: GOTO 766
59 076B: MOVLW 97
60 076C: MOVWF 77
61 076D: DECFSZ 77,F
62 076E: GOTO 76D
63 076F: DECFSZ 00,F
64 0770: GOTO 764
65 0771: BCF 0A.3
66 0772: BSF 0A.4
67 0773: GOTO 64E (RETURN)
68 ....................
69 ....................
70 .................... #define EEPROM_SDA PIN_C4
71 .................... #define EEPROM_SCL PIN_C3
72 .................... #use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
73 *
74 0104: MOVLW 08
75 0105: MOVWF 78
76 0106: NOP
77 0107: BCF 07.3
78 0108: BCF 20.3
79 0109: MOVF 20,W
80 010A: BSF 03.5
81 010B: MOVWF 07
82 010C: NOP
83 010D: BCF 03.5
84 010E: RLF 3C,F
85 010F: BCF 07.4
86 0110: BTFSS 03.0
87 0111: GOTO 118
88 0112: BSF 20.4
89 0113: MOVF 20,W
90 0114: BSF 03.5
91 0115: MOVWF 07
92 0116: GOTO 11C
93 0117: BCF 03.5
94 0118: BCF 20.4
95 0119: MOVF 20,W
96 011A: BSF 03.5
97 011B: MOVWF 07
98 011C: NOP
99 011D: BCF 03.5
100 011E: BSF 20.3
101 011F: MOVF 20,W
102 0120: BSF 03.5
103 0121: MOVWF 07
104 0122: BCF 03.5
105 0123: BTFSS 07.3
106 0124: GOTO 123
107 0125: DECFSZ 78,F
108 0126: GOTO 106
109 0127: NOP
110 0128: BCF 07.3
111 0129: BCF 20.3
112 012A: MOVF 20,W
113 012B: BSF 03.5
114 012C: MOVWF 07
115 012D: NOP
116 012E: BCF 03.5
117 012F: BSF 20.4
118 0130: MOVF 20,W
119 0131: BSF 03.5
120 0132: MOVWF 07
121 0133: NOP
122 0134: NOP
123 0135: BCF 03.5
124 0136: BSF 20.3
125 0137: MOVF 20,W
126 0138: BSF 03.5
127 0139: MOVWF 07
128 013A: BCF 03.5
129 013B: BTFSS 07.3
130 013C: GOTO 13B
131 013D: CLRF 78
132 013E: NOP
133 013F: BTFSC 07.4
134 0140: BSF 78.0
135 0141: BCF 07.3
136 0142: BCF 20.3
137 0143: MOVF 20,W
138 0144: BSF 03.5
139 0145: MOVWF 07
140 0146: BCF 03.5
141 0147: BCF 07.4
142 0148: BCF 20.4
143 0149: MOVF 20,W
144 014A: BSF 03.5
145 014B: MOVWF 07
146 014C: BCF 03.5
147 014D: RETURN
148 014E: MOVLW 08
149 014F: MOVWF 3D
150 0150: MOVF 77,W
151 0151: MOVWF 3E
152 0152: BSF 20.4
153 0153: MOVF 20,W
154 0154: BSF 03.5
155 0155: MOVWF 07
156 0156: NOP
157 0157: BCF 03.5
158 0158: BSF 20.3
159 0159: MOVF 20,W
160 015A: BSF 03.5
161 015B: MOVWF 07
162 015C: BCF 03.5
163 015D: BTFSS 07.3
164 015E: GOTO 15D
165 015F: BTFSC 07.4
166 0160: BSF 03.0
167 0161: BTFSS 07.4
168 0162: BCF 03.0
169 0163: RLF 78,F
170 0164: NOP
171 0165: BCF 20.3
172 0166: MOVF 20,W
173 0167: BSF 03.5
174 0168: MOVWF 07
175 0169: BCF 03.5
176 016A: BCF 07.3
177 016B: DECFSZ 3D,F
178 016C: GOTO 152
179 016D: BSF 20.4
180 016E: MOVF 20,W
181 016F: BSF 03.5
182 0170: MOVWF 07
183 0171: NOP
184 0172: BCF 03.5
185 0173: BCF 07.4
186 0174: MOVF 3E,W
187 0175: BTFSC 03.2
188 0176: GOTO 17C
189 0177: BCF 20.4
190 0178: MOVF 20,W
191 0179: BSF 03.5
192 017A: MOVWF 07
193 017B: BCF 03.5
194 017C: NOP
195 017D: BSF 20.3
196 017E: MOVF 20,W
197 017F: BSF 03.5
198 0180: MOVWF 07
199 0181: BCF 03.5
200 0182: BTFSS 07.3
201 0183: GOTO 182
202 0184: NOP
203 0185: BCF 07.3
204 0186: BCF 20.3
205 0187: MOVF 20,W
206 0188: BSF 03.5
207 0189: MOVWF 07
208 018A: NOP
209 018B: BCF 03.5
210 018C: BCF 07.4
211 018D: BCF 20.4
212 018E: MOVF 20,W
213 018F: BSF 03.5
214 0190: MOVWF 07
215 0191: BCF 03.5
216 0192: RETURN
217 .................... #use rs232(baud=9600,parity=N,xmit=PIN_C7,rcv=PIN_C6,bits=8) //rcv TXD xmit RXD
218 *
219 0098: BCF 20.7
220 0099: MOVF 20,W
221 009A: BSF 03.5
222 009B: MOVWF 07
223 009C: BCF 03.5
224 009D: BCF 07.7
225 009E: MOVLW 08
226 009F: MOVWF 78
227 00A0: GOTO 0A1
228 00A1: NOP
229 00A2: BSF 78.7
230 00A3: GOTO 0B2
231 00A4: BCF 78.7
232 00A5: RRF 49,F
233 00A6: BTFSC 03.0
234 00A7: BSF 07.7
235 00A8: BTFSS 03.0
236 00A9: BCF 07.7
237 00AA: BSF 78.6
238 00AB: GOTO 0B2
239 00AC: BCF 78.6
240 00AD: DECFSZ 78,F
241 00AE: GOTO 0A5
242 00AF: GOTO 0B0
243 00B0: NOP
244 00B1: BSF 07.7
245 00B2: MOVLW 3F
246 00B3: MOVWF 04
247 00B4: DECFSZ 04,F
248 00B5: GOTO 0B4
249 00B6: NOP
250 00B7: BTFSC 78.7
251 00B8: GOTO 0A4
252 00B9: BTFSC 78.6
253 00BA: GOTO 0AC
254 00BB: RETURN
255 .................... #include <math.h>
256 .................... ////////////////////////////////////////////////////////////////////////////
257 .................... //// (C) Copyright 1996,2008 Custom Computer Services ////
258 .................... //// This source code may only be used by licensed users of the CCS C ////
259 .................... //// compiler. This source code may only be distributed to other ////
260 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
261 .................... //// or distribution is permitted without written permission. ////
262 .................... //// Derivative programs created using this software in object code ////
263 .................... //// form are not restricted in any way. ////
264 .................... ////////////////////////////////////////////////////////////////////////////
265 .................... //// ////
266 .................... //// History: ////
267 .................... //// * 9/20/2001 : Improvments are made to sin/cos code. ////
268 .................... //// The code now is small, much faster, ////
269 .................... //// and more accurate. ////
270 .................... //// * 2/21/2007 : Compiler handles & operator differently and does
271 .................... //// not return generic (int8 *) so type cast is done ////
272 .................... //// ////
273 .................... ////////////////////////////////////////////////////////////////////////////
274 ....................
275 .................... #ifndef MATH_H
276 .................... #define MATH_H
277 ....................
278 .................... #ifdef PI
279 .................... #undef PI
280 .................... #endif
281 .................... #define PI 3.1415926535897932
282 ....................
283 ....................
284 .................... #define SQRT2 1.4142135623730950
285 ....................
286 .................... //float const ps[4] = {5.9304945, 21.125224, 8.9403076, 0.29730279};
287 .................... //float const qs[4] = {1.0000000, 15.035723, 17.764134, 2.4934718};
288 ....................
289 .................... ///////////////////////////// Round Functions //////////////////////////////
290 ....................
291 .................... float32 CEIL_FLOOR(float32 x, unsigned int8 n)
292 .................... {
293 .................... float32 y, res;
294 .................... unsigned int16 l;
295 .................... int1 s;
296 ....................
297 .................... s = 0;
298 .................... y = x;
299 ....................
300 .................... if (x < 0)
301 .................... {
302 .................... s = 1;
303 .................... y = -y;
304 .................... }
305 ....................
306 .................... if (y <= 32768.0)
307 .................... res = (float32)(unsigned int16)y;
308 ....................
309 .................... else if (y < 10000000.0)
310 .................... {
311 .................... l = (unsigned int16)(y/32768.0);
312 .................... y = 32768.0*(y/32768.0 - (float32)l);
313 .................... res = 32768.0*(float32)l;
314 .................... res += (float32)(unsigned int16)y;
315 .................... }
316 ....................
317 .................... else
318 .................... res = y;
319 ....................
320 .................... y = y - (float32)(unsigned int16)y;
321 ....................
322 .................... if (s)
323 .................... res = -res;
324 ....................
325 .................... if (y != 0)
326 .................... {
327 .................... if (s == 1 && n == 0)
328 .................... res -= 1.0;
329 ....................
330 .................... if (s == 0 && n == 1)
331 .................... res += 1.0;
332 .................... }
333 .................... if (x == 0)
334 .................... res = 0;
335 ....................
336 .................... return (res);
337 .................... }
338 ....................
339 .................... // Overloaded Functions to take care for new Data types in PCD
340 .................... // Overloaded function CEIL_FLOOR() for data type - Float48
341 .................... #if defined(__PCD__)
342 .................... float48 CEIL_FLOOR(float48 x, unsigned int8 n)
343 .................... {
344 .................... float48 y, res;
345 .................... unsigned int16 l;
346 .................... int1 s;
347 ....................
348 .................... s = 0;
349 .................... y = x;
350 ....................
351 .................... if (x < 0)
352 .................... {
353 .................... s = 1;
354 .................... y = -y;
355 .................... }
356 ....................
357 .................... if (y <= 32768.0)
358 .................... res = (float48)(unsigned int16)y;
359 ....................
360 .................... else if (y < 10000000.0)
361 .................... {
362 .................... l = (unsigned int16)(y/32768.0);
363 .................... y = 32768.0*(y/32768.0 - (float48)l);
364 .................... res = 32768.0*(float32)l;
365 .................... res += (float48)(unsigned int16)y;
366 .................... }
367 ....................
368 .................... else
369 .................... res = y;
370 ....................
371 .................... y = y - (float48)(unsigned int16)y;
372 ....................
373 .................... if (s)
374 .................... res = -res;
375 ....................
376 .................... if (y != 0)
377 .................... {
378 .................... if (s == 1 && n == 0)
379 .................... res -= 1.0;
380 ....................
381 .................... if (s == 0 && n == 1)
382 .................... res += 1.0;
383 .................... }
384 .................... if (x == 0)
385 .................... res = 0;
386 ....................
387 .................... return (res);
388 .................... }
389 ....................
390 ....................
391 .................... // Overloaded function CEIL_FLOOR() for data type - Float64
392 .................... float64 CEIL_FLOOR(float64 x, unsigned int8 n)
393 .................... {
394 .................... float64 y, res;
395 .................... unsigned int16 l;
396 .................... int1 s;
397 ....................
398 .................... s = 0;
399 .................... y = x;
400 ....................
401 .................... if (x < 0)
402 .................... {
403 .................... s = 1;
404 .................... y = -y;
405 .................... }
406 ....................
407 .................... if (y <= 32768.0)
408 .................... res = (float64)(unsigned int16)y;
409 ....................
410 .................... else if (y < 10000000.0)
411 .................... {
412 .................... l = (unsigned int16)(y/32768.0);
413 .................... y = 32768.0*(y/32768.0 - (float64)l);
414 .................... res = 32768.0*(float64)l;
415 .................... res += (float64)(unsigned int16)y;
416 .................... }
417 ....................
418 .................... else
419 .................... res = y;
420 ....................
421 .................... y = y - (float64)(unsigned int16)y;
422 ....................
423 .................... if (s)
424 .................... res = -res;
425 ....................
426 .................... if (y != 0)
427 .................... {
428 .................... if (s == 1 && n == 0)
429 .................... res -= 1.0;
430 ....................
431 .................... if (s == 0 && n == 1)
432 .................... res += 1.0;
433 .................... }
434 .................... if (x == 0)
435 .................... res = 0;
436 ....................
437 .................... return (res);
438 .................... }
439 .................... #endif
440 ....................
441 .................... ////////////////////////////////////////////////////////////////////////////
442 .................... // float floor(float x)
443 .................... ////////////////////////////////////////////////////////////////////////////
444 .................... // Description : rounds down the number x.
445 .................... // Date : N/A
446 .................... //
447 .................... float32 floor(float32 x)
448 .................... {
449 .................... return CEIL_FLOOR(x, 0);
450 .................... }
451 .................... // Following 2 functions are overloaded functions of floor() for PCD
452 .................... // Overloaded function floor() for data type - Float48
453 .................... #if defined(__PCD__)
454 .................... float48 floor(float48 x)
455 .................... {
456 .................... return CEIL_FLOOR(x, 0);
457 .................... }
458 ....................
459 .................... // Overloaded function floor() for data type - Float64
460 .................... float64 floor(float64 x)
461 .................... {
462 .................... return CEIL_FLOOR(x, 0);
463 .................... }
464 .................... #endif
465 ....................
466 ....................
467 .................... ////////////////////////////////////////////////////////////////////////////
468 .................... // float ceil(float x)
469 .................... ////////////////////////////////////////////////////////////////////////////
470 .................... // Description : rounds up the number x.
471 .................... // Date : N/A
472 .................... //
473 .................... float32 ceil(float32 x)
474 .................... {
475 .................... return CEIL_FLOOR(x, 1);
476 .................... }
477 .................... // Following 2 functions are overloaded functions of ceil() for PCD
478 .................... // Overloaded function ceil() for data type - Float48
479 .................... #if defined(__PCD__)
480 .................... float48 ceil(float48 x)
481 .................... {
482 .................... return CEIL_FLOOR(x, 1);
483 .................... }
484 ....................
485 .................... // Overloaded function ceil() for data type - Float64
486 .................... float64 ceil(float64 x)
487 .................... {
488 .................... return CEIL_FLOOR(x, 1);
489 .................... }
490 .................... #endif
491 ....................
492 .................... ////////////////////////////////////////////////////////////////////////////
493 .................... // float fabs(float x)
494 .................... ////////////////////////////////////////////////////////////////////////////
495 .................... // Description : Computes the absolute value of floating point number x
496 .................... // Returns : returns the absolute value of x
497 .................... // Date : N/A
498 .................... //
499 .................... #define fabs abs
500 ....................
501 .................... ////////////////////////////////////////////////////////////////////////////
502 .................... // float fmod(float x)
503 .................... ////////////////////////////////////////////////////////////////////////////
504 .................... // Description : Computes the floating point remainder of x/y
505 .................... // Returns : returns the value of x= i*y, for some integer i such that, if y
506 .................... // is non zero, the result has the same isgn of x na dmagnitude less than the
507 .................... // magnitude of y. If y is zero then a domain error occurs.
508 .................... // Date : N/A
509 .................... //
510 ....................
511 .................... float fmod(float32 x,float32 y)
512 .................... {
513 .................... float32 i;
514 .................... if (y!=0.0)
515 .................... {
516 .................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);
517 .................... return(x-(i*y));
518 .................... }
519 .................... else
520 .................... {
521 .................... #ifdef _ERRNO
522 .................... {
523 .................... errno=EDOM;
524 .................... }
525 .................... #endif
526 .................... }
527 .................... }
528 .................... //Overloaded function for fmod() for PCD
529 .................... // Overloaded function fmod() for data type - Float48
530 .................... #if defined(__PCD__)
531 .................... float48 fmod(float48 x,float48 y)
532 .................... {
533 .................... float48 i;
534 .................... if (y!=0.0)
535 .................... {
536 .................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);
537 .................... return(x-(i*y));
538 .................... }
539 .................... else
540 .................... {
541 .................... #ifdef _ERRNO
542 .................... {
543 .................... errno=EDOM;
544 .................... }
545 .................... #endif
546 .................... }
547 .................... }
548 .................... // Overloaded function fmod() for data type - Float64
549 .................... float64 fmod(float64 x,float64 y)
550 .................... {
551 .................... float64 i;
552 .................... if (y!=0.0)
553 .................... {
554 .................... i=(x/y < 0.0)? ceil(x/y): floor(x/y);
555 .................... return(x-(i*y));
556 .................... }
557 .................... else
558 .................... {
559 .................... #ifdef _ERRNO
560 .................... {
561 .................... errno=EDOM;
562 .................... }
563 .................... #endif
564 .................... }
565 .................... }
566 .................... #endif
567 .................... //////////////////// Exponential and logarithmic functions ////////////////////
568 .................... ////////////////////////////////////////////////////////////////////////////
569 .................... // float exp(float x)
570 .................... ////////////////////////////////////////////////////////////////////////////
571 .................... // Description : returns the value (e^x)
572 .................... // Date : N/A
573 .................... //
574 .................... #define LN2 0.6931471805599453
575 ....................
576 .................... float const pe[6] = {0.000207455774, 0.00127100575, 0.00965065093,
577 .................... 0.0554965651, 0.240227138, 0.693147172};
578 ....................
579 ....................
580 .................... float32 exp(float32 x)
581 .................... {
582 .................... float32 y, res, r;
583 .................... #if defined(__PCD__)
584 .................... int8 data1;
585 .................... #endif
586 .................... signed int8 n;
587 .................... int1 s;
588 .................... #ifdef _ERRNO
589 .................... if(x > 88.722838)
590 .................... {
591 .................... errno=ERANGE;
592 .................... return(0);
593 .................... }
594 .................... #endif
595 .................... n = (signed int16)(x/LN2);
596 .................... s = 0;
597 .................... y = x;
598 ....................
599 .................... if (x < 0)
600 .................... {
601 .................... s = 1;
602 .................... n = -n;
603 .................... y = -y;
604 .................... }
605 ....................
606 .................... res = 0.0;
607 .................... #if !defined(__PCD__)
608 .................... *((unsigned int8 *)(&res)) = n + 0x7F;
609 .................... #endif
610 ....................
611 .................... #if defined(__PCD__) // Takes care of IEEE format for PCD
612 .................... data1 = n+0x7F;
613 .................... if(bit_test(data1,0))
614 .................... bit_set(*(((unsigned int8 *)(&res)+2)),7);
615 .................... rotate_right(&data1,1);
616 .................... bit_clear(data1,7);
617 .................... *(((unsigned int8 *)(&res)+3)) = data1;
618 .................... #endif
619 ....................
620 .................... y = y/LN2 - (float32)n;
621 ....................
622 .................... r = pe[0]*y + pe[1];
623 .................... r = r*y + pe[2];
624 .................... r = r*y + pe[3];
625 .................... r = r*y + pe[4];
626 .................... r = r*y + pe[5];
627 ....................
628 .................... res = res*(1.0 + y*r);
629 ....................
630 .................... if (s)
631 .................... res = 1.0/res;
632 .................... return(res);
633 .................... }
634 ....................
635 ....................
636 .................... //Overloaded function for exp() for PCD
637 .................... // Overloaded function exp() for data type - Float48
638 .................... #if defined(__PCD__)
639 .................... float48 exp(float48 x)
640 .................... {
641 .................... float48 y, res, r;
642 .................... int8 data1;
643 .................... signed int8 n;
644 .................... int1 s;
645 .................... #ifdef _ERRNO
646 .................... if(x > 88.722838)
647 .................... {
648 .................... errno=ERANGE;
649 .................... return(0);
650 .................... }
651 .................... #endif
652 .................... n = (signed int16)(x/LN2);
653 .................... s = 0;
654 .................... y = x;
655 ....................
656 .................... if (x < 0)
657 .................... {
658 .................... s = 1;
659 .................... n = -n;
660 .................... y = -y;
661 .................... }
662 ....................
663 .................... res = 0.0;
664 ....................
665 .................... data1 = n+0x7F;
666 .................... if(bit_test(data1,0))
667 .................... bit_set(*(((unsigned int8 *)(&res)+4)),7);
668 .................... rotate_right(&data1,1);
669 .................... bit_clear(data1,7);
670 .................... *(((unsigned int8 *)(&res)+5)) = data1;
671 ....................
672 .................... y = y/LN2 - (float48)n;
673 ....................
674 .................... r = pe[0]*y + pe[1];
675 .................... r = r*y + pe[2];
676 .................... r = r*y + pe[3];
677 .................... r = r*y + pe[4];
678 .................... r = r*y + pe[5];
679 ....................
680 .................... res = res*(1.0 + y*r);
681 ....................
682 .................... if (s)
683 .................... res = 1.0/res;
684 .................... return(res);
685 .................... }
686 ....................
687 .................... // Overloaded function exp() for data type - Float64
688 .................... float64 exp(float64 x)
689 .................... {
690 .................... float64 y, res, r;
691 .................... unsigned int16 data1, data2;
692 .................... unsigned int16 *p;
693 .................... signed int16 n;
694 .................... int1 s;
695 .................... #ifdef _ERRNO
696 .................... if(x > 709.7827128)
697 .................... {
698 .................... errno=ERANGE;
699 .................... return(0);
700 .................... }
701 .................... #endif
702 .................... n = (signed int16)(x/LN2);
703 .................... s = 0;
704 .................... y = x;
705 ....................
706 .................... if (x < 0)
707 .................... {
708 .................... s = 1;
709 .................... n = -n;
710 .................... y = -y;
711 .................... }
712 ....................
713 .................... res = 0.0;
714 ....................
715 .................... #if !defined(__PCD__)
716 .................... *((unsigned int16 *)(&res)) = n + 0x7F;
717 .................... #endif
718 .................... p= (((unsigned int16 *)(&res))+3);
719 .................... data1 = *p;
720 .................... data2 = *p;
721 .................... data1 = n + 0x3FF;
722 .................... data1 = data1 <<4;
723 .................... if(bit_test(data2,15))
724 .................... bit_set(data1,15);
725 .................... data2 = data2 & 0x000F;
726 .................... data1 ^= data2;
727 ....................
728 .................... *(((unsigned int16 *)(&res)+3)) = data1;
729 ....................
730 ....................
731 .................... y = y/LN2 - (float64)n;
732 ....................
733 .................... r = pe[0]*y + pe[1];
734 .................... r = r*y + pe[2];
735 .................... r = r*y + pe[3];
736 .................... r = r*y + pe[4];
737 .................... r = r*y + pe[5];
738 ....................
739 .................... res = res*(1.0 + y*r);
740 ....................
741 .................... if (s)
742 .................... res = 1.0/res;
743 .................... return(res);
744 .................... }
745 ....................
746 .................... #ENDIF
747 ....................
748 ....................
749 .................... /************************************************************/
750 ....................
751 .................... float32 const pl[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};
752 .................... float32 const ql[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943};
753 ....................
754 .................... ////////////////////////////////////////////////////////////////////////////
755 .................... // float log(float x)
756 .................... ////////////////////////////////////////////////////////////////////////////
757 .................... // Description : returns the the natural log of x
758 .................... // Date : N/A
759 .................... //
760 .................... float32 log(float32 x)
761 .................... {
762 .................... float32 y, res, r, y2;
763 .................... #if defined(__PCD__)
764 .................... unsigned int8 data1,data2;
765 .................... #endif
766 .................... signed int8 n;
767 .................... #ifdef _ERRNO
768 .................... if(x <0)
769 .................... {
770 .................... errno=EDOM;
771 .................... }
772 .................... if(x ==0)
773 .................... {
774 .................... errno=ERANGE;
775 .................... return(0);
776 .................... }
777 .................... #endif
778 .................... y = x;
779 ....................
780 .................... if (y != 1.0)
781 .................... {
782 .................... #if !defined(__PCD__)
783 .................... *((unsigned int8 *)(&y)) = 0x7E;
784 .................... #endif
785 ....................
786 .................... #if defined(__PCD__) // Takes care of IEEE format
787 .................... data2 = *(((unsigned int8 *)(&y))+3);
788 .................... *(((unsigned int8 *)(&y))+3) = 0x3F;
789 .................... data1 = *(((unsigned int8 *)(&y))+2);
790 .................... bit_clear(data1,7);
791 .................... *(((unsigned int8 *)(&y))+2) = data1;
792 .................... if(bit_test(data2,7))
793 .................... bit_set(*(((unsigned int8 *)(&y))+3),7);
794 .................... #endif
795 ....................
796 .................... y = (y - 1.0)/(y + 1.0);
797 ....................
798 .................... y2=y*y;
799 ....................
800 .................... res = pl[0]*y2 + pl[1];
801 .................... res = res*y2 + pl[2];
802 .................... res = res*y2 + pl[3];
803 ....................
804 .................... r = ql[0]*y2 + ql[1];
805 .................... r = r*y2 + ql[2];
806 .................... r = r*y2 + ql[3];
807 ....................
808 .................... res = y*res/r;
809 .................... #if !defined(__PCD__)
810 .................... n = *((unsigned int8 *)(&x)) - 0x7E;
811 .................... #endif
812 .................... #if defined(__PCD__)
813 .................... data1 = *(((unsigned int8 *)(&x)+3));
814 .................... rotate_left(&data1,1);
815 .................... data2 = *(((unsigned int8 *)(&x)+2));
816 .................... if(bit_test (data2,7))
817 .................... bit_set(data1,0);
818 .................... n = data1 - 0x7E;
819 .................... #endif
820 ....................
821 .................... if (n<0)
822 .................... r = -(float32)-n;
823 .................... else
824 .................... r = (float32)n;
825 ....................
826 .................... res += r*LN2;
827 .................... }
828 ....................
829 .................... else
830 .................... res = 0.0;
831 ....................
832 .................... return(res);
833 .................... }
834 ....................
835 .................... //Overloaded function for log() for PCD
836 .................... // Overloaded function log() for data type - Float48
837 .................... #if defined(__PCD__)
838 .................... float48 log(float48 x)
839 .................... {
840 .................... float48 y, res, r, y2;
841 .................... unsigned int8 data1,data2;
842 .................... signed int8 n;
843 .................... #ifdef _ERRNO
844 .................... if(x <0)
845 .................... {
846 .................... errno=EDOM;
847 .................... }
848 .................... if(x ==0)
849 .................... {
850 .................... errno=ERANGE;
851 .................... return(0);
852 .................... }
853 .................... #endif
854 .................... y = x;
855 ....................
856 .................... if (y != 1.0)
857 .................... {
858 ....................
859 .................... #if !defined(__PCD__)
860 .................... *((unsigned int8 *)(&y)) = 0x7E;
861 .................... #endif
862 .................... data2 = *(((unsigned int8 *)(&y))+5);
863 .................... *(((unsigned int8 *)(&y))+5) = 0x3F;
864 .................... data1 = *(((unsigned int8 *)(&y))+4);
865 .................... bit_clear(data1,7);
866 .................... *(((unsigned int8 *)(&y))+4) = data1;
867 ....................
868 .................... if(bit_test(data2,7))
869 .................... bit_set(*(((unsigned int8 *)(&y))+4),7);
870 .................... y = (y - 1.0)/(y + 1.0);
871 ....................
872 .................... y2=y*y;
873 ....................
874 .................... res = pl[0]*y2 + pl[1];
875 .................... res = res*y2 + pl[2];
876 .................... res = res*y2 + pl[3];
877 ....................
878 .................... r = ql[0]*y2 + ql[1];
879 .................... r = r*y2 + ql[2];
880 .................... r = r*y2 + ql[3];
881 ....................
882 .................... res = y*res/r;
883 ....................
884 .................... data1 = *(((unsigned int8 *)(&x)+5));
885 .................... rotate_left(&data1,1);
886 .................... data2 = *(((unsigned int8 *)(&x)+4));
887 .................... if(bit_test (data2,7))
888 .................... bit_set(data1,0);
889 ....................
890 .................... n = data1 - 0x7E;
891 ....................
892 .................... if (n<0)
893 .................... r = -(float48)-n;
894 .................... else
895 .................... r = (float48)n;
896 ....................
897 .................... res += r*LN2;
898 .................... }
899 ....................
900 .................... else
901 .................... res = 0.0;
902 ....................
903 .................... return(res);
904 .................... }
905 ....................
906 .................... // Overloaded function log() for data type - Float48
907 .................... #if defined(__PCD__)
908 .................... float32 const pl_64[4] = {0.45145214, -9.0558803, 26.940971, -19.860189};
909 .................... float32 const ql_64[4] = {1.0000000, -8.1354259, 16.780517, -9.9300943};
910 .................... #endif
911 .................... float64 log(float64 x)
912 .................... {
913 .................... float64 y, res, r, y2;
914 .................... unsigned int16 data1,data2;
915 .................... unsigned int16 *p;
916 .................... signed int16 n;
917 .................... #ifdef _ERRNO
918 .................... if(x <0)
919 .................... {
920 .................... errno=EDOM;
921 .................... }
922 .................... if(x ==0)
923 .................... {
924 .................... errno=ERANGE;
925 .................... return(0);
926 .................... }
927 .................... #endif
928 .................... y = x;
929 ....................
930 .................... if (y != 1.0)
931 .................... {
932 .................... #if !defined(__PCD__)
933 .................... *((unsigned int8 *)(&y)) = 0x7E;
934 .................... #endif
935 .................... p= (((unsigned int16 *)(&y))+3);
936 .................... data1 = *p;
937 .................... data2 = *p;
938 .................... data1 = 0x3FE;
939 .................... data1 = data1 <<4;
940 .................... if(bit_test (data2,15))
941 .................... bit_set(data1,15);
942 .................... data2 = data2 & 0x000F;
943 .................... data1 ^=data2;
944 ....................
945 .................... *p = data1;
946 ....................
947 .................... y = (y - 1.0)/(y + 1.0);
948 ....................
949 .................... y2=y*y;
950 ....................
951 .................... res = pl_64[0]*y2 + pl_64[1];
952 .................... res = res*y2 + pl_64[2];
953 .................... res = res*y2 + pl_64[3];
954 ....................
955 .................... r = ql_64[0]*y2 + ql_64[1];
956 .................... r = r*y2 + ql_64[2];
957 .................... r = r*y2 + ql_64[3];
958 ....................
959 .................... res = y*res/r;
960 ....................
961 .................... p= (((unsigned int16 *)(&x))+3);
962 .................... data1 = *p;
963 .................... bit_clear(data1,15);
964 .................... data1 = data1 >>4;
965 .................... n = data1 - 0x3FE;
966 ....................
967 ....................
968 .................... if (n<0)
969 .................... r = -(float64)-n;
970 .................... else
971 .................... r = (float64)n;
972 ....................
973 .................... res += r*LN2;
974 .................... }
975 ....................
976 .................... else
977 .................... res = 0.0;
978 ....................
979 .................... return(res);
980 .................... }
981 .................... #endif
982 ....................
983 ....................
984 .................... #define LN10 2.3025850929940456
985 ....................
986 .................... ////////////////////////////////////////////////////////////////////////////
987 .................... // float log10(float x)
988 .................... ////////////////////////////////////////////////////////////////////////////
989 .................... // Description : returns the the log base 10 of x
990 .................... // Date : N/A
991 .................... //
992 .................... float32 log10(float32 x)
993 .................... {
994 .................... float32 r;
995 ....................
996 .................... r = log(x);
997 .................... r = r/LN10;
998 .................... return(r);
999 .................... }
1000 ....................
1001 .................... //Overloaded functions for log10() for PCD
1002 .................... // Overloaded function log10() for data type - Float48
1003 .................... #if defined(__PCD__)
1004 .................... float48 log10(float48 x)
1005 .................... {
1006 .................... float48 r;
1007 ....................
1008 .................... r = log(x);
1009 .................... r = r/LN10;
1010 .................... return(r);
1011 .................... }
1012 ....................
1013 .................... // Overloaded function log10() for data type - Float64
1014 .................... float64 log10(float64 x)
1015 .................... {
1016 .................... float64 r;
1017 ....................
1018 .................... r = log(x);
1019 .................... r = r/LN10;
1020 .................... return(r);
1021 .................... }
1022 .................... #endif
1023 .................... ////////////////////////////////////////////////////////////////////////////
1024 .................... // float modf(float x)
1025 .................... ////////////////////////////////////////////////////////////////////////////
1026 .................... // Description :breaks the argument value int integral and fractional parts,
1027 .................... // ach of which have the same sign as the argument. It stores the integral part
1028 .................... // as a float in the object pointed to by the iptr
1029 .................... // Returns : returns the signed fractional part of value.
1030 .................... // Date : N/A
1031 .................... //
1032 ....................
1033 .................... float32 modf(float32 value,float32 *iptr)
1034 .................... {
1035 .................... *iptr=(value < 0.0)? ceil(value): floor(value);
1036 .................... return(value - *iptr);
1037 .................... }
1038 .................... //Overloaded functions for modf() for PCD
1039 .................... // Overloaded function modf() for data type - Float48
1040 .................... #if defined(__PCD__)
1041 .................... float48 modf(float48 value,float48 *iptr)
1042 .................... {
1043 .................... *iptr=(value < 0.0)? ceil(value): floor(value);
1044 .................... return(value - *iptr);
1045 .................... }
1046 .................... // Overloaded function modf() for data type - Float64
1047 .................... float64 modf(float64 value,float64 *iptr)
1048 .................... {
1049 .................... *iptr=(value < 0.0)? ceil(value): floor(value);
1050 .................... return(value - *iptr);
1051 .................... }
1052 .................... #endif
1053 ....................
1054 .................... ////////////////////////////////////////////////////////////////////////////
1055 .................... // float pwr(float x,float y)
1056 .................... ////////////////////////////////////////////////////////////////////////////
1057 .................... // Description : returns the value (x^y)
1058 .................... // Date : N/A
1059 .................... // Note : 0 is returned when the function will generate an imaginary number
1060 .................... //
1061 .................... float32 pwr(float32 x,float32 y)
1062 .................... {
1063 .................... if(0 > x && fmod(y, 1) == 0) {
1064 .................... if(fmod(y, 2) == 0) {
1065 .................... return (exp(log(-x) * y));
1066 .................... } else {
1067 .................... return (-exp(log(-x) * y));
1068 .................... }
1069 .................... } else if(0 > x && fmod(y, 1) != 0) {
1070 .................... return 0;
1071 .................... } else {
1072 .................... if(x != 0 || 0 >= y) {
1073 .................... return (exp(log(x) * y));
1074 .................... }
1075 .................... }
1076 .................... }
1077 .................... //Overloaded functions for pwr() for PCD
1078 .................... // Overloaded function pwr() for data type - Float48
1079 .................... #if defined(__PCD__)
1080 .................... float48 pwr(float48 x,float48 y)
1081 .................... {
1082 .................... if(0 > x && fmod(y, 1) == 0) {
1083 .................... if(fmod(y, 2) == 0) {
1084 .................... return (exp(log(-x) * y));
1085 .................... } else {
1086 .................... return (-exp(log(-x) * y));
1087 .................... }
1088 .................... } else if(0 > x && fmod(y, 1) != 0) {
1089 .................... return 0;
1090 .................... } else {
1091 .................... if(x != 0 || 0 >= y) {
1092 .................... return (exp(log(x) * y));
1093 .................... }
1094 .................... }
1095 .................... }
1096 .................... // Overloaded function pwr() for data type - Float64
1097 .................... float64 pwr(float64 x,float64 y)
1098 .................... {
1099 .................... if(0 > x && fmod(y, 1) == 0) {
1100 .................... if(fmod(y, 2) == 0) {
1101 .................... return (exp(log(-x) * y));
1102 .................... } else {
1103 .................... return (-exp(log(-x) * y));
1104 .................... }
1105 .................... } else if(0 > x && fmod(y, 1) != 0) {
1106 .................... return 0;
1107 .................... } else {
1108 .................... if(x != 0 || 0 >= y) {
1109 .................... return (exp(log(x) * y));
1110 .................... }
1111 .................... }
1112 .................... }
1113 .................... #endif
1114 ....................
1115 .................... //////////////////// Power functions ////////////////////
1116 ....................
1117 .................... ////////////////////////////////////////////////////////////////////////////
1118 .................... // float pow(float x,float y)
1119 .................... ////////////////////////////////////////////////////////////////////////////
1120 .................... // Description : returns the value (x^y)
1121 .................... // Date : N/A
1122 .................... // Note : 0 is returned when the function will generate an imaginary number
1123 .................... //
1124 .................... float32 pow(float32 x,float32 y)
1125 .................... {
1126 .................... if(0 > x && fmod(y, 1) == 0) {
1127 .................... if(fmod(y, 2) == 0) {
1128 .................... return (exp(log(-x) * y));
1129 .................... } else {
1130 .................... return (-exp(log(-x) * y));
1131 .................... }
1132 .................... } else if(0 > x && fmod(y, 1) != 0) {
1133 .................... return 0;
1134 .................... } else {
1135 .................... if(x != 0 || 0 >= y) {
1136 .................... return (exp(log(x) * y));
1137 .................... }
1138 .................... }
1139 .................... }
1140 .................... //Overloaded functions for pow() for PCD
1141 .................... // Overloaded function for pow() data type - Float48
1142 .................... #if defined(__PCD__)
1143 .................... float48 pow(float48 x,float48 y)
1144 .................... {
1145 .................... if(0 > x && fmod(y, 1) == 0) {
1146 .................... if(fmod(y, 2) == 0) {
1147 .................... return (exp(log(-x) * y));
1148 .................... } else {
1149 .................... return (-exp(log(-x) * y));
1150 .................... }
1151 .................... } else if(0 > x && fmod(y, 1) != 0) {
1152 .................... return 0;
1153 .................... } else {
1154 .................... if(x != 0 || 0 >= y) {
1155 .................... return (exp(log(x) * y));
1156 .................... }
1157 .................... }
1158 .................... }
1159 ....................
1160 .................... // Overloaded function pow() for data type - Float64
1161 .................... float64 pow(float64 x,float64 y)
1162 .................... {
1163 .................... if(0 > x && fmod(y, 1) == 0) {
1164 .................... if(fmod(y, 2) == 0) {
1165 .................... return (exp(log(-x) * y));
1166 .................... } else {
1167 .................... return (-exp(log(-x) * y));
1168 .................... }
1169 .................... } else if(0 > x && fmod(y, 1) != 0) {
1170 .................... return 0;
1171 .................... } else {
1172 .................... if(x != 0 || 0 >= y) {
1173 .................... return (exp(log(x) * y));
1174 .................... }
1175 .................... }
1176 .................... }
1177 .................... #endif
1178 ....................
1179 .................... ////////////////////////////////////////////////////////////////////////////
1180 .................... // float sqrt(float x)
1181 .................... ////////////////////////////////////////////////////////////////////////////
1182 .................... // Description : returns the square root of x
1183 .................... // Date : N/A
1184 .................... //
1185 .................... float32 sqrt(float32 x)
1186 .................... {
1187 .................... float32 y, res;
1188 .................... #if defined(__PCD__)
1189 .................... unsigned int16 data1,data2;
1190 .................... #endif
1191 .................... BYTE *p;
1192 ....................
1193 .................... #ifdef _ERRNO
1194 .................... if(x < 0)
1195 .................... {
1196 .................... errno=EDOM;
1197 .................... }
1198 .................... #endif
1199 ....................
1200 .................... if( x<=0.0)
1201 .................... return(0.0);
1202 ....................
1203 .................... y=x;
1204 ....................
1205 .................... #if !defined(__PCD__)
1206 .................... p=&y;
1207 .................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1);
1208 .................... #endif
1209 ....................
1210 .................... #if defined(__PCD__)
1211 .................... p = (((unsigned int8 *)(&y))+3);
1212 .................... data1 = *(((unsigned int8 *)(&y))+3);
1213 .................... data2 = *(((unsigned int8 *)(&y))+2);
1214 .................... rotate_left(&data1,1);
1215 .................... if(bit_test(data2,7))
1216 .................... bit_set(data1,0);
1217 .................... data1 = ((data1+127) >>1);
1218 .................... bit_clear(data2,7);
1219 .................... if(bit_test(data1,0))
1220 .................... bit_set(data2,7);
1221 .................... data1 = data1 >>1;
1222 .................... *(((unsigned int8 *)(&y))+3) = data1;
1223 .................... *(((unsigned int8 *)(&y))+2) = data2;
1224 ....................
1225 .................... #endif
1226 ....................
1227 .................... do {
1228 .................... res=y;
1229 .................... y+=(x/y);
1230 ....................
1231 .................... #if !defined(__PCD__)
1232 .................... (*p)--;
1233 .................... #endif
1234 ....................
1235 .................... #if defined(__PCD__)
1236 .................... data1 = *(((unsigned int8 *)(&y))+3);
1237 .................... data2 = *(((unsigned int8 *)(&y))+2);
1238 .................... rotate_left(&data1,1);
1239 .................... if(bit_test(data2,7))
1240 .................... bit_set(data1,0);
1241 .................... data1--;
1242 .................... bit_clear(data2,7);
1243 .................... if(bit_test(data1,0))
1244 .................... bit_set(data2,7);
1245 .................... data1 = data1 >>1;
1246 .................... *(((unsigned int8 *)(&y))+3) = data1;
1247 .................... *(((unsigned int8 *)(&y))+2) = data2;
1248 ....................
1249 .................... #endif
1250 .................... } while(res != y);
1251 ....................
1252 .................... return(res);
1253 .................... }
1254 .................... //Overloaded functions for sqrt() for PCD
1255 .................... // Overloaded function sqrt() for data type - Float48
1256 .................... #if defined(__PCD__)
1257 .................... float48 sqrt(float48 x)
1258 .................... {
1259 .................... float48 y, res;
1260 .................... unsigned int16 data1,data2;
1261 .................... BYTE *p;
1262 ....................
1263 .................... #ifdef _ERRNO
1264 .................... if(x < 0)
1265 .................... {
1266 .................... errno=EDOM;
1267 .................... }
1268 .................... #endif
1269 ....................
1270 .................... if( x<=0.0)
1271 .................... return(0.0);
1272 ....................
1273 .................... y=x;
1274 ....................
1275 .................... #if !defined(__PCD__)
1276 .................... p=&y;
1277 .................... (*p)=(BYTE)((((unsigned int16)(*p)) + 127) >> 1);
1278 .................... #endif
1279 ....................
1280 .................... #if defined(__PCD__)
1281 .................... p = (((unsigned int8 *)(&y))+5);
1282 .................... data1 = *(((unsigned int8 *)(&y))+5);
1283 .................... data2 = *(((unsigned int8 *)(&y))+4);
1284 .................... rotate_left(&data1,1);
1285 .................... if(bit_test(data2,7))
1286 .................... bit_set(data1,0);
1287 .................... data1 = ((data1+127) >>1);
1288 .................... bit_clear(data2,7);
1289 .................... if(bit_test(data1,0))
1290 .................... bit_set(data2,7);
1291 .................... data1 = data1 >>1;
1292 .................... *(((unsigned int8 *)(&y))+5) = data1;
1293 .................... *(((unsigned int8 *)(&y))+4) = data2;
1294 ....................
1295 .................... #endif
1296 ....................
1297 .................... do {
1298 .................... res=y;
1299 .................... y+=(x/y);
1300 ....................
1301 .................... #if !defined(__PCD__)
1302 .................... (*p)--;
1303 .................... #endif
1304 ....................
1305 .................... data1 = *(((unsigned int8 *)(&y))+5);
1306 .................... data2 = *(((unsigned int8 *)(&y))+4);
1307 .................... rotate_left(&data1,1);
1308 .................... if(bit_test(data2,7))
1309 .................... bit_set(data1,0);
1310 .................... data1--;
1311 .................... bit_clear(data2,7);
1312 .................... if(bit_test(data1,0))
1313 .................... bit_set(data2,7);
1314 .................... data1 = data1 >>1;
1315 .................... *(((unsigned int8 *)(&y))+5) = data1;
1316 .................... *(((unsigned int8 *)(&y))+4) = data2;
1317 ....................
1318 .................... } while(res != y);
1319 ....................
1320 .................... return(res);
1321 .................... }
1322 ....................
1323 .................... // Overloaded function sqrt() for data type - Float64
1324 .................... float64 sqrt(float64 x)
1325 .................... {
1326 .................... float64 y, res;
1327 .................... unsigned int16 *p;
1328 .................... unsigned int16 temp1,temp2;
1329 ....................
1330 .................... #ifdef _ERRNO
1331 .................... if(x < 0)
1332 .................... {
1333 .................... errno=EDOM;
1334 .................... }
1335 .................... #endif
1336 ....................
1337 .................... if( x<=0.0)
1338 .................... return(0.0);
1339 ....................
1340 .................... y=x;
1341 .................... p= (((unsigned int16 *)(&y))+3);
1342 .................... temp1 = *p;
1343 .................... temp2 = *p;
1344 .................... bit_clear(temp1,15);
1345 .................... temp1 = (temp1>>4)+1023;
1346 .................... temp1 = temp1 >> 1;
1347 .................... temp1 = (temp1<<4) & 0xFFF0;
1348 .................... if(bit_test(temp2,15))
1349 .................... bit_set(temp1,15);
1350 .................... temp2 = temp2 & 0x000F;
1351 .................... temp1 ^= temp2;
1352 ....................
1353 .................... (*p) = temp1;
1354 ....................
1355 .................... do {
1356 .................... res=y;
1357 .................... y+=(x/y);
1358 .................... temp1 = *p;
1359 .................... temp2 = *p;
1360 .................... bit_clear(temp1,15);
1361 .................... temp1 = (temp1>>4);
1362 .................... temp1--;
1363 .................... temp1 = (temp1<<4) & 0xFFF0;
1364 .................... if(bit_test(temp2,15))
1365 .................... bit_set(temp1,15);
1366 .................... temp2 = temp2 & 0x000F;
1367 .................... temp1 ^= temp2;
1368 .................... (*p) = temp1;
1369 ....................
1370 .................... } while(res != y);
1371 ....................
1372 .................... return(res);
1373 .................... }
1374 .................... #endif
1375 ....................
1376 .................... ////////////////////////////// Trig Functions //////////////////////////////
1377 .................... #ifdef PI_DIV_BY_TWO
1378 .................... #undef PI_DIV_BY_TWO
1379 .................... #endif
1380 .................... #define PI_DIV_BY_TWO 1.5707963267948966
1381 .................... #ifdef TWOBYPI
1382 .................... #undef TWOBYPI
1383 .................... #define TWOBYPI 0.6366197723675813
1384 .................... #endif
1385 .................... ////////////////////////////////////////////////////////////////////////////
1386 .................... // float cos(float x)
1387 .................... ////////////////////////////////////////////////////////////////////////////
1388 .................... // Description : returns the cosine value of the angle x, which is in radian
1389 .................... // Date : 9/20/2001
1390 .................... //
1391 .................... float32 cos(float32 x)
1392 .................... {
1393 .................... float32 y, t, t2 = 1.0;
1394 .................... unsigned int8 quad, i;
1395 .................... float32 frac;
1396 .................... float32 p[6] = { //by the series definition for cosine
1397 .................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
1398 .................... 0.04166666666667,
1399 .................... -0.00138888888889,
1400 .................... 0.00002480158730,
1401 .................... -0.00000027557319,
1402 .................... 0.00000000208767,
1403 .................... //-0.00000000001147,
1404 .................... // 0.00000000000005
1405 .................... };
1406 ....................
1407 .................... if (x < 0) x = -x; // absolute value of input
1408 ....................
1409 .................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
1410 .................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
1411 .................... quad = quad % 4; // quadrant (0 to 3)
1412 ....................
1413 .................... if (quad == 0 || quad == 2)
1414 .................... t = frac * PI_DIV_BY_TWO;
1415 .................... else if (quad == 1)
1416 .................... t = (1-frac) * PI_DIV_BY_TWO;
1417 .................... else // should be 3
1418 .................... t = (frac-1) * PI_DIV_BY_TWO;
1419 ....................
1420 .................... y = 1.0;
1421 .................... t = t * t;
1422 .................... for (i = 0; i <= 5; i++)
1423 .................... {
1424 .................... t2 = t2 * t;
1425 .................... y = y + p[i] * t2;
1426 .................... }
1427 ....................
1428 .................... if (quad == 2 || quad == 1)
1429 .................... y = -y; // correct sign
1430 ....................
1431 .................... return (y);
1432 .................... }
1433 ....................
1434 ....................
1435 .................... //Overloaded functions for cos() for PCD
1436 .................... // Overloaded function cos() for data type - Float48
1437 .................... #if defined(__PCD__)
1438 .................... float48 cos(float48 x)
1439 .................... {
1440 .................... float48 y, t, t2 = 1.0;
1441 .................... unsigned int8 quad, i;
1442 .................... float48 frac;
1443 .................... float48 p[6] = { //by the series definition for cosine
1444 .................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
1445 .................... 0.04166666666667,
1446 .................... -0.00138888888889,
1447 .................... 0.00002480158730,
1448 .................... -0.00000027557319,
1449 .................... 0.00000000208767,
1450 .................... //-0.00000000001147,
1451 .................... // 0.00000000000005
1452 .................... };
1453 ....................
1454 .................... if (x < 0) x = -x; // absolute value of input
1455 ....................
1456 .................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
1457 .................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
1458 .................... quad = quad % 4; // quadrant (0 to 3)
1459 ....................
1460 .................... if (quad == 0 || quad == 2)
1461 .................... t = frac * PI_DIV_BY_TWO;
1462 .................... else if (quad == 1)
1463 .................... t = (1-frac) * PI_DIV_BY_TWO;
1464 .................... else // should be 3
1465 .................... t = (frac-1) * PI_DIV_BY_TWO;
1466 ....................
1467 .................... y = 0.999999999781;
1468 .................... t = t * t;
1469 .................... for (i = 0; i <= 5; i++)
1470 .................... {
1471 .................... t2 = t2 * t;
1472 .................... y = y + p[i] * t2;
1473 .................... }
1474 ....................
1475 .................... if (quad == 2 || quad == 1)
1476 .................... y = -y; // correct sign
1477 ....................
1478 .................... return (y);
1479 .................... }
1480 ....................
1481 .................... // Overloaded function cos() for data type - Float48
1482 .................... float64 cos(float64 x)
1483 .................... {
1484 .................... float64 y, t, t2 = 1.0;
1485 .................... unsigned int8 quad, i;
1486 .................... float64 frac;
1487 .................... float64 p[6] = { //by the series definition for cosine
1488 .................... -0.5, // sum ( ( (-1)^n * x^2n )/(2n)! )
1489 .................... 0.04166666666667,
1490 .................... -0.00138888888889,
1491 .................... 0.00002480158730,
1492 .................... -0.00000027557319,
1493 .................... 0.00000000208767,
1494 .................... //-0.00000000001147,
1495 .................... // 0.00000000000005
1496 .................... };
1497 ....................
1498 .................... if (x < 0) x = -x; // absolute value of input
1499 ....................
1500 .................... quad = (unsigned int8)(x / PI_DIV_BY_TWO); // quadrant
1501 .................... frac = (x / PI_DIV_BY_TWO) - quad; // fractional part of input
1502 .................... quad = quad % 4; // quadrant (0 to 3)
1503 ....................
1504 .................... if (quad == 0 || quad == 2)
1505 .................... t = frac * PI_DIV_BY_TWO;
1506 .................... else if (quad == 1)
1507 .................... t = (1-frac) * PI_DIV_BY_TWO;
1508 .................... else // should be 3
1509 .................... t = (frac-1) * PI_DIV_BY_TWO;
1510 ....................
1511 .................... y = 0.999999999781;
1512 .................... t = t * t;
1513 .................... for (i = 0; i <= 5; i++)
1514 .................... {
1515 .................... t2 = t2 * t;
1516 .................... y = y + p[i] * t2;
1517 .................... }
1518 ....................
1519 .................... if (quad == 2 || quad == 1)
1520 .................... y = -y; // correct sign
1521 ....................
1522 .................... return (y);
1523 .................... }
1524 ....................
1525 .................... #endif
1526 ....................
1527 .................... ////////////////////////////////////////////////////////////////////////////
1528 .................... // float sin(float x)
1529 .................... ////////////////////////////////////////////////////////////////////////////
1530 .................... // Description : returns the sine value of the angle x, which is in radian
1531 .................... // Date : 9/20/2001
1532 .................... //
1533 .................... float32 sin(float32 x)
1534 .................... {
1535 .................... return cos(x - PI_DIV_BY_TWO);
1536 .................... }
1537 ....................
1538 .................... //Overloaded functions for sin() for PCD
1539 .................... // Overloaded function sin() for data type - Float48
1540 .................... #if defined(__PCD__)
1541 .................... float48 sin(float48 x)
1542 .................... {
1543 .................... return cos(x - PI_DIV_BY_TWO);
1544 .................... }
1545 ....................
1546 .................... // Overloaded function sin() for data type - Float48
1547 .................... float64 sin(float64 x)
1548 .................... {
1549 .................... return cos(x - PI_DIV_BY_TWO);
1550 .................... }
1551 .................... #endif
1552 ....................
1553 .................... ////////////////////////////////////////////////////////////////////////////
1554 .................... // float tan(float x)
1555 .................... ////////////////////////////////////////////////////////////////////////////
1556 .................... // Description : returns the tangent value of the angle x, which is in radian
1557 .................... // Date : 9/20/2001
1558 .................... //
1559 .................... float32 tan(float32 x)
1560 .................... {
1561 .................... float32 c, s;
1562 ....................
1563 .................... c = cos(x);
1564 .................... if (c == 0.0)
1565 .................... return (1.0e+36);
1566 ....................
1567 .................... s = sin(x);
1568 .................... return(s/c);
1569 .................... }
1570 .................... //Overloaded functions for tan() for PCD
1571 .................... // Overloaded function tan() for data type - Float48
1572 .................... #if defined(__PCD__)
1573 .................... float48 tan(float48 x)
1574 .................... {
1575 .................... float48 c, s;
1576 ....................
1577 .................... c = cos(x);
1578 .................... if (c == 0.0)
1579 .................... return (1.0e+36);
1580 ....................
1581 .................... s = sin(x);
1582 .................... return(s/c);
1583 .................... }
1584 ....................
1585 .................... // Overloaded function tan() for data type - Float48
1586 .................... float64 tan(float64 x)
1587 .................... {
1588 .................... float64 c, s;
1589 ....................
1590 .................... c = cos(x);
1591 .................... if (c == 0.0)
1592 .................... return (1.0e+36);
1593 ....................
1594 .................... s = sin(x);
1595 .................... return(s/c);
1596 .................... }
1597 .................... #endif
1598 ....................
1599 .................... float32 const pas[3] = {0.49559947, -4.6145309, 5.6036290};
1600 .................... float32 const qas[3] = {1.0000000, -5.5484666, 5.6036290};
1601 ....................
1602 .................... float32 ASIN_COS(float32 x, unsigned int8 n)
1603 .................... {
1604 .................... float32 y, res, r, y2;
1605 .................... int1 s;
1606 .................... #ifdef _ERRNO
1607 .................... if(x <-1 || x > 1)
1608 .................... {
1609 .................... errno=EDOM;
1610 .................... }
1611 .................... #endif
1612 .................... s = 0;
1613 .................... y = x;
1614 ....................
1615 .................... if (x < 0)
1616 .................... {
1617 .................... s = 1;
1618 .................... y = -y;
1619 .................... }
1620 ....................
1621 .................... if (y > 0.5)
1622 .................... {
1623 .................... y = sqrt((1.0 - y)/2.0);
1624 .................... n += 2;
1625 .................... }
1626 ....................
1627 .................... y2=y*y;
1628 ....................
1629 .................... res = pas[0]*y2 + pas[1];
1630 .................... res = res*y2 + pas[2];
1631 ....................
1632 .................... r = qas[0]*y2 + qas[1];
1633 .................... r = r*y2 + qas[2];
1634 ....................
1635 .................... res = y*res/r;
1636 ....................
1637 .................... if (n & 2) // |x| > 0.5
1638 .................... res = PI_DIV_BY_TWO - 2.0*res;
1639 .................... if (s)
1640 .................... res = -res;
1641 .................... if (n & 1) // take arccos
1642 .................... res = PI_DIV_BY_TWO - res;
1643 ....................
1644 .................... return(res);
1645 .................... }
1646 ....................
1647 .................... //Overloaded functions for ASIN_COS() for PCD
1648 .................... // Overloaded function ASIN_COS() for data type - Float48
1649 .................... #if defined(__PCD__)
1650 .................... float48 ASIN_COS(float48 x, unsigned int8 n)
1651 .................... {
1652 .................... float48 y, res, r, y2;
1653 .................... int1 s;
1654 .................... #ifdef _ERRNO
1655 .................... if(x <-1 || x > 1)
1656 .................... {
1657 .................... errno=EDOM;
1658 .................... }
1659 .................... #endif
1660 .................... s = 0;
1661 .................... y = x;
1662 ....................
1663 .................... if (x < 0)
1664 .................... {
1665 .................... s = 1;
1666 .................... y = -y;
1667 .................... }
1668 ....................
1669 .................... if (y > 0.5)
1670 .................... {
1671 .................... y = sqrt((1.0 - y)/2.0);
1672 .................... n += 2;
1673 .................... }
1674 ....................
1675 .................... y2=y*y;
1676 ....................
1677 .................... res = pas[0]*y2 + pas[1];
1678 .................... res = res*y2 + pas[2];
1679 ....................
1680 .................... r = qas[0]*y2 + qas[1];
1681 .................... r = r*y2 + qas[2];
1682 ....................
1683 .................... res = y*res/r;
1684 ....................
1685 .................... if (n & 2) // |x| > 0.5
1686 .................... res = PI_DIV_BY_TWO - 2.0*res;
1687 .................... if (s)
1688 .................... res = -res;
1689 .................... if (n & 1) // take arccos
1690 .................... res = PI_DIV_BY_TWO - res;
1691 ....................
1692 .................... return(res);
1693 .................... }
1694 ....................
1695 .................... // Overloaded function ASIN_COS() for data type - Float64
1696 .................... float64 ASIN_COS(float64 x, unsigned int8 n)
1697 .................... {
1698 .................... float64 y, res, r, y2;
1699 .................... int1 s;
1700 .................... #ifdef _ERRNO
1701 .................... if(x <-1 || x > 1)
1702 .................... {
1703 .................... errno=EDOM;
1704 .................... }
1705 .................... #endif
1706 .................... s = 0;
1707 .................... y = x;
1708 ....................
1709 .................... if (x < 0)
1710 .................... {
1711 .................... s = 1;
1712 .................... y = -y;
1713 .................... }
1714 ....................
1715 .................... if (y > 0.5)
1716 .................... {
1717 .................... y = sqrt((1.0 - y)/2.0);
1718 .................... n += 2;
1719 .................... }
1720 ....................
1721 .................... y2=y*y;
1722 ....................
1723 .................... res = pas[0]*y2 + pas[1];
1724 .................... res = res*y2 + pas[2];
1725 ....................
1726 .................... r = qas[0]*y2 + qas[1];
1727 .................... r = r*y2 + qas[2];
1728 ....................
1729 .................... res = y*res/r;
1730 ....................
1731 .................... if (n & 2) // |x| > 0.5
1732 .................... res = PI_DIV_BY_TWO - 2.0*res;
1733 .................... if (s)
1734 .................... res = -res;
1735 .................... if (n & 1) // take arccos
1736 .................... res = PI_DIV_BY_TWO - res;
1737 ....................
1738 .................... return(res);
1739 .................... }
1740 .................... #endif
1741 ....................
1742 .................... ////////////////////////////////////////////////////////////////////////////
1743 .................... // float asin(float x)
1744 .................... ////////////////////////////////////////////////////////////////////////////
1745 .................... // Description : returns the arcsine value of the value x.
1746 .................... // Date : N/A
1747 .................... //
1748 .................... float32 asin(float32 x)
1749 .................... {
1750 .................... float32 r;
1751 ....................
1752 .................... r = ASIN_COS(x, 0);
1753 .................... return(r);
1754 .................... }
1755 .................... //Overloaded functions for asin() for PCD
1756 .................... // Overloaded function asin() for data type - Float48
1757 .................... #if defined(__PCD__)
1758 .................... float48 asin(float48 x)
1759 .................... {
1760 .................... float48 r;
1761 ....................
1762 .................... r = ASIN_COS(x, 0);
1763 .................... return(r);
1764 .................... }
1765 ....................
1766 .................... // Overloaded function asin() for data type - Float64
1767 .................... float64 asin(float64 x)
1768 .................... {
1769 .................... float64 r;
1770 ....................
1771 .................... r = ASIN_COS(x, 0);
1772 .................... return(r);
1773 .................... }
1774 .................... #endif
1775 ....................
1776 .................... ////////////////////////////////////////////////////////////////////////////
1777 .................... // float acos(float x)
1778 .................... ////////////////////////////////////////////////////////////////////////////
1779 .................... // Description : returns the arccosine value of the value x.
1780 .................... // Date : N/A
1781 .................... //
1782 .................... float32 acos(float32 x)
1783 .................... {
1784 .................... float32 r;
1785 ....................
1786 .................... r = ASIN_COS(x, 1);
1787 .................... return(r);
1788 .................... }
1789 .................... //Overloaded functions for acos() for PCD
1790 .................... // Overloaded function acos() for data type - Float48
1791 .................... #if defined(__PCD__)
1792 .................... float48 acos(float48 x)
1793 .................... {
1794 .................... float48 r;
1795 ....................
1796 .................... r = ASIN_COS(x, 1);
1797 .................... return(r);
1798 .................... }
1799 ....................
1800 .................... // Overloaded function acos() for data type - Float64
1801 .................... float64 acos(float64 x)
1802 .................... {
1803 .................... float64 r;
1804 ....................
1805 .................... r = ASIN_COS(x, 1);
1806 .................... return(r);
1807 .................... }
1808 .................... #endif
1809 ....................
1810 .................... float32 const pat[4] = {0.17630401, 5.6710795, 22.376096, 19.818457};
1811 .................... float32 const qat[4] = {1.0000000, 11.368190, 28.982246, 19.818457};
1812 ....................
1813 .................... ////////////////////////////////////////////////////////////////////////////
1814 .................... // float atan(float x)
1815 .................... ////////////////////////////////////////////////////////////////////////////
1816 .................... // Description : returns the arctangent value of the value x.
1817 .................... // Date : N/A
1818 .................... //
1819 .................... float32 atan(float32 x)
1820 .................... {
1821 .................... float32 y, res, r;
1822 .................... int1 s, flag;
1823 ....................
1824 .................... s = 0;
1825 *
1826 0800: BCF 4C.0
1827 .................... flag = 0;
1828 0801: BCF 4C.1
1829 .................... y = x;
1830 0802: MOVF 3F,W
1831 0803: MOVWF 43
1832 0804: MOVF 3E,W
1833 0805: MOVWF 42
1834 0806: MOVF 3D,W
1835 0807: MOVWF 41
1836 0808: MOVF 3C,W
1837 0809: MOVWF 40
1838 ....................
1839 .................... if (x < 0)
1840 080A: MOVF 3F,W
1841 080B: MOVWF 50
1842 080C: MOVF 3E,W
1843 080D: MOVWF 4F
1844 080E: MOVF 3D,W
1845 080F: MOVWF 4E
1846 0810: MOVF 3C,W
1847 0811: MOVWF 4D
1848 0812: CLRF 54
1849 0813: CLRF 53
1850 0814: CLRF 52
1851 0815: CLRF 51
1852 0816: BCF 0A.3
1853 0817: CALL 5DE
1854 0818: BSF 0A.3
1855 0819: BTFSS 03.0
1856 081A: GOTO 01F
1857 .................... {
1858 .................... s = 1;
1859 081B: BSF 4C.0
1860 .................... y = -y;
1861 081C: MOVF 41,W
1862 081D: XORLW 80
1863 081E: MOVWF 41
1864 .................... }
1865 ....................
1866 .................... if (y > 1.0)
1867 081F: CLRF 50
1868 0820: CLRF 4F
1869 0821: CLRF 4E
1870 0822: MOVLW 7F
1871 0823: MOVWF 4D
1872 0824: MOVF 43,W
1873 0825: MOVWF 54
1874 0826: MOVF 42,W
1875 0827: MOVWF 53
1876 0828: MOVF 41,W
1877 0829: MOVWF 52
1878 082A: MOVF 40,W
1879 082B: MOVWF 51
1880 082C: BCF 0A.3
1881 082D: CALL 5DE
1882 082E: BSF 0A.3
1883 082F: BTFSS 03.0
1884 0830: GOTO 04A
1885 .................... {
1886 .................... y = 1.0/y;
1887 0831: CLRF 54
1888 0832: CLRF 53
1889 0833: CLRF 52
1890 0834: MOVLW 7F
1891 0835: MOVWF 51
1892 0836: MOVF 43,W
1893 0837: MOVWF 58
1894 0838: MOVF 42,W
1895 0839: MOVWF 57
1896 083A: MOVF 41,W
1897 083B: MOVWF 56
1898 083C: MOVF 40,W
1899 083D: MOVWF 55
1900 083E: BCF 0A.3
1901 083F: CALL 376
1902 0840: BSF 0A.3
1903 0841: MOVF 7A,W
1904 0842: MOVWF 43
1905 0843: MOVF 79,W
1906 0844: MOVWF 42
1907 0845: MOVF 78,W
1908 0846: MOVWF 41
1909 0847: MOVF 77,W
1910 0848: MOVWF 40
1911 .................... flag = 1;
1912 0849: BSF 4C.1
1913 .................... }
1914 ....................
1915 .................... res = pat[0]*y*y + pat[1];
1916 084A: MOVLW 0A
1917 084B: MOVWF 54
1918 084C: MOVLW 89
1919 084D: MOVWF 53
1920 084E: MOVLW 34
1921 084F: MOVWF 52
1922 0850: MOVLW 7C
1923 0851: MOVWF 51
1924 0852: MOVF 43,W
1925 0853: MOVWF 58
1926 0854: MOVF 42,W
1927 0855: MOVWF 57
1928 0856: MOVF 41,W
1929 0857: MOVWF 56
1930 0858: MOVF 40,W
1931 0859: MOVWF 55
1932 085A: BCF 0A.3
1933 085B: CALL 440
1934 085C: BSF 0A.3
1935 085D: MOVF 77,W
1936 085E: MOVWF 4D
1937 085F: MOVF 78,W
1938 0860: MOVWF 4E
1939 0861: MOVF 79,W
1940 0862: MOVWF 4F
1941 0863: MOVF 7A,W
1942 0864: MOVWF 50
1943 0865: MOVWF 54
1944 0866: MOVF 4F,W
1945 0867: MOVWF 53
1946 0868: MOVF 4E,W
1947 0869: MOVWF 52
1948 086A: MOVF 4D,W
1949 086B: MOVWF 51
1950 086C: MOVF 43,W
1951 086D: MOVWF 58
1952 086E: MOVF 42,W
1953 086F: MOVWF 57
1954 0870: MOVF 41,W
1955 0871: MOVWF 56
1956 0872: MOVF 40,W
1957 0873: MOVWF 55
1958 0874: BCF 0A.3
1959 0875: CALL 440
1960 0876: BSF 0A.3
1961 0877: MOVF 77,W
1962 0878: MOVWF 4D
1963 0879: MOVF 78,W
1964 087A: MOVWF 4E
1965 087B: MOVF 79,W
1966 087C: MOVWF 4F
1967 087D: MOVF 7A,W
1968 087E: MOVWF 50
1969 087F: BCF 03.1
1970 0880: MOVF 50,W
1971 0881: MOVWF 54
1972 0882: MOVF 4F,W
1973 0883: MOVWF 53
1974 0884: MOVF 4E,W
1975 0885: MOVWF 52
1976 0886: MOVF 4D,W
1977 0887: MOVWF 51
1978 0888: MOVLW 7C
1979 0889: MOVWF 58
1980 088A: MOVLW 79
1981 088B: MOVWF 57
1982 088C: MOVLW 35
1983 088D: MOVWF 56
1984 088E: MOVLW 81
1985 088F: MOVWF 55
1986 0890: BCF 0A.3
1987 0891: CALL 61D
1988 0892: BSF 0A.3
1989 0893: MOVF 7A,W
1990 0894: MOVWF 47
1991 0895: MOVF 79,W
1992 0896: MOVWF 46
1993 0897: MOVF 78,W
1994 0898: MOVWF 45
1995 0899: MOVF 77,W
1996 089A: MOVWF 44
1997 .................... res = res*y*y + pat[2];
1998 089B: MOVF 47,W
1999 089C: MOVWF 54
2000 089D: MOVF 46,W
2001 089E: MOVWF 53
2002 089F: MOVF 45,W
2003 08A0: MOVWF 52
2004 08A1: MOVF 44,W
2005 08A2: MOVWF 51
2006 08A3: MOVF 43,W
2007 08A4: MOVWF 58
2008 08A5: MOVF 42,W
2009 08A6: MOVWF 57
2010 08A7: MOVF 41,W
2011 08A8: MOVWF 56
2012 08A9: MOVF 40,W
2013 08AA: MOVWF 55
2014 08AB: BCF 0A.3
2015 08AC: CALL 440
2016 08AD: BSF 0A.3
2017 08AE: MOVF 77,W
2018 08AF: MOVWF 4D
2019 08B0: MOVF 78,W
2020 08B1: MOVWF 4E
2021 08B2: MOVF 79,W
2022 08B3: MOVWF 4F
2023 08B4: MOVF 7A,W
2024 08B5: MOVWF 50
2025 08B6: MOVWF 54
2026 08B7: MOVF 4F,W
2027 08B8: MOVWF 53
2028 08B9: MOVF 4E,W
2029 08BA: MOVWF 52
2030 08BB: MOVF 4D,W
2031 08BC: MOVWF 51
2032 08BD: MOVF 43,W
2033 08BE: MOVWF 58
2034 08BF: MOVF 42,W
2035 08C0: MOVWF 57
2036 08C1: MOVF 41,W
2037 08C2: MOVWF 56
2038 08C3: MOVF 40,W
2039 08C4: MOVWF 55
2040 08C5: BCF 0A.3
2041 08C6: CALL 440
2042 08C7: BSF 0A.3
2043 08C8: MOVF 77,W
2044 08C9: MOVWF 4D
2045 08CA: MOVF 78,W
2046 08CB: MOVWF 4E
2047 08CC: MOVF 79,W
2048 08CD: MOVWF 4F
2049 08CE: MOVF 7A,W
2050 08CF: MOVWF 50
2051 08D0: BCF 03.1
2052 08D1: MOVF 50,W
2053 08D2: MOVWF 54
2054 08D3: MOVF 4F,W
2055 08D4: MOVWF 53
2056 08D5: MOVF 4E,W
2057 08D6: MOVWF 52
2058 08D7: MOVF 4D,W
2059 08D8: MOVWF 51
2060 08D9: MOVLW 3F
2061 08DA: MOVWF 58
2062 08DB: MOVLW 02
2063 08DC: MOVWF 57
2064 08DD: MOVLW 33
2065 08DE: MOVWF 56
2066 08DF: MOVLW 83
2067 08E0: MOVWF 55
2068 08E1: BCF 0A.3
2069 08E2: CALL 61D
2070 08E3: BSF 0A.3
2071 08E4: MOVF 7A,W
2072 08E5: MOVWF 47
2073 08E6: MOVF 79,W
2074 08E7: MOVWF 46
2075 08E8: MOVF 78,W
2076 08E9: MOVWF 45
2077 08EA: MOVF 77,W
2078 08EB: MOVWF 44
2079 .................... res = res*y*y + pat[3];
2080 08EC: MOVF 47,W
2081 08ED: MOVWF 54
2082 08EE: MOVF 46,W
2083 08EF: MOVWF 53
2084 08F0: MOVF 45,W
2085 08F1: MOVWF 52
2086 08F2: MOVF 44,W
2087 08F3: MOVWF 51
2088 08F4: MOVF 43,W
2089 08F5: MOVWF 58
2090 08F6: MOVF 42,W
2091 08F7: MOVWF 57
2092 08F8: MOVF 41,W
2093 08F9: MOVWF 56
2094 08FA: MOVF 40,W
2095 08FB: MOVWF 55
2096 08FC: BCF 0A.3
2097 08FD: CALL 440
2098 08FE: BSF 0A.3
2099 08FF: MOVF 77,W
2100 0900: MOVWF 4D
2101 0901: MOVF 78,W
2102 0902: MOVWF 4E
2103 0903: MOVF 79,W
2104 0904: MOVWF 4F
2105 0905: MOVF 7A,W
2106 0906: MOVWF 50
2107 0907: MOVWF 54
2108 0908: MOVF 4F,W
2109 0909: MOVWF 53
2110 090A: MOVF 4E,W
2111 090B: MOVWF 52
2112 090C: MOVF 4D,W
2113 090D: MOVWF 51
2114 090E: MOVF 43,W
2115 090F: MOVWF 58
2116 0910: MOVF 42,W
2117 0911: MOVWF 57
2118 0912: MOVF 41,W
2119 0913: MOVWF 56
2120 0914: MOVF 40,W
2121 0915: MOVWF 55
2122 0916: BCF 0A.3
2123 0917: CALL 440
2124 0918: BSF 0A.3
2125 0919: MOVF 77,W
2126 091A: MOVWF 4D
2127 091B: MOVF 78,W
2128 091C: MOVWF 4E
2129 091D: MOVF 79,W
2130 091E: MOVWF 4F
2131 091F: MOVF 7A,W
2132 0920: MOVWF 50
2133 0921: BCF 03.1
2134 0922: MOVF 50,W
2135 0923: MOVWF 54
2136 0924: MOVF 4F,W
2137 0925: MOVWF 53
2138 0926: MOVF 4E,W
2139 0927: MOVWF 52
2140 0928: MOVF 4D,W
2141 0929: MOVWF 51
2142 092A: MOVLW 33
2143 092B: MOVWF 58
2144 092C: MOVLW 8C
2145 092D: MOVWF 57
2146 092E: MOVLW 1E
2147 092F: MOVWF 56
2148 0930: MOVLW 83
2149 0931: MOVWF 55
2150 0932: BCF 0A.3
2151 0933: CALL 61D
2152 0934: BSF 0A.3
2153 0935: MOVF 7A,W
2154 0936: MOVWF 47
2155 0937: MOVF 79,W
2156 0938: MOVWF 46
2157 0939: MOVF 78,W
2158 093A: MOVWF 45
2159 093B: MOVF 77,W
2160 093C: MOVWF 44
2161 ....................
2162 .................... r = qat[0]*y*y + qat[1];
2163 093D: CLRF 54
2164 093E: CLRF 53
2165 093F: CLRF 52
2166 0940: MOVLW 7F
2167 0941: MOVWF 51
2168 0942: MOVF 43,W
2169 0943: MOVWF 58
2170 0944: MOVF 42,W
2171 0945: MOVWF 57
2172 0946: MOVF 41,W
2173 0947: MOVWF 56
2174 0948: MOVF 40,W
2175 0949: MOVWF 55
2176 094A: BCF 0A.3
2177 094B: CALL 440
2178 094C: BSF 0A.3
2179 094D: MOVF 77,W
2180 094E: MOVWF 4D
2181 094F: MOVF 78,W
2182 0950: MOVWF 4E
2183 0951: MOVF 79,W
2184 0952: MOVWF 4F
2185 0953: MOVF 7A,W
2186 0954: MOVWF 50
2187 0955: MOVWF 54
2188 0956: MOVF 4F,W
2189 0957: MOVWF 53
2190 0958: MOVF 4E,W
2191 0959: MOVWF 52
2192 095A: MOVF 4D,W
2193 095B: MOVWF 51
2194 095C: MOVF 43,W
2195 095D: MOVWF 58
2196 095E: MOVF 42,W
2197 095F: MOVWF 57
2198 0960: MOVF 41,W
2199 0961: MOVWF 56
2200 0962: MOVF 40,W
2201 0963: MOVWF 55
2202 0964: BCF 0A.3
2203 0965: CALL 440
2204 0966: BSF 0A.3
2205 0967: MOVF 77,W
2206 0968: MOVWF 4D
2207 0969: MOVF 78,W
2208 096A: MOVWF 4E
2209 096B: MOVF 79,W
2210 096C: MOVWF 4F
2211 096D: MOVF 7A,W
2212 096E: MOVWF 50
2213 096F: BCF 03.1
2214 0970: MOVF 50,W
2215 0971: MOVWF 54
2216 0972: MOVF 4F,W
2217 0973: MOVWF 53
2218 0974: MOVF 4E,W
2219 0975: MOVWF 52
2220 0976: MOVF 4D,W
2221 0977: MOVWF 51
2222 0978: MOVLW 1B
2223 0979: MOVWF 58
2224 097A: MOVLW E4
2225 097B: MOVWF 57
2226 097C: MOVLW 35
2227 097D: MOVWF 56
2228 097E: MOVLW 82
2229 097F: MOVWF 55
2230 0980: BCF 0A.3
2231 0981: CALL 61D
2232 0982: BSF 0A.3
2233 0983: MOVF 7A,W
2234 0984: MOVWF 4B
2235 0985: MOVF 79,W
2236 0986: MOVWF 4A
2237 0987: MOVF 78,W
2238 0988: MOVWF 49
2239 0989: MOVF 77,W
2240 098A: MOVWF 48
2241 .................... r = r*y*y + qat[2];
2242 098B: MOVF 4B,W
2243 098C: MOVWF 54
2244 098D: MOVF 4A,W
2245 098E: MOVWF 53
2246 098F: MOVF 49,W
2247 0990: MOVWF 52
2248 0991: MOVF 48,W
2249 0992: MOVWF 51
2250 0993: MOVF 43,W
2251 0994: MOVWF 58
2252 0995: MOVF 42,W
2253 0996: MOVWF 57
2254 0997: MOVF 41,W
2255 0998: MOVWF 56
2256 0999: MOVF 40,W
2257 099A: MOVWF 55
2258 099B: BCF 0A.3
2259 099C: CALL 440
2260 099D: BSF 0A.3
2261 099E: MOVF 77,W
2262 099F: MOVWF 4D
2263 09A0: MOVF 78,W
2264 09A1: MOVWF 4E
2265 09A2: MOVF 79,W
2266 09A3: MOVWF 4F
2267 09A4: MOVF 7A,W
2268 09A5: MOVWF 50
2269 09A6: MOVWF 54
2270 09A7: MOVF 4F,W
2271 09A8: MOVWF 53
2272 09A9: MOVF 4E,W
2273 09AA: MOVWF 52
2274 09AB: MOVF 4D,W
2275 09AC: MOVWF 51
2276 09AD: MOVF 43,W
2277 09AE: MOVWF 58
2278 09AF: MOVF 42,W
2279 09B0: MOVWF 57
2280 09B1: MOVF 41,W
2281 09B2: MOVWF 56
2282 09B3: MOVF 40,W
2283 09B4: MOVWF 55
2284 09B5: BCF 0A.3
2285 09B6: CALL 440
2286 09B7: BSF 0A.3
2287 09B8: MOVF 77,W
2288 09B9: MOVWF 4D
2289 09BA: MOVF 78,W
2290 09BB: MOVWF 4E
2291 09BC: MOVF 79,W
2292 09BD: MOVWF 4F
2293 09BE: MOVF 7A,W
2294 09BF: MOVWF 50
2295 09C0: BCF 03.1
2296 09C1: MOVF 50,W
2297 09C2: MOVWF 54
2298 09C3: MOVF 4F,W
2299 09C4: MOVWF 53
2300 09C5: MOVF 4E,W
2301 09C6: MOVWF 52
2302 09C7: MOVF 4D,W
2303 09C8: MOVWF 51
2304 09C9: MOVLW A4
2305 09CA: MOVWF 58
2306 09CB: MOVLW DB
2307 09CC: MOVWF 57
2308 09CD: MOVLW 67
2309 09CE: MOVWF 56
2310 09CF: MOVLW 83
2311 09D0: MOVWF 55
2312 09D1: BCF 0A.3
2313 09D2: CALL 61D
2314 09D3: BSF 0A.3
2315 09D4: MOVF 7A,W
2316 09D5: MOVWF 4B
2317 09D6: MOVF 79,W
2318 09D7: MOVWF 4A
2319 09D8: MOVF 78,W
2320 09D9: MOVWF 49
2321 09DA: MOVF 77,W
2322 09DB: MOVWF 48
2323 .................... r = r*y*y + qat[3];
2324 09DC: MOVF 4B,W
2325 09DD: MOVWF 54
2326 09DE: MOVF 4A,W
2327 09DF: MOVWF 53
2328 09E0: MOVF 49,W
2329 09E1: MOVWF 52
2330 09E2: MOVF 48,W
2331 09E3: MOVWF 51
2332 09E4: MOVF 43,W
2333 09E5: MOVWF 58
2334 09E6: MOVF 42,W
2335 09E7: MOVWF 57
2336 09E8: MOVF 41,W
2337 09E9: MOVWF 56
2338 09EA: MOVF 40,W
2339 09EB: MOVWF 55
2340 09EC: BCF 0A.3
2341 09ED: CALL 440
2342 09EE: BSF 0A.3
2343 09EF: MOVF 77,W
2344 09F0: MOVWF 4D
2345 09F1: MOVF 78,W
2346 09F2: MOVWF 4E
2347 09F3: MOVF 79,W
2348 09F4: MOVWF 4F
2349 09F5: MOVF 7A,W
2350 09F6: MOVWF 50
2351 09F7: MOVWF 54
2352 09F8: MOVF 4F,W
2353 09F9: MOVWF 53
2354 09FA: MOVF 4E,W
2355 09FB: MOVWF 52
2356 09FC: MOVF 4D,W
2357 09FD: MOVWF 51
2358 09FE: MOVF 43,W
2359 09FF: MOVWF 58
2360 0A00: MOVF 42,W
2361 0A01: MOVWF 57
2362 0A02: MOVF 41,W
2363 0A03: MOVWF 56
2364 0A04: MOVF 40,W
2365 0A05: MOVWF 55
2366 0A06: BCF 0A.3
2367 0A07: CALL 440
2368 0A08: BSF 0A.3
2369 0A09: MOVF 77,W
2370 0A0A: MOVWF 4D
2371 0A0B: MOVF 78,W
2372 0A0C: MOVWF 4E
2373 0A0D: MOVF 79,W
2374 0A0E: MOVWF 4F
2375 0A0F: MOVF 7A,W
2376 0A10: MOVWF 50
2377 0A11: BCF 03.1
2378 0A12: MOVF 50,W
2379 0A13: MOVWF 54
2380 0A14: MOVF 4F,W
2381 0A15: MOVWF 53
2382 0A16: MOVF 4E,W
2383 0A17: MOVWF 52
2384 0A18: MOVF 4D,W
2385 0A19: MOVWF 51
2386 0A1A: MOVLW 33
2387 0A1B: MOVWF 58
2388 0A1C: MOVLW 8C
2389 0A1D: MOVWF 57
2390 0A1E: MOVLW 1E
2391 0A1F: MOVWF 56
2392 0A20: MOVLW 83
2393 0A21: MOVWF 55
2394 0A22: BCF 0A.3
2395 0A23: CALL 61D
2396 0A24: BSF 0A.3
2397 0A25: MOVF 7A,W
2398 0A26: MOVWF 4B
2399 0A27: MOVF 79,W
2400 0A28: MOVWF 4A
2401 0A29: MOVF 78,W
2402 0A2A: MOVWF 49
2403 0A2B: MOVF 77,W
2404 0A2C: MOVWF 48
2405 ....................
2406 .................... res = y*res/r;
2407 0A2D: MOVF 43,W
2408 0A2E: MOVWF 54
2409 0A2F: MOVF 42,W
2410 0A30: MOVWF 53
2411 0A31: MOVF 41,W
2412 0A32: MOVWF 52
2413 0A33: MOVF 40,W
2414 0A34: MOVWF 51
2415 0A35: MOVF 47,W
2416 0A36: MOVWF 58
2417 0A37: MOVF 46,W
2418 0A38: MOVWF 57
2419 0A39: MOVF 45,W
2420 0A3A: MOVWF 56
2421 0A3B: MOVF 44,W
2422 0A3C: MOVWF 55
2423 0A3D: BCF 0A.3
2424 0A3E: CALL 440
2425 0A3F: BSF 0A.3
2426 0A40: MOVF 77,W
2427 0A41: MOVWF 4D
2428 0A42: MOVF 78,W
2429 0A43: MOVWF 4E
2430 0A44: MOVF 79,W
2431 0A45: MOVWF 4F
2432 0A46: MOVF 7A,W
2433 0A47: MOVWF 50
2434 0A48: MOVWF 54
2435 0A49: MOVF 4F,W
2436 0A4A: MOVWF 53
2437 0A4B: MOVF 4E,W
2438 0A4C: MOVWF 52
2439 0A4D: MOVF 4D,W
2440 0A4E: MOVWF 51
2441 0A4F: MOVF 4B,W
2442 0A50: MOVWF 58
2443 0A51: MOVF 4A,W
2444 0A52: MOVWF 57
2445 0A53: MOVF 49,W
2446 0A54: MOVWF 56
2447 0A55: MOVF 48,W
2448 0A56: MOVWF 55
2449 0A57: BCF 0A.3
2450 0A58: CALL 376
2451 0A59: BSF 0A.3
2452 0A5A: MOVF 7A,W
2453 0A5B: MOVWF 47
2454 0A5C: MOVF 79,W
2455 0A5D: MOVWF 46
2456 0A5E: MOVF 78,W
2457 0A5F: MOVWF 45
2458 0A60: MOVF 77,W
2459 0A61: MOVWF 44
2460 ....................
2461 ....................
2462 .................... if (flag) // for |x| > 1
2463 0A62: BTFSS 4C.1
2464 0A63: GOTO 280
2465 .................... res = PI_DIV_BY_TWO - res;
2466 0A64: BSF 03.1
2467 0A65: MOVLW DB
2468 0A66: MOVWF 54
2469 0A67: MOVLW 0F
2470 0A68: MOVWF 53
2471 0A69: MOVLW 49
2472 0A6A: MOVWF 52
2473 0A6B: MOVLW 7F
2474 0A6C: MOVWF 51
2475 0A6D: MOVF 47,W
2476 0A6E: MOVWF 58
2477 0A6F: MOVF 46,W
2478 0A70: MOVWF 57
2479 0A71: MOVF 45,W
2480 0A72: MOVWF 56
2481 0A73: MOVF 44,W
2482 0A74: MOVWF 55
2483 0A75: BCF 0A.3
2484 0A76: CALL 61D
2485 0A77: BSF 0A.3
2486 0A78: MOVF 7A,W
2487 0A79: MOVWF 47
2488 0A7A: MOVF 79,W
2489 0A7B: MOVWF 46
2490 0A7C: MOVF 78,W
2491 0A7D: MOVWF 45
2492 0A7E: MOVF 77,W
2493 0A7F: MOVWF 44
2494 .................... if (s)
2495 0A80: BTFSS 4C.0
2496 0A81: GOTO 285
2497 .................... res = -res;
2498 0A82: MOVF 45,W
2499 0A83: XORLW 80
2500 0A84: MOVWF 45
2501 ....................
2502 .................... return(res);
2503 0A85: MOVF 44,W
2504 0A86: MOVWF 77
2505 0A87: MOVF 45,W
2506 0A88: MOVWF 78
2507 0A89: MOVF 46,W
2508 0A8A: MOVWF 79
2509 0A8B: MOVF 47,W
2510 0A8C: MOVWF 7A
2511 .................... }
2512 0A8D: BCF 0A.3
2513 0A8E: BSF 0A.4
2514 0A8F: GOTO 58C (RETURN)
2515 .................... //Overloaded functions for atan() for PCD
2516 .................... // Overloaded function atan() for data type - Float48
2517 .................... #if defined(__PCD__)
2518 .................... float48 atan(float48 x)
2519 .................... {
2520 .................... float48 y, res, r;
2521 .................... int1 s, flag;
2522 ....................
2523 .................... s = 0;
2524 .................... flag = 0;
2525 .................... y = x;
2526 ....................
2527 .................... if (x < 0)
2528 .................... {
2529 .................... s = 1;
2530 .................... y = -y;
2531 .................... }
2532 ....................
2533 .................... if (y > 1.0)
2534 .................... {
2535 .................... y = 1.0/y;
2536 .................... flag = 1;
2537 .................... }
2538 ....................
2539 .................... res = pat[0]*y*y + pat[1];
2540 .................... res = res*y*y + pat[2];
2541 .................... res = res*y*y + pat[3];
2542 ....................
2543 .................... r = qat[0]*y*y + qat[1];
2544 .................... r = r*y*y + qat[2];
2545 .................... r = r*y*y + qat[3];
2546 ....................
2547 .................... res = y*res/r;
2548 ....................
2549 ....................
2550 .................... if (flag) // for |x| > 1
2551 .................... res = PI_DIV_BY_TWO - res;
2552 .................... if (s)
2553 .................... res = -res;
2554 ....................
2555 .................... return(res);
2556 .................... }
2557 ....................
2558 .................... // Overloaded function atan() for data type - Float64
2559 .................... float64 atan(float64 x)
2560 .................... {
2561 .................... float64 y, res, r;
2562 .................... int1 s, flag;
2563 ....................
2564 .................... s = 0;
2565 .................... flag = 0;
2566 .................... y = x;
2567 ....................
2568 .................... if (x < 0)
2569 .................... {
2570 .................... s = 1;
2571 .................... y = -y;
2572 .................... }
2573 ....................
2574 .................... if (y > 1.0)
2575 .................... {
2576 .................... y = 1.0/y;
2577 .................... flag = 1;
2578 .................... }
2579 ....................
2580 .................... res = pat[0]*y*y + pat[1];
2581 .................... res = res*y*y + pat[2];
2582 .................... res = res*y*y + pat[3];
2583 ....................
2584 .................... r = qat[0]*y*y + qat[1];
2585 .................... r = r*y*y + qat[2];
2586 .................... r = r*y*y + qat[3];
2587 ....................
2588 .................... res = y*res/r;
2589 ....................
2590 ....................
2591 .................... if (flag) // for |x| > 1
2592 .................... res = PI_DIV_BY_TWO - res;
2593 .................... if (s)
2594 .................... res = -res;
2595 ....................
2596 .................... return(res);
2597 .................... }
2598 .................... #endif
2599 ....................
2600 .................... /////////////////////////////////////////////////////////////////////////////
2601 .................... // float atan2(float y, float x)
2602 .................... /////////////////////////////////////////////////////////////////////////////
2603 .................... // Description :computes the principal value of arc tangent of y/x, using the
2604 .................... // signs of both the arguments to determine the quadrant of the return value
2605 .................... // Returns : returns the arc tangent of y/x.
2606 .................... // Date : N/A
2607 .................... //
2608 ....................
2609 .................... float32 atan2(float32 y,float32 x)
2610 .................... {
2611 .................... float32 z;
2612 .................... int1 sign;
2613 .................... unsigned int8 quad;
2614 .................... sign=0;
2615 .................... quad=0; //quadrant
2616 .................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
2617 .................... if(y<0.0)
2618 .................... {
2619 .................... sign=1;
2620 .................... y=-y;
2621 .................... }
2622 .................... if(x<0.0)
2623 .................... {
2624 .................... x=-x;
2625 .................... }
2626 .................... if (x==0.0)
2627 .................... {
2628 .................... if(y==0.0)
2629 .................... {
2630 .................... #ifdef _ERRNO
2631 .................... {
2632 .................... errno=EDOM;
2633 .................... }
2634 .................... #endif
2635 .................... }
2636 .................... else
2637 .................... {
2638 .................... if(sign)
2639 .................... {
2640 .................... return (-(PI_DIV_BY_TWO));
2641 .................... }
2642 .................... else
2643 .................... {
2644 .................... return (PI_DIV_BY_TWO);
2645 .................... }
2646 .................... }
2647 .................... }
2648 .................... else
2649 .................... {
2650 .................... z=y/x;
2651 .................... switch(quad)
2652 .................... {
2653 .................... case 1:
2654 .................... {
2655 .................... return atan(z);
2656 .................... break;
2657 .................... }
2658 .................... case 2:
2659 .................... {
2660 .................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
2661 .................... return (PI-atan(z));
2662 .................... break;
2663 .................... }
2664 .................... case 3:
2665 .................... {
2666 .................... return (atan(z)-PI);
2667 .................... break;
2668 .................... }
2669 .................... case 4:
2670 .................... {
2671 .................... return (-atan(z));
2672 .................... break;
2673 .................... }
2674 .................... }
2675 .................... }
2676 .................... }
2677 ....................
2678 .................... //Overloaded functions for atan2() for PCD
2679 .................... // Overloaded function atan2() for data type - Float48
2680 .................... #if defined(__PCD__)
2681 .................... float48 atan2(float48 y,float48 x)
2682 .................... {
2683 .................... float48 z;
2684 .................... int1 sign;
2685 .................... unsigned int8 quad;
2686 .................... sign=0;
2687 .................... quad=0; //quadrant
2688 .................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
2689 .................... if(y<0.0)
2690 .................... {
2691 .................... sign=1;
2692 .................... y=-y;
2693 .................... }
2694 .................... if(x<0.0)
2695 .................... {
2696 .................... x=-x;
2697 .................... }
2698 .................... if (x==0.0)
2699 .................... {
2700 .................... if(y==0.0)
2701 .................... {
2702 .................... #ifdef _ERRNO
2703 .................... {
2704 .................... errno=EDOM;
2705 .................... }
2706 .................... #endif
2707 .................... }
2708 .................... else
2709 .................... {
2710 .................... if(sign)
2711 .................... {
2712 .................... return (-(PI_DIV_BY_TWO));
2713 .................... }
2714 .................... else
2715 .................... {
2716 .................... return (PI_DIV_BY_TWO);
2717 .................... }
2718 .................... }
2719 .................... }
2720 .................... else
2721 .................... {
2722 .................... z=y/x;
2723 .................... switch(quad)
2724 .................... {
2725 .................... case 1:
2726 .................... {
2727 .................... return atan(z);
2728 .................... break;
2729 .................... }
2730 .................... case 2:
2731 .................... {
2732 .................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
2733 .................... return (PI-atan(z));
2734 .................... break;
2735 .................... }
2736 .................... case 3:
2737 .................... {
2738 .................... return (atan(z)-PI);
2739 .................... break;
2740 .................... }
2741 .................... case 4:
2742 .................... {
2743 .................... return (-atan(z));
2744 .................... break;
2745 .................... }
2746 .................... }
2747 .................... }
2748 .................... }
2749 ....................
2750 .................... // Overloaded function atan2() for data type - Float64
2751 .................... float64 atan2(float64 y,float64 x)
2752 .................... {
2753 .................... float64 z;
2754 .................... int1 sign;
2755 .................... unsigned int8 quad;
2756 .................... sign=0;
2757 .................... quad=0; //quadrant
2758 .................... quad=((y<=0.0)?((x<=0.0)?3:4):((x<0.0)?2:1));
2759 .................... if(y<0.0)
2760 .................... {
2761 .................... sign=1;
2762 .................... y=-y;
2763 .................... }
2764 .................... if(x<0.0)
2765 .................... {
2766 .................... x=-x;
2767 .................... }
2768 .................... if (x==0.0)
2769 .................... {
2770 .................... if(y==0.0)
2771 .................... {
2772 .................... #ifdef _ERRNO
2773 .................... {
2774 .................... errno=EDOM;
2775 .................... }
2776 .................... #endif
2777 .................... }
2778 .................... else
2779 .................... {
2780 .................... if(sign)
2781 .................... {
2782 .................... return (-(PI_DIV_BY_TWO));
2783 .................... }
2784 .................... else
2785 .................... {
2786 .................... return (PI_DIV_BY_TWO);
2787 .................... }
2788 .................... }
2789 .................... }
2790 .................... else
2791 .................... {
2792 .................... z=y/x;
2793 .................... switch(quad)
2794 .................... {
2795 .................... case 1:
2796 .................... {
2797 .................... return atan(z);
2798 .................... break;
2799 .................... }
2800 .................... case 2:
2801 .................... {
2802 .................... // return (atan(z)+PI_DIV_BY_TWO); //2L3122
2803 .................... return (PI-atan(z));
2804 .................... break;
2805 .................... }
2806 .................... case 3:
2807 .................... {
2808 .................... return (atan(z)-PI);
2809 .................... break;
2810 .................... }
2811 .................... case 4:
2812 .................... {
2813 .................... return (-atan(z));
2814 .................... break;
2815 .................... }
2816 .................... }
2817 .................... }
2818 .................... }
2819 .................... #endif
2820 ....................
2821 .................... //////////////////// Hyperbolic functions ////////////////////
2822 ....................
2823 .................... ////////////////////////////////////////////////////////////////////////////
2824 .................... // float cosh(float x)
2825 .................... ////////////////////////////////////////////////////////////////////////////
2826 .................... // Description : Computes the hyperbolic cosine value of x
2827 .................... // Returns : returns the hyperbolic cosine value of x
2828 .................... // Date : N/A
2829 .................... //
2830 ....................
2831 .................... float32 cosh(float32 x)
2832 .................... {
2833 .................... return ((exp(x)+exp(-x))/2);
2834 .................... }
2835 .................... //Overloaded functions for cosh() for PCD
2836 .................... // Overloaded function cosh() for data type - Float48
2837 .................... #if defined(__PCD__)
2838 .................... float48 cosh(float48 x)
2839 .................... {
2840 .................... return ((exp(x)+exp(-x))/2);
2841 .................... }
2842 ....................
2843 .................... // Overloaded function cosh() for data type - Float64
2844 .................... float64 cosh(float64 x)
2845 .................... {
2846 .................... return ((exp(x)+exp(-x))/2);
2847 .................... }
2848 .................... #endif
2849 ....................
2850 .................... ////////////////////////////////////////////////////////////////////////////
2851 .................... // float sinh(float x)
2852 .................... ////////////////////////////////////////////////////////////////////////////
2853 .................... // Description : Computes the hyperbolic sine value of x
2854 .................... // Returns : returns the hyperbolic sine value of x
2855 .................... // Date : N/A
2856 .................... //
2857 ....................
2858 .................... float32 sinh(float32 x)
2859 .................... {
2860 ....................
2861 .................... return ((exp(x) - exp(-x))/2);
2862 .................... }
2863 .................... //Overloaded functions for sinh() for PCD
2864 .................... // Overloaded function sinh() for data type - Float48
2865 .................... #if defined(__PCD__)
2866 .................... float48 sinh(float48 x)
2867 .................... {
2868 ....................
2869 .................... return ((exp(x) - exp(-x))/2);
2870 .................... }
2871 ....................
2872 .................... // Overloaded function sinh() for data type - Float48
2873 .................... float64 sinh(float64 x)
2874 .................... {
2875 ....................
2876 .................... return ((exp(x) - exp(-x))/2);
2877 .................... }
2878 .................... #endif
2879 ....................
2880 .................... ////////////////////////////////////////////////////////////////////////////
2881 .................... // float tanh(float x)
2882 .................... ////////////////////////////////////////////////////////////////////////////
2883 .................... // Description : Computes the hyperbolic tangent value of x
2884 .................... // Returns : returns the hyperbolic tangent value of x
2885 .................... // Date : N/A
2886 .................... //
2887 ....................
2888 .................... float32 tanh(float32 x)
2889 .................... {
2890 .................... return(sinh(x)/cosh(x));
2891 .................... }
2892 .................... //Overloaded functions for tanh() for PCD
2893 .................... // Overloaded function tanh() for data type - Float48
2894 .................... #if defined(__PCD__)
2895 .................... float48 tanh(float48 x)
2896 .................... {
2897 .................... return(sinh(x)/cosh(x));
2898 .................... }
2899 ....................
2900 .................... // Overloaded function tanh() for data type - Float64
2901 .................... float64 tanh(float64 x)
2902 .................... {
2903 .................... return(sinh(x)/cosh(x));
2904 .................... }
2905 .................... #endif
2906 ....................
2907 .................... ////////////////////////////////////////////////////////////////////////////
2908 .................... // float frexp(float x, signed int *exp)
2909 .................... ////////////////////////////////////////////////////////////////////////////
2910 .................... // Description : breaks a floating point number into a normalized fraction and an integral
2911 .................... // power of 2. It stores the integer in the signed int object pointed to by exp.
2912 .................... // Returns : returns the value x, such that x is a double with magnitude in the interval
2913 .................... // [1/2,1) or zero, and value equals x times 2 raised to the power *exp.If value is zero,
2914 .................... // both parts of the result are zero.
2915 .................... // Date : N/A
2916 .................... //
2917 ....................
2918 .................... #define LOG2 .30102999566398119521
2919 .................... float32 frexp(float32 x, signed int8 *exp)
2920 .................... {
2921 .................... float32 res;
2922 .................... int1 sign = 0;
2923 .................... if(x == 0.0)
2924 .................... {
2925 .................... *exp=0;
2926 .................... return (0.0);
2927 .................... }
2928 .................... if(x < 0.0)
2929 .................... {
2930 .................... x=-x;
2931 .................... sign=1;
2932 .................... }
2933 .................... if (x > 1.0)
2934 .................... {
2935 .................... *exp=(ceil(log10(x)/LOG2));
2936 .................... res=x/(pow(2, *exp));
2937 .................... if (res == 1)
2938 .................... {
2939 .................... *exp=*exp+1;
2940 .................... res=.5;
2941 .................... }
2942 .................... }
2943 .................... else
2944 .................... {
2945 .................... if(x < 0.5)
2946 .................... {
2947 .................... *exp=-1;
2948 .................... res=x*2;
2949 .................... }
2950 .................... else
2951 .................... {
2952 .................... *exp=0;
2953 .................... res=x;
2954 .................... }
2955 .................... }
2956 .................... if(sign)
2957 .................... {
2958 .................... res=-res;
2959 .................... }
2960 .................... return res;
2961 .................... }
2962 ....................
2963 .................... //Overloaded functions for frexp() for PCD
2964 .................... // Overloaded function frexp() for data type - Float48
2965 .................... #if defined(__PCD__)
2966 .................... float48 frexp(float48 x, signed int8 *exp)
2967 .................... {
2968 .................... float48 res;
2969 .................... int1 sign = 0;
2970 .................... if(x == 0.0)
2971 .................... {
2972 .................... *exp=0;
2973 .................... return (0.0);
2974 .................... }
2975 .................... if(x < 0.0)
2976 .................... {
2977 .................... x=-x;
2978 .................... sign=1;
2979 .................... }
2980 .................... if (x > 1.0)
2981 .................... {
2982 .................... *exp=(ceil(log10(x)/LOG2));
2983 .................... res=x/(pow(2, *exp));
2984 .................... if (res == 1)
2985 .................... {
2986 .................... *exp=*exp+1;
2987 .................... res=.5;
2988 .................... }
2989 .................... }
2990 .................... else
2991 .................... {
2992 .................... if(x < 0.5)
2993 .................... {
2994 .................... *exp=-1;
2995 .................... res=x*2;
2996 .................... }
2997 .................... else
2998 .................... {
2999 .................... *exp=0;
3000 .................... res=x;
3001 .................... }
3002 .................... }
3003 .................... if(sign)
3004 .................... {
3005 .................... res=-res;
3006 .................... }
3007 .................... return res;
3008 .................... }
3009 ....................
3010 .................... // Overloaded function frexp() for data type - Float64
3011 .................... float64 frexp(float64 x, signed int8 *exp)
3012 .................... {
3013 .................... float64 res;
3014 .................... int1 sign = 0;
3015 .................... if(x == 0.0)
3016 .................... {
3017 .................... *exp=0;
3018 .................... return (0.0);
3019 .................... }
3020 .................... if(x < 0.0)
3021 .................... {
3022 .................... x=-x;
3023 .................... sign=1;
3024 .................... }
3025 .................... if (x > 1.0)
3026 .................... {
3027 .................... *exp=(ceil(log10(x)/LOG2));
3028 .................... res=x/(pow(2, *exp));
3029 .................... if (res == 1)
3030 .................... {
3031 .................... *exp=*exp+1;
3032 .................... res=.5;
3033 .................... }
3034 .................... }
3035 .................... else
3036 .................... {
3037 .................... if(x < 0.5)
3038 .................... {
3039 .................... *exp=-1;
3040 .................... res=x*2;
3041 .................... }
3042 .................... else
3043 .................... {
3044 .................... *exp=0;
3045 .................... res=x;
3046 .................... }
3047 .................... }
3048 .................... if(sign)
3049 .................... {
3050 .................... res=-res;
3051 .................... }
3052 .................... return res;
3053 .................... }
3054 .................... #endif
3055 ....................
3056 .................... //////////////////////////////////////////////////////////////////////////////
3057 .................... // float ldexp(float x, signed int *exp)
3058 .................... //////////////////////////////////////////////////////////////////////////////
3059 .................... // Description : multiplies a floating point number by an integral power of 2.
3060 .................... // Returns : returns the value of x times 2 raised to the power exp.
3061 .................... // Date : N/A
3062 .................... //
3063 ....................
3064 .................... float32 ldexp(float32 value, signed int8 exp)
3065 .................... {
3066 .................... return (value * pow(2,exp));
3067 .................... }
3068 .................... //Overloaded functions for ldexp() for PCD
3069 .................... // Overloaded function ldexp() for data type - Float48
3070 ....................
3071 .................... #if defined(__PCD__)
3072 .................... float48 ldexp(float48 value, signed int8 exp)
3073 .................... {
3074 .................... return (value * pow(2,exp));
3075 .................... }
3076 .................... // Overloaded function ldexp() for data type - Float64
3077 .................... float64 ldexp(float64 value, signed int8 exp)
3078 .................... {
3079 .................... return (value * pow(2,exp));
3080 .................... }
3081 .................... #endif
3082 ....................
3083 .................... #endif
3084 ....................
3085 ....................
3086 .................... void main()
3087 .................... {
3088 *
3089 0097: DATA 00,00
3090 *
3091 1000: CLRF 04
3092 1001: BCF 03.7
3093 1002: MOVLW 1F
3094 1003: ANDWF 03,F
3095 1004: MOVLW 71
3096 1005: BSF 03.5
3097 1006: MOVWF 0F
3098 1007: MOVF 0F,W
3099 1008: BCF 03.5
3100 1009: BCF 20.7
3101 100A: MOVF 20,W
3102 100B: BSF 03.5
3103 100C: MOVWF 07
3104 100D: BCF 03.5
3105 100E: BSF 07.7
3106 100F: BSF 03.5
3107 1010: BSF 03.6
3108 1011: MOVF 09,W
3109 1012: ANDLW C0
3110 1013: MOVWF 09
3111 1014: BCF 03.6
3112 1015: BCF 1F.4
3113 1016: BCF 1F.5
3114 1017: MOVLW 00
3115 1018: BSF 03.6
3116 1019: MOVWF 08
3117 101A: BCF 03.5
3118 101B: CLRF 07
3119 101C: CLRF 08
3120 101D: CLRF 09
3121 ....................
3122 .................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
3123 *
3124 1021: BSF 03.5
3125 1022: BSF 03.6
3126 1023: MOVF 09,W
3127 1024: ANDLW C0
3128 1025: MOVWF 09
3129 1026: BCF 03.6
3130 1027: BCF 1F.4
3131 1028: BCF 1F.5
3132 1029: MOVLW 00
3133 102A: BSF 03.6
3134 102B: MOVWF 08
3135 .................... setup_adc(ADC_CLOCK_DIV_2);
3136 102C: BCF 03.5
3137 102D: BCF 03.6
3138 102E: BCF 1F.6
3139 102F: BCF 1F.7
3140 1030: BSF 03.5
3141 1031: BCF 1F.7
3142 1032: BCF 03.5
3143 1033: BSF 1F.0
3144 .................... setup_spi(SPI_SS_DISABLED);
3145 1034: BCF 14.5
3146 1035: BCF 20.5
3147 1036: MOVF 20,W
3148 1037: BSF 03.5
3149 1038: MOVWF 07
3150 1039: BCF 03.5
3151 103A: BSF 20.4
3152 103B: MOVF 20,W
3153 103C: BSF 03.5
3154 103D: MOVWF 07
3155 103E: BCF 03.5
3156 103F: BCF 20.3
3157 1040: MOVF 20,W
3158 1041: BSF 03.5
3159 1042: MOVWF 07
3160 1043: MOVLW 01
3161 1044: BCF 03.5
3162 1045: MOVWF 14
3163 1046: MOVLW 00
3164 1047: BSF 03.5
3165 1048: MOVWF 14
3166 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
3167 1049: MOVF 01,W
3168 104A: ANDLW C7
3169 104B: IORLW 08
3170 104C: MOVWF 01
3171 .................... setup_timer_1(T1_DISABLED);
3172 104D: BCF 03.5
3173 104E: CLRF 10
3174 .................... setup_timer_2(T2_DISABLED,0,1);
3175 104F: MOVLW 00
3176 1050: MOVWF 78
3177 1051: MOVWF 12
3178 1052: MOVLW 00
3179 1053: BSF 03.5
3180 1054: MOVWF 12
3181 .................... setup_ccp1(CCP_OFF);
3182 1055: BCF 03.5
3183 1056: BSF 20.2
3184 1057: MOVF 20,W
3185 1058: BSF 03.5
3186 1059: MOVWF 07
3187 105A: BCF 03.5
3188 105B: CLRF 17
3189 105C: BSF 03.5
3190 105D: CLRF 1B
3191 105E: CLRF 1C
3192 105F: MOVLW 01
3193 1060: MOVWF 1D
3194 .................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
3195 1061: BCF 03.5
3196 1062: BSF 03.6
3197 1063: CLRF 07
3198 1064: CLRF 08
3199 1065: CLRF 09
3200 ....................
3201 .................... printf("Simple Thermomether \r\n",);
3202 1066: MOVLW 04
3203 1067: MOVWF 0D
3204 1068: MOVLW 00
3205 1069: MOVWF 0F
3206 106A: BCF 0A.4
3207 106B: BCF 03.6
3208 106C: GOTO 0BC
3209 106D: BSF 0A.4
3210 ....................
3211 .................... int16 data1, data2, data3;
3212 .................... signed int16 X, Y, Z;
3213 .................... float a, b;
3214 ....................
3215 .................... unsigned int8 XL,XH,YL,YH,ZL,ZH;
3216 ....................
3217 ....................
3218 .................... i2c_start();
3219 106E: BSF 20.4
3220 106F: MOVF 20,W
3221 1070: BSF 03.5
3222 1071: MOVWF 07
3223 1072: NOP
3224 1073: BCF 03.5
3225 1074: BSF 20.3
3226 1075: MOVF 20,W
3227 1076: BSF 03.5
3228 1077: MOVWF 07
3229 1078: NOP
3230 1079: BCF 03.5
3231 107A: BCF 07.4
3232 107B: BCF 20.4
3233 107C: MOVF 20,W
3234 107D: BSF 03.5
3235 107E: MOVWF 07
3236 107F: NOP
3237 1080: BCF 03.5
3238 1081: BCF 07.3
3239 1082: BCF 20.3
3240 1083: MOVF 20,W
3241 1084: BSF 03.5
3242 1085: MOVWF 07
3243 .................... I2C_Write(0x38);
3244 1086: MOVLW 38
3245 1087: BCF 03.5
3246 1088: MOVWF 3C
3247 1089: BCF 0A.4
3248 108A: CALL 104
3249 108B: BSF 0A.4
3250 .................... I2C_write(0x2A);
3251 108C: MOVLW 2A
3252 108D: MOVWF 3C
3253 108E: BCF 0A.4
3254 108F: CALL 104
3255 1090: BSF 0A.4
3256 ....................
3257 .................... I2C_write(0x01);
3258 1091: MOVLW 01
3259 1092: MOVWF 3C
3260 1093: BCF 0A.4
3261 1094: CALL 104
3262 1095: BSF 0A.4
3263 ....................
3264 .................... i2c_stop();
3265 1096: BCF 20.4
3266 1097: MOVF 20,W
3267 1098: BSF 03.5
3268 1099: MOVWF 07
3269 109A: NOP
3270 109B: BCF 03.5
3271 109C: BSF 20.3
3272 109D: MOVF 20,W
3273 109E: BSF 03.5
3274 109F: MOVWF 07
3275 10A0: BCF 03.5
3276 10A1: BTFSS 07.3
3277 10A2: GOTO 0A1
3278 10A3: NOP
3279 10A4: GOTO 0A5
3280 10A5: NOP
3281 10A6: BSF 20.4
3282 10A7: MOVF 20,W
3283 10A8: BSF 03.5
3284 10A9: MOVWF 07
3285 10AA: NOP
3286 ....................
3287 ....................
3288 ....................
3289 .................... while(TRUE)
3290 .................... {
3291 ....................
3292 .................... data1=0;
3293 10AB: BCF 03.5
3294 10AC: CLRF 22
3295 10AD: CLRF 21
3296 .................... data2=0 ;
3297 10AE: CLRF 24
3298 10AF: CLRF 23
3299 ....................
3300 ....................
3301 .................... //akcelerometr
3302 .................... int1 ack;
3303 .................... i2c_start(); // If the write command is acknowledged,
3304 10B0: BSF 20.4
3305 10B1: MOVF 20,W
3306 10B2: BSF 03.5
3307 10B3: MOVWF 07
3308 10B4: NOP
3309 10B5: BCF 03.5
3310 10B6: BSF 20.3
3311 10B7: MOVF 20,W
3312 10B8: BSF 03.5
3313 10B9: MOVWF 07
3314 10BA: NOP
3315 10BB: BCF 03.5
3316 10BC: BCF 07.4
3317 10BD: BCF 20.4
3318 10BE: MOVF 20,W
3319 10BF: BSF 03.5
3320 10C0: MOVWF 07
3321 10C1: NOP
3322 10C2: BCF 03.5
3323 10C3: BCF 07.3
3324 10C4: BCF 20.3
3325 10C5: MOVF 20,W
3326 10C6: BSF 03.5
3327 10C7: MOVWF 07
3328 .................... ack = i2c_write(0x39);//hen the device is ready.
3329 10C8: MOVLW 39
3330 10C9: BCF 03.5
3331 10CA: MOVWF 3C
3332 10CB: BCF 0A.4
3333 10CC: CALL 104
3334 10CD: BSF 0A.4
3335 10CE: MOVF 78,W
3336 10CF: BCF 3B.0
3337 10D0: BTFSC 78.0
3338 10D1: BSF 3B.0
3339 .................... i2c_stop();
3340 10D2: BCF 20.4
3341 10D3: MOVF 20,W
3342 10D4: BSF 03.5
3343 10D5: MOVWF 07
3344 10D6: NOP
3345 10D7: BCF 03.5
3346 10D8: BSF 20.3
3347 10D9: MOVF 20,W
3348 10DA: BSF 03.5
3349 10DB: MOVWF 07
3350 10DC: BCF 03.5
3351 10DD: BTFSS 07.3
3352 10DE: GOTO 0DD
3353 10DF: NOP
3354 10E0: GOTO 0E1
3355 10E1: NOP
3356 10E2: BSF 20.4
3357 10E3: MOVF 20,W
3358 10E4: BSF 03.5
3359 10E5: MOVWF 07
3360 10E6: NOP
3361 .................... ack=!ack;
3362 10E7: MOVLW 01
3363 10E8: BCF 03.5
3364 10E9: XORWF 3B,F
3365 ....................
3366 ....................
3367 ....................
3368 .................... i2c_stop();
3369 10EA: BCF 20.4
3370 10EB: MOVF 20,W
3371 10EC: BSF 03.5
3372 10ED: MOVWF 07
3373 10EE: NOP
3374 10EF: BCF 03.5
3375 10F0: BSF 20.3
3376 10F1: MOVF 20,W
3377 10F2: BSF 03.5
3378 10F3: MOVWF 07
3379 10F4: BCF 03.5
3380 10F5: BTFSS 07.3
3381 10F6: GOTO 0F5
3382 10F7: NOP
3383 10F8: GOTO 0F9
3384 10F9: NOP
3385 10FA: BSF 20.4
3386 10FB: MOVF 20,W
3387 10FC: BSF 03.5
3388 10FD: MOVWF 07
3389 10FE: NOP
3390 ....................
3391 .................... i2c_start();
3392 10FF: BCF 03.5
3393 1100: BSF 20.4
3394 1101: MOVF 20,W
3395 1102: BSF 03.5
3396 1103: MOVWF 07
3397 1104: NOP
3398 1105: BCF 03.5
3399 1106: BSF 20.3
3400 1107: MOVF 20,W
3401 1108: BSF 03.5
3402 1109: MOVWF 07
3403 110A: NOP
3404 110B: BCF 03.5
3405 110C: BCF 07.4
3406 110D: BCF 20.4
3407 110E: MOVF 20,W
3408 110F: BSF 03.5
3409 1110: MOVWF 07
3410 1111: NOP
3411 1112: BCF 03.5
3412 1113: BCF 07.3
3413 1114: BCF 20.3
3414 1115: MOVF 20,W
3415 1116: BSF 03.5
3416 1117: MOVWF 07
3417 .................... I2C_Write(0x38);
3418 1118: MOVLW 38
3419 1119: BCF 03.5
3420 111A: MOVWF 3C
3421 111B: BCF 0A.4
3422 111C: CALL 104
3423 111D: BSF 0A.4
3424 .................... I2C_write(0x01);
3425 111E: MOVLW 01
3426 111F: MOVWF 3C
3427 1120: BCF 0A.4
3428 1121: CALL 104
3429 1122: BSF 0A.4
3430 .................... // i2c_stop();
3431 .................... i2c_start();
3432 1123: BSF 20.4
3433 1124: MOVF 20,W
3434 1125: BSF 03.5
3435 1126: MOVWF 07
3436 1127: NOP
3437 1128: BCF 03.5
3438 1129: BSF 20.3
3439 112A: MOVF 20,W
3440 112B: BSF 03.5
3441 112C: MOVWF 07
3442 112D: NOP
3443 112E: BCF 03.5
3444 112F: BTFSS 07.3
3445 1130: GOTO 12F
3446 1131: BCF 07.4
3447 1132: BCF 20.4
3448 1133: MOVF 20,W
3449 1134: BSF 03.5
3450 1135: MOVWF 07
3451 1136: NOP
3452 1137: BCF 03.5
3453 1138: BCF 07.3
3454 1139: BCF 20.3
3455 113A: MOVF 20,W
3456 113B: BSF 03.5
3457 113C: MOVWF 07
3458 .................... I2C_Write(0x39);
3459 113D: MOVLW 39
3460 113E: BCF 03.5
3461 113F: MOVWF 3C
3462 1140: BCF 0A.4
3463 1141: CALL 104
3464 1142: BSF 0A.4
3465 .................... XH=i2c_read(0);
3466 1143: CLRF 77
3467 1144: BCF 0A.4
3468 1145: CALL 14E
3469 1146: BSF 0A.4
3470 1147: MOVF 78,W
3471 1148: MOVWF 36
3472 .................... i2c_stop();
3473 1149: BCF 20.4
3474 114A: MOVF 20,W
3475 114B: BSF 03.5
3476 114C: MOVWF 07
3477 114D: NOP
3478 114E: BCF 03.5
3479 114F: BSF 20.3
3480 1150: MOVF 20,W
3481 1151: BSF 03.5
3482 1152: MOVWF 07
3483 1153: BCF 03.5
3484 1154: BTFSS 07.3
3485 1155: GOTO 154
3486 1156: NOP
3487 1157: GOTO 158
3488 1158: NOP
3489 1159: BSF 20.4
3490 115A: MOVF 20,W
3491 115B: BSF 03.5
3492 115C: MOVWF 07
3493 115D: NOP
3494 ....................
3495 .................... i2c_start();
3496 115E: BCF 03.5
3497 115F: BSF 20.4
3498 1160: MOVF 20,W
3499 1161: BSF 03.5
3500 1162: MOVWF 07
3501 1163: NOP
3502 1164: BCF 03.5
3503 1165: BSF 20.3
3504 1166: MOVF 20,W
3505 1167: BSF 03.5
3506 1168: MOVWF 07
3507 1169: NOP
3508 116A: BCF 03.5
3509 116B: BCF 07.4
3510 116C: BCF 20.4
3511 116D: MOVF 20,W
3512 116E: BSF 03.5
3513 116F: MOVWF 07
3514 1170: NOP
3515 1171: BCF 03.5
3516 1172: BCF 07.3
3517 1173: BCF 20.3
3518 1174: MOVF 20,W
3519 1175: BSF 03.5
3520 1176: MOVWF 07
3521 .................... I2C_Write(0x38);
3522 1177: MOVLW 38
3523 1178: BCF 03.5
3524 1179: MOVWF 3C
3525 117A: BCF 0A.4
3526 117B: CALL 104
3527 117C: BSF 0A.4
3528 .................... I2C_write(0x02);
3529 117D: MOVLW 02
3530 117E: MOVWF 3C
3531 117F: BCF 0A.4
3532 1180: CALL 104
3533 1181: BSF 0A.4
3534 .................... // i2c_stop();
3535 .................... i2c_start();
3536 1182: BSF 20.4
3537 1183: MOVF 20,W
3538 1184: BSF 03.5
3539 1185: MOVWF 07
3540 1186: NOP
3541 1187: BCF 03.5
3542 1188: BSF 20.3
3543 1189: MOVF 20,W
3544 118A: BSF 03.5
3545 118B: MOVWF 07
3546 118C: NOP
3547 118D: BCF 03.5
3548 118E: BTFSS 07.3
3549 118F: GOTO 18E
3550 1190: BCF 07.4
3551 1191: BCF 20.4
3552 1192: MOVF 20,W
3553 1193: BSF 03.5
3554 1194: MOVWF 07
3555 1195: NOP
3556 1196: BCF 03.5
3557 1197: BCF 07.3
3558 1198: BCF 20.3
3559 1199: MOVF 20,W
3560 119A: BSF 03.5
3561 119B: MOVWF 07
3562 .................... I2C_Write(0x39);
3563 119C: MOVLW 39
3564 119D: BCF 03.5
3565 119E: MOVWF 3C
3566 119F: BCF 0A.4
3567 11A0: CALL 104
3568 11A1: BSF 0A.4
3569 .................... XL=i2c_read(0);
3570 11A2: CLRF 77
3571 11A3: BCF 0A.4
3572 11A4: CALL 14E
3573 11A5: BSF 0A.4
3574 11A6: MOVF 78,W
3575 11A7: MOVWF 35
3576 .................... i2c_stop();
3577 11A8: BCF 20.4
3578 11A9: MOVF 20,W
3579 11AA: BSF 03.5
3580 11AB: MOVWF 07
3581 11AC: NOP
3582 11AD: BCF 03.5
3583 11AE: BSF 20.3
3584 11AF: MOVF 20,W
3585 11B0: BSF 03.5
3586 11B1: MOVWF 07
3587 11B2: BCF 03.5
3588 11B3: BTFSS 07.3
3589 11B4: GOTO 1B3
3590 11B5: NOP
3591 11B6: GOTO 1B7
3592 11B7: NOP
3593 11B8: BSF 20.4
3594 11B9: MOVF 20,W
3595 11BA: BSF 03.5
3596 11BB: MOVWF 07
3597 11BC: NOP
3598 ....................
3599 .................... i2c_start();
3600 11BD: BCF 03.5
3601 11BE: BSF 20.4
3602 11BF: MOVF 20,W
3603 11C0: BSF 03.5
3604 11C1: MOVWF 07
3605 11C2: NOP
3606 11C3: BCF 03.5
3607 11C4: BSF 20.3
3608 11C5: MOVF 20,W
3609 11C6: BSF 03.5
3610 11C7: MOVWF 07
3611 11C8: NOP
3612 11C9: BCF 03.5
3613 11CA: BCF 07.4
3614 11CB: BCF 20.4
3615 11CC: MOVF 20,W
3616 11CD: BSF 03.5
3617 11CE: MOVWF 07
3618 11CF: NOP
3619 11D0: BCF 03.5
3620 11D1: BCF 07.3
3621 11D2: BCF 20.3
3622 11D3: MOVF 20,W
3623 11D4: BSF 03.5
3624 11D5: MOVWF 07
3625 .................... I2C_Write(0x38);
3626 11D6: MOVLW 38
3627 11D7: BCF 03.5
3628 11D8: MOVWF 3C
3629 11D9: BCF 0A.4
3630 11DA: CALL 104
3631 11DB: BSF 0A.4
3632 .................... I2C_write(0x03);
3633 11DC: MOVLW 03
3634 11DD: MOVWF 3C
3635 11DE: BCF 0A.4
3636 11DF: CALL 104
3637 11E0: BSF 0A.4
3638 .................... // i2c_stop();
3639 .................... i2c_start();
3640 11E1: BSF 20.4
3641 11E2: MOVF 20,W
3642 11E3: BSF 03.5
3643 11E4: MOVWF 07
3644 11E5: NOP
3645 11E6: BCF 03.5
3646 11E7: BSF 20.3
3647 11E8: MOVF 20,W
3648 11E9: BSF 03.5
3649 11EA: MOVWF 07
3650 11EB: NOP
3651 11EC: BCF 03.5
3652 11ED: BTFSS 07.3
3653 11EE: GOTO 1ED
3654 11EF: BCF 07.4
3655 11F0: BCF 20.4
3656 11F1: MOVF 20,W
3657 11F2: BSF 03.5
3658 11F3: MOVWF 07
3659 11F4: NOP
3660 11F5: BCF 03.5
3661 11F6: BCF 07.3
3662 11F7: BCF 20.3
3663 11F8: MOVF 20,W
3664 11F9: BSF 03.5
3665 11FA: MOVWF 07
3666 .................... I2C_Write(0x39);
3667 11FB: MOVLW 39
3668 11FC: BCF 03.5
3669 11FD: MOVWF 3C
3670 11FE: BCF 0A.4
3671 11FF: CALL 104
3672 1200: BSF 0A.4
3673 .................... YH=i2c_read(0);
3674 1201: CLRF 77
3675 1202: BCF 0A.4
3676 1203: CALL 14E
3677 1204: BSF 0A.4
3678 1205: MOVF 78,W
3679 1206: MOVWF 38
3680 .................... i2c_stop();
3681 1207: BCF 20.4
3682 1208: MOVF 20,W
3683 1209: BSF 03.5
3684 120A: MOVWF 07
3685 120B: NOP
3686 120C: BCF 03.5
3687 120D: BSF 20.3
3688 120E: MOVF 20,W
3689 120F: BSF 03.5
3690 1210: MOVWF 07
3691 1211: BCF 03.5
3692 1212: BTFSS 07.3
3693 1213: GOTO 212
3694 1214: NOP
3695 1215: GOTO 216
3696 1216: NOP
3697 1217: BSF 20.4
3698 1218: MOVF 20,W
3699 1219: BSF 03.5
3700 121A: MOVWF 07
3701 121B: NOP
3702 ....................
3703 .................... i2c_start();
3704 121C: BCF 03.5
3705 121D: BSF 20.4
3706 121E: MOVF 20,W
3707 121F: BSF 03.5
3708 1220: MOVWF 07
3709 1221: NOP
3710 1222: BCF 03.5
3711 1223: BSF 20.3
3712 1224: MOVF 20,W
3713 1225: BSF 03.5
3714 1226: MOVWF 07
3715 1227: NOP
3716 1228: BCF 03.5
3717 1229: BCF 07.4
3718 122A: BCF 20.4
3719 122B: MOVF 20,W
3720 122C: BSF 03.5
3721 122D: MOVWF 07
3722 122E: NOP
3723 122F: BCF 03.5
3724 1230: BCF 07.3
3725 1231: BCF 20.3
3726 1232: MOVF 20,W
3727 1233: BSF 03.5
3728 1234: MOVWF 07
3729 .................... I2C_Write(0x38);
3730 1235: MOVLW 38
3731 1236: BCF 03.5
3732 1237: MOVWF 3C
3733 1238: BCF 0A.4
3734 1239: CALL 104
3735 123A: BSF 0A.4
3736 .................... I2C_write(0x04);
3737 123B: MOVLW 04
3738 123C: MOVWF 3C
3739 123D: BCF 0A.4
3740 123E: CALL 104
3741 123F: BSF 0A.4
3742 .................... // i2c_stop();
3743 .................... i2c_start();
3744 1240: BSF 20.4
3745 1241: MOVF 20,W
3746 1242: BSF 03.5
3747 1243: MOVWF 07
3748 1244: NOP
3749 1245: BCF 03.5
3750 1246: BSF 20.3
3751 1247: MOVF 20,W
3752 1248: BSF 03.5
3753 1249: MOVWF 07
3754 124A: NOP
3755 124B: BCF 03.5
3756 124C: BTFSS 07.3
3757 124D: GOTO 24C
3758 124E: BCF 07.4
3759 124F: BCF 20.4
3760 1250: MOVF 20,W
3761 1251: BSF 03.5
3762 1252: MOVWF 07
3763 1253: NOP
3764 1254: BCF 03.5
3765 1255: BCF 07.3
3766 1256: BCF 20.3
3767 1257: MOVF 20,W
3768 1258: BSF 03.5
3769 1259: MOVWF 07
3770 .................... I2C_Write(0x39);
3771 125A: MOVLW 39
3772 125B: BCF 03.5
3773 125C: MOVWF 3C
3774 125D: BCF 0A.4
3775 125E: CALL 104
3776 125F: BSF 0A.4
3777 .................... YL=i2c_read(0);
3778 1260: CLRF 77
3779 1261: BCF 0A.4
3780 1262: CALL 14E
3781 1263: BSF 0A.4
3782 1264: MOVF 78,W
3783 1265: MOVWF 37
3784 .................... i2c_stop();
3785 1266: BCF 20.4
3786 1267: MOVF 20,W
3787 1268: BSF 03.5
3788 1269: MOVWF 07
3789 126A: NOP
3790 126B: BCF 03.5
3791 126C: BSF 20.3
3792 126D: MOVF 20,W
3793 126E: BSF 03.5
3794 126F: MOVWF 07
3795 1270: BCF 03.5
3796 1271: BTFSS 07.3
3797 1272: GOTO 271
3798 1273: NOP
3799 1274: GOTO 275
3800 1275: NOP
3801 1276: BSF 20.4
3802 1277: MOVF 20,W
3803 1278: BSF 03.5
3804 1279: MOVWF 07
3805 127A: NOP
3806 ....................
3807 .................... i2c_start();
3808 127B: BCF 03.5
3809 127C: BSF 20.4
3810 127D: MOVF 20,W
3811 127E: BSF 03.5
3812 127F: MOVWF 07
3813 1280: NOP
3814 1281: BCF 03.5
3815 1282: BSF 20.3
3816 1283: MOVF 20,W
3817 1284: BSF 03.5
3818 1285: MOVWF 07
3819 1286: NOP
3820 1287: BCF 03.5
3821 1288: BCF 07.4
3822 1289: BCF 20.4
3823 128A: MOVF 20,W
3824 128B: BSF 03.5
3825 128C: MOVWF 07
3826 128D: NOP
3827 128E: BCF 03.5
3828 128F: BCF 07.3
3829 1290: BCF 20.3
3830 1291: MOVF 20,W
3831 1292: BSF 03.5
3832 1293: MOVWF 07
3833 .................... I2C_Write(0x38);
3834 1294: MOVLW 38
3835 1295: BCF 03.5
3836 1296: MOVWF 3C
3837 1297: BCF 0A.4
3838 1298: CALL 104
3839 1299: BSF 0A.4
3840 .................... I2C_write(0x05);
3841 129A: MOVLW 05
3842 129B: MOVWF 3C
3843 129C: BCF 0A.4
3844 129D: CALL 104
3845 129E: BSF 0A.4
3846 .................... // i2c_stop();
3847 .................... i2c_start();
3848 129F: BSF 20.4
3849 12A0: MOVF 20,W
3850 12A1: BSF 03.5
3851 12A2: MOVWF 07
3852 12A3: NOP
3853 12A4: BCF 03.5
3854 12A5: BSF 20.3
3855 12A6: MOVF 20,W
3856 12A7: BSF 03.5
3857 12A8: MOVWF 07
3858 12A9: NOP
3859 12AA: BCF 03.5
3860 12AB: BTFSS 07.3
3861 12AC: GOTO 2AB
3862 12AD: BCF 07.4
3863 12AE: BCF 20.4
3864 12AF: MOVF 20,W
3865 12B0: BSF 03.5
3866 12B1: MOVWF 07
3867 12B2: NOP
3868 12B3: BCF 03.5
3869 12B4: BCF 07.3
3870 12B5: BCF 20.3
3871 12B6: MOVF 20,W
3872 12B7: BSF 03.5
3873 12B8: MOVWF 07
3874 .................... I2C_Write(0x39);
3875 12B9: MOVLW 39
3876 12BA: BCF 03.5
3877 12BB: MOVWF 3C
3878 12BC: BCF 0A.4
3879 12BD: CALL 104
3880 12BE: BSF 0A.4
3881 .................... ZH=i2c_read(0);
3882 12BF: CLRF 77
3883 12C0: BCF 0A.4
3884 12C1: CALL 14E
3885 12C2: BSF 0A.4
3886 12C3: MOVF 78,W
3887 12C4: MOVWF 3A
3888 .................... i2c_stop();
3889 12C5: BCF 20.4
3890 12C6: MOVF 20,W
3891 12C7: BSF 03.5
3892 12C8: MOVWF 07
3893 12C9: NOP
3894 12CA: BCF 03.5
3895 12CB: BSF 20.3
3896 12CC: MOVF 20,W
3897 12CD: BSF 03.5
3898 12CE: MOVWF 07
3899 12CF: BCF 03.5
3900 12D0: BTFSS 07.3
3901 12D1: GOTO 2D0
3902 12D2: NOP
3903 12D3: GOTO 2D4
3904 12D4: NOP
3905 12D5: BSF 20.4
3906 12D6: MOVF 20,W
3907 12D7: BSF 03.5
3908 12D8: MOVWF 07
3909 12D9: NOP
3910 ....................
3911 .................... i2c_start();
3912 12DA: BCF 03.5
3913 12DB: BSF 20.4
3914 12DC: MOVF 20,W
3915 12DD: BSF 03.5
3916 12DE: MOVWF 07
3917 12DF: NOP
3918 12E0: BCF 03.5
3919 12E1: BSF 20.3
3920 12E2: MOVF 20,W
3921 12E3: BSF 03.5
3922 12E4: MOVWF 07
3923 12E5: NOP
3924 12E6: BCF 03.5
3925 12E7: BCF 07.4
3926 12E8: BCF 20.4
3927 12E9: MOVF 20,W
3928 12EA: BSF 03.5
3929 12EB: MOVWF 07
3930 12EC: NOP
3931 12ED: BCF 03.5
3932 12EE: BCF 07.3
3933 12EF: BCF 20.3
3934 12F0: MOVF 20,W
3935 12F1: BSF 03.5
3936 12F2: MOVWF 07
3937 .................... I2C_Write(0x38);
3938 12F3: MOVLW 38
3939 12F4: BCF 03.5
3940 12F5: MOVWF 3C
3941 12F6: BCF 0A.4
3942 12F7: CALL 104
3943 12F8: BSF 0A.4
3944 .................... I2C_write(0x06);
3945 12F9: MOVLW 06
3946 12FA: MOVWF 3C
3947 12FB: BCF 0A.4
3948 12FC: CALL 104
3949 12FD: BSF 0A.4
3950 .................... // i2c_stop();
3951 .................... i2c_start();
3952 12FE: BSF 20.4
3953 12FF: MOVF 20,W
3954 1300: BSF 03.5
3955 1301: MOVWF 07
3956 1302: NOP
3957 1303: BCF 03.5
3958 1304: BSF 20.3
3959 1305: MOVF 20,W
3960 1306: BSF 03.5
3961 1307: MOVWF 07
3962 1308: NOP
3963 1309: BCF 03.5
3964 130A: BTFSS 07.3
3965 130B: GOTO 30A
3966 130C: BCF 07.4
3967 130D: BCF 20.4
3968 130E: MOVF 20,W
3969 130F: BSF 03.5
3970 1310: MOVWF 07
3971 1311: NOP
3972 1312: BCF 03.5
3973 1313: BCF 07.3
3974 1314: BCF 20.3
3975 1315: MOVF 20,W
3976 1316: BSF 03.5
3977 1317: MOVWF 07
3978 .................... I2C_Write(0x39);
3979 1318: MOVLW 39
3980 1319: BCF 03.5
3981 131A: MOVWF 3C
3982 131B: BCF 0A.4
3983 131C: CALL 104
3984 131D: BSF 0A.4
3985 .................... ZL=i2c_read(0);
3986 131E: CLRF 77
3987 131F: BCF 0A.4
3988 1320: CALL 14E
3989 1321: BSF 0A.4
3990 1322: MOVF 78,W
3991 1323: MOVWF 39
3992 .................... i2c_stop();
3993 1324: BCF 20.4
3994 1325: MOVF 20,W
3995 1326: BSF 03.5
3996 1327: MOVWF 07
3997 1328: NOP
3998 1329: BCF 03.5
3999 132A: BSF 20.3
4000 132B: MOVF 20,W
4001 132C: BSF 03.5
4002 132D: MOVWF 07
4003 132E: BCF 03.5
4004 132F: BTFSS 07.3
4005 1330: GOTO 32F
4006 1331: NOP
4007 1332: GOTO 333
4008 1333: NOP
4009 1334: BSF 20.4
4010 1335: MOVF 20,W
4011 1336: BSF 03.5
4012 1337: MOVWF 07
4013 1338: NOP
4014 ....................
4015 .................... i2c_start();
4016 1339: BCF 03.5
4017 133A: BSF 20.4
4018 133B: MOVF 20,W
4019 133C: BSF 03.5
4020 133D: MOVWF 07
4021 133E: NOP
4022 133F: BCF 03.5
4023 1340: BSF 20.3
4024 1341: MOVF 20,W
4025 1342: BSF 03.5
4026 1343: MOVWF 07
4027 1344: NOP
4028 1345: BCF 03.5
4029 1346: BCF 07.4
4030 1347: BCF 20.4
4031 1348: MOVF 20,W
4032 1349: BSF 03.5
4033 134A: MOVWF 07
4034 134B: NOP
4035 134C: BCF 03.5
4036 134D: BCF 07.3
4037 134E: BCF 20.3
4038 134F: MOVF 20,W
4039 1350: BSF 03.5
4040 1351: MOVWF 07
4041 .................... I2C_Write(0x38);
4042 1352: MOVLW 38
4043 1353: BCF 03.5
4044 1354: MOVWF 3C
4045 1355: BCF 0A.4
4046 1356: CALL 104
4047 1357: BSF 0A.4
4048 .................... I2C_write(0x00);
4049 1358: CLRF 3C
4050 1359: BCF 0A.4
4051 135A: CALL 104
4052 135B: BSF 0A.4
4053 .................... // i2c_stop();
4054 .................... i2c_start();
4055 135C: BSF 20.4
4056 135D: MOVF 20,W
4057 135E: BSF 03.5
4058 135F: MOVWF 07
4059 1360: NOP
4060 1361: BCF 03.5
4061 1362: BSF 20.3
4062 1363: MOVF 20,W
4063 1364: BSF 03.5
4064 1365: MOVWF 07
4065 1366: NOP
4066 1367: BCF 03.5
4067 1368: BTFSS 07.3
4068 1369: GOTO 368
4069 136A: BCF 07.4
4070 136B: BCF 20.4
4071 136C: MOVF 20,W
4072 136D: BSF 03.5
4073 136E: MOVWF 07
4074 136F: NOP
4075 1370: BCF 03.5
4076 1371: BCF 07.3
4077 1372: BCF 20.3
4078 1373: MOVF 20,W
4079 1374: BSF 03.5
4080 1375: MOVWF 07
4081 .................... I2C_Write(0x39);
4082 1376: MOVLW 39
4083 1377: BCF 03.5
4084 1378: MOVWF 3C
4085 1379: BCF 0A.4
4086 137A: CALL 104
4087 137B: BSF 0A.4
4088 .................... ZL=i2c_read(0);
4089 137C: CLRF 77
4090 137D: BCF 0A.4
4091 137E: CALL 14E
4092 137F: BSF 0A.4
4093 1380: MOVF 78,W
4094 1381: MOVWF 39
4095 .................... i2c_stop();
4096 1382: BCF 20.4
4097 1383: MOVF 20,W
4098 1384: BSF 03.5
4099 1385: MOVWF 07
4100 1386: NOP
4101 1387: BCF 03.5
4102 1388: BSF 20.3
4103 1389: MOVF 20,W
4104 138A: BSF 03.5
4105 138B: MOVWF 07
4106 138C: BCF 03.5
4107 138D: BTFSS 07.3
4108 138E: GOTO 38D
4109 138F: NOP
4110 1390: GOTO 391
4111 1391: NOP
4112 1392: BSF 20.4
4113 1393: MOVF 20,W
4114 1394: BSF 03.5
4115 1395: MOVWF 07
4116 1396: NOP
4117 ....................
4118 .................... printf("Stav: %ud(procenta)\r\n", XL);
4119 1397: MOVLW 10
4120 1398: BCF 03.5
4121 1399: BSF 03.6
4122 139A: MOVWF 0D
4123 139B: MOVLW 00
4124 139C: MOVWF 0F
4125 139D: BCF 03.0
4126 139E: MOVLW 06
4127 139F: BCF 03.6
4128 13A0: MOVWF 3D
4129 13A1: BCF 0A.4
4130 13A2: CALL 193
4131 13A3: BSF 0A.4
4132 13A4: MOVF 35,W
4133 13A5: MOVWF 3C
4134 13A6: MOVLW 1B
4135 13A7: MOVWF 3D
4136 13A8: BCF 0A.4
4137 13A9: CALL 1F7
4138 13AA: BSF 0A.4
4139 13AB: MOVLW 14
4140 13AC: BSF 03.6
4141 13AD: MOVWF 0D
4142 13AE: MOVLW 00
4143 13AF: MOVWF 0F
4144 13B0: BCF 03.0
4145 13B1: MOVLW 0D
4146 13B2: BCF 03.6
4147 13B3: MOVWF 3D
4148 13B4: BCF 0A.4
4149 13B5: CALL 193
4150 13B6: BSF 0A.4
4151 .................... printf("Stav: %ud(procenta)\r\n", XH);
4152 13B7: MOVLW 1B
4153 13B8: BSF 03.6
4154 13B9: MOVWF 0D
4155 13BA: MOVLW 00
4156 13BB: MOVWF 0F
4157 13BC: BCF 03.0
4158 13BD: MOVLW 06
4159 13BE: BCF 03.6
4160 13BF: MOVWF 3D
4161 13C0: BCF 0A.4
4162 13C1: CALL 193
4163 13C2: BSF 0A.4
4164 13C3: MOVF 36,W
4165 13C4: MOVWF 3C
4166 13C5: MOVLW 1B
4167 13C6: MOVWF 3D
4168 13C7: BCF 0A.4
4169 13C8: CALL 1F7
4170 13C9: BSF 0A.4
4171 13CA: MOVLW 1F
4172 13CB: BSF 03.6
4173 13CC: MOVWF 0D
4174 13CD: MOVLW 00
4175 13CE: MOVWF 0F
4176 13CF: BCF 03.0
4177 13D0: MOVLW 0D
4178 13D1: BCF 03.6
4179 13D2: MOVWF 3D
4180 13D3: BCF 0A.4
4181 13D4: CALL 193
4182 13D5: BSF 0A.4
4183 .................... printf("Stav: %ud(procenta)\r\n", YL);
4184 13D6: MOVLW 26
4185 13D7: BSF 03.6
4186 13D8: MOVWF 0D
4187 13D9: MOVLW 00
4188 13DA: MOVWF 0F
4189 13DB: BCF 03.0
4190 13DC: MOVLW 06
4191 13DD: BCF 03.6
4192 13DE: MOVWF 3D
4193 13DF: BCF 0A.4
4194 13E0: CALL 193
4195 13E1: BSF 0A.4
4196 13E2: MOVF 37,W
4197 13E3: MOVWF 3C
4198 13E4: MOVLW 1B
4199 13E5: MOVWF 3D
4200 13E6: BCF 0A.4
4201 13E7: CALL 1F7
4202 13E8: BSF 0A.4
4203 13E9: MOVLW 2A
4204 13EA: BSF 03.6
4205 13EB: MOVWF 0D
4206 13EC: MOVLW 00
4207 13ED: MOVWF 0F
4208 13EE: BCF 03.0
4209 13EF: MOVLW 0D
4210 13F0: BCF 03.6
4211 13F1: MOVWF 3D
4212 13F2: BCF 0A.4
4213 13F3: CALL 193
4214 13F4: BSF 0A.4
4215 .................... printf("Stav: %ud(procenta)\r\n", YH);
4216 13F5: MOVLW 31
4217 13F6: BSF 03.6
4218 13F7: MOVWF 0D
4219 13F8: MOVLW 00
4220 13F9: MOVWF 0F
4221 13FA: BCF 03.0
4222 13FB: MOVLW 06
4223 13FC: BCF 03.6
4224 13FD: MOVWF 3D
4225 13FE: BCF 0A.4
4226 13FF: CALL 193
4227 1400: BSF 0A.4
4228 1401: MOVF 38,W
4229 1402: MOVWF 3C
4230 1403: MOVLW 1B
4231 1404: MOVWF 3D
4232 1405: BCF 0A.4
4233 1406: CALL 1F7
4234 1407: BSF 0A.4
4235 1408: MOVLW 35
4236 1409: BSF 03.6
4237 140A: MOVWF 0D
4238 140B: MOVLW 00
4239 140C: MOVWF 0F
4240 140D: BCF 03.0
4241 140E: MOVLW 0D
4242 140F: BCF 03.6
4243 1410: MOVWF 3D
4244 1411: BCF 0A.4
4245 1412: CALL 193
4246 1413: BSF 0A.4
4247 .................... printf("Stav: %ud(procenta)\r\n", ZL);
4248 1414: MOVLW 3C
4249 1415: BSF 03.6
4250 1416: MOVWF 0D
4251 1417: MOVLW 00
4252 1418: MOVWF 0F
4253 1419: BCF 03.0
4254 141A: MOVLW 06
4255 141B: BCF 03.6
4256 141C: MOVWF 3D
4257 141D: BCF 0A.4
4258 141E: CALL 193
4259 141F: BSF 0A.4
4260 1420: MOVF 39,W
4261 1421: MOVWF 3C
4262 1422: MOVLW 1B
4263 1423: MOVWF 3D
4264 1424: BCF 0A.4
4265 1425: CALL 1F7
4266 1426: BSF 0A.4
4267 1427: MOVLW 40
4268 1428: BSF 03.6
4269 1429: MOVWF 0D
4270 142A: MOVLW 00
4271 142B: MOVWF 0F
4272 142C: BCF 03.0
4273 142D: MOVLW 0D
4274 142E: BCF 03.6
4275 142F: MOVWF 3D
4276 1430: BCF 0A.4
4277 1431: CALL 193
4278 1432: BSF 0A.4
4279 .................... printf("Stav: %ud(procenta)\r\n", ZH);
4280 1433: MOVLW 47
4281 1434: BSF 03.6
4282 1435: MOVWF 0D
4283 1436: MOVLW 00
4284 1437: MOVWF 0F
4285 1438: BCF 03.0
4286 1439: MOVLW 06
4287 143A: BCF 03.6
4288 143B: MOVWF 3D
4289 143C: BCF 0A.4
4290 143D: CALL 193
4291 143E: BSF 0A.4
4292 143F: MOVF 3A,W
4293 1440: MOVWF 3C
4294 1441: MOVLW 1B
4295 1442: MOVWF 3D
4296 1443: BCF 0A.4
4297 1444: CALL 1F7
4298 1445: BSF 0A.4
4299 1446: MOVLW 4B
4300 1447: BSF 03.6
4301 1448: MOVWF 0D
4302 1449: MOVLW 00
4303 144A: MOVWF 0F
4304 144B: BCF 03.0
4305 144C: MOVLW 0D
4306 144D: BCF 03.6
4307 144E: MOVWF 3D
4308 144F: BCF 0A.4
4309 1450: CALL 193
4310 1451: BSF 0A.4
4311 ....................
4312 ....................
4313 .................... X = (((unsigned int16) XH << 8) + XL );
4314 1452: CLRF 3D
4315 1453: MOVF 36,W
4316 1454: MOVWF 3C
4317 1455: MOVWF 3D
4318 1456: CLRF 3C
4319 1457: MOVF 35,W
4320 1458: ADDWF 3C,W
4321 1459: MOVWF 27
4322 145A: MOVF 3D,W
4323 145B: MOVWF 28
4324 145C: BTFSC 03.0
4325 145D: INCF 28,F
4326 .................... Y = (((unsigned int16) YH << 8) + YL);
4327 145E: CLRF 3D
4328 145F: MOVF 38,W
4329 1460: MOVWF 3C
4330 1461: MOVWF 3D
4331 1462: CLRF 3C
4332 1463: MOVF 37,W
4333 1464: ADDWF 3C,W
4334 1465: MOVWF 29
4335 1466: MOVF 3D,W
4336 1467: MOVWF 2A
4337 1468: BTFSC 03.0
4338 1469: INCF 2A,F
4339 .................... Z = (((unsigned int16) ZH << 8) + ZL);
4340 146A: CLRF 3D
4341 146B: MOVF 3A,W
4342 146C: MOVWF 3C
4343 146D: MOVWF 3D
4344 146E: CLRF 3C
4345 146F: MOVF 39,W
4346 1470: ADDWF 3C,W
4347 1471: MOVWF 2B
4348 1472: MOVF 3D,W
4349 1473: MOVWF 2C
4350 1474: BTFSC 03.0
4351 1475: INCF 2C,F
4352 ....................
4353 .................... X=X/4;
4354 1476: MOVF 28,W
4355 1477: MOVWF 3D
4356 1478: MOVF 27,W
4357 1479: MOVWF 3C
4358 147A: CLRF 3F
4359 147B: MOVLW 04
4360 147C: MOVWF 3E
4361 147D: BCF 0A.4
4362 147E: CALL 22C
4363 147F: BSF 0A.4
4364 1480: MOVF 79,W
4365 1481: MOVWF 28
4366 1482: MOVF 78,W
4367 1483: MOVWF 27
4368 .................... Y=Y/4;
4369 1484: MOVF 2A,W
4370 1485: MOVWF 3D
4371 1486: MOVF 29,W
4372 1487: MOVWF 3C
4373 1488: CLRF 3F
4374 1489: MOVLW 04
4375 148A: MOVWF 3E
4376 148B: BCF 0A.4
4377 148C: CALL 22C
4378 148D: BSF 0A.4
4379 148E: MOVF 79,W
4380 148F: MOVWF 2A
4381 1490: MOVF 78,W
4382 1491: MOVWF 29
4383 .................... Z=Z/4;
4384 1492: MOVF 2C,W
4385 1493: MOVWF 3D
4386 1494: MOVF 2B,W
4387 1495: MOVWF 3C
4388 1496: CLRF 3F
4389 1497: MOVLW 04
4390 1498: MOVWF 3E
4391 1499: BCF 0A.4
4392 149A: CALL 22C
4393 149B: BSF 0A.4
4394 149C: MOVF 79,W
4395 149D: MOVWF 2C
4396 149E: MOVF 78,W
4397 149F: MOVWF 2B
4398 .................... //X = X>>2;
4399 .................... //Y = Y>>2;
4400 .................... //Z = Z>>2;
4401 ....................
4402 ....................
4403 ....................
4404 .................... printf("Stav: %d (procenta)\r\n", ack);
4405 14A0: MOVLW 00
4406 14A1: BTFSC 3B.0
4407 14A2: MOVLW 01
4408 14A3: MOVWF 3C
4409 14A4: MOVLW 52
4410 14A5: BSF 03.6
4411 14A6: MOVWF 0D
4412 14A7: MOVLW 00
4413 14A8: MOVWF 0F
4414 14A9: BCF 03.0
4415 14AA: MOVLW 06
4416 14AB: BCF 03.6
4417 14AC: MOVWF 3D
4418 14AD: BCF 0A.4
4419 14AE: CALL 193
4420 14AF: BSF 0A.4
4421 14B0: MOVF 3C,W
4422 14B1: MOVWF 3D
4423 14B2: MOVLW 1F
4424 14B3: MOVWF 3E
4425 14B4: BCF 0A.4
4426 14B5: GOTO 26A
4427 14B6: BSF 0A.4
4428 14B7: MOVLW 56
4429 14B8: BSF 03.6
4430 14B9: MOVWF 0D
4431 14BA: MOVLW 00
4432 14BB: MOVWF 0F
4433 14BC: BCF 03.0
4434 14BD: MOVLW 0D
4435 14BE: BCF 03.6
4436 14BF: MOVWF 3D
4437 14C0: BCF 0A.4
4438 14C1: CALL 193
4439 14C2: BSF 0A.4
4440 ....................
4441 .................... printf("Stavx: %Ld(procenta)\r\n", X);
4442 14C3: MOVLW 5D
4443 14C4: BSF 03.6
4444 14C5: MOVWF 0D
4445 14C6: MOVLW 00
4446 14C7: MOVWF 0F
4447 14C8: BCF 03.0
4448 14C9: MOVLW 07
4449 14CA: BCF 03.6
4450 14CB: MOVWF 3D
4451 14CC: BCF 0A.4
4452 14CD: CALL 193
4453 14CE: BSF 0A.4
4454 14CF: MOVLW 10
4455 14D0: MOVWF 04
4456 14D1: MOVF 28,W
4457 14D2: MOVWF 3D
4458 14D3: MOVF 27,W
4459 14D4: MOVWF 3C
4460 14D5: BCF 0A.4
4461 14D6: CALL 2D1
4462 14D7: BSF 0A.4
4463 14D8: MOVLW 62
4464 14D9: BSF 03.6
4465 14DA: MOVWF 0D
4466 14DB: MOVLW 00
4467 14DC: MOVWF 0F
4468 14DD: BCF 03.0
4469 14DE: MOVLW 0C
4470 14DF: BCF 03.6
4471 14E0: MOVWF 3D
4472 14E1: BCF 0A.4
4473 14E2: CALL 193
4474 14E3: BSF 0A.4
4475 .................... printf("Stavy: %Ld(procenta)\r\n", Y);
4476 14E4: MOVLW 69
4477 14E5: BSF 03.6
4478 14E6: MOVWF 0D
4479 14E7: MOVLW 00
4480 14E8: MOVWF 0F
4481 14E9: BCF 03.0
4482 14EA: MOVLW 07
4483 14EB: BCF 03.6
4484 14EC: MOVWF 3D
4485 14ED: BCF 0A.4
4486 14EE: CALL 193
4487 14EF: BSF 0A.4
4488 14F0: MOVLW 10
4489 14F1: MOVWF 04
4490 14F2: MOVF 2A,W
4491 14F3: MOVWF 3D
4492 14F4: MOVF 29,W
4493 14F5: MOVWF 3C
4494 14F6: BCF 0A.4
4495 14F7: CALL 2D1
4496 14F8: BSF 0A.4
4497 14F9: MOVLW 6E
4498 14FA: BSF 03.6
4499 14FB: MOVWF 0D
4500 14FC: MOVLW 00
4501 14FD: MOVWF 0F
4502 14FE: BCF 03.0
4503 14FF: MOVLW 0C
4504 1500: BCF 03.6
4505 1501: MOVWF 3D
4506 1502: BCF 0A.4
4507 1503: CALL 193
4508 1504: BSF 0A.4
4509 .................... printf("Stavz: %Ld(procenta)\r\n", Z);
4510 1505: MOVLW 75
4511 1506: BSF 03.6
4512 1507: MOVWF 0D
4513 1508: MOVLW 00
4514 1509: MOVWF 0F
4515 150A: BCF 03.0
4516 150B: MOVLW 07
4517 150C: BCF 03.6
4518 150D: MOVWF 3D
4519 150E: BCF 0A.4
4520 150F: CALL 193
4521 1510: BSF 0A.4
4522 1511: MOVLW 10
4523 1512: MOVWF 04
4524 1513: MOVF 2C,W
4525 1514: MOVWF 3D
4526 1515: MOVF 2B,W
4527 1516: MOVWF 3C
4528 1517: BCF 0A.4
4529 1518: CALL 2D1
4530 1519: BSF 0A.4
4531 151A: MOVLW 7A
4532 151B: BSF 03.6
4533 151C: MOVWF 0D
4534 151D: MOVLW 00
4535 151E: MOVWF 0F
4536 151F: BCF 03.0
4537 1520: MOVLW 0C
4538 1521: BCF 03.6
4539 1522: MOVWF 3D
4540 1523: BCF 0A.4
4541 1524: CALL 193
4542 1525: BSF 0A.4
4543 ....................
4544 ....................
4545 ....................
4546 .................... a=(float)Y/Z;
4547 1526: MOVF 2A,W
4548 1527: MOVWF 41
4549 1528: MOVF 29,W
4550 1529: MOVWF 40
4551 152A: BCF 0A.4
4552 152B: CALL 351
4553 152C: BSF 0A.4
4554 152D: MOVF 77,W
4555 152E: MOVWF 3C
4556 152F: MOVF 78,W
4557 1530: MOVWF 3D
4558 1531: MOVF 79,W
4559 1532: MOVWF 3E
4560 1533: MOVF 7A,W
4561 1534: MOVWF 3F
4562 1535: MOVF 2C,W
4563 1536: MOVWF 41
4564 1537: MOVF 2B,W
4565 1538: MOVWF 40
4566 1539: BCF 0A.4
4567 153A: CALL 351
4568 153B: BSF 0A.4
4569 153C: MOVF 3F,W
4570 153D: MOVWF 54
4571 153E: MOVF 3E,W
4572 153F: MOVWF 53
4573 1540: MOVF 3D,W
4574 1541: MOVWF 52
4575 1542: MOVF 3C,W
4576 1543: MOVWF 51
4577 1544: MOVF 7A,W
4578 1545: MOVWF 58
4579 1546: MOVF 79,W
4580 1547: MOVWF 57
4581 1548: MOVF 78,W
4582 1549: MOVWF 56
4583 154A: MOVF 77,W
4584 154B: MOVWF 55
4585 154C: BCF 0A.4
4586 154D: CALL 376
4587 154E: BSF 0A.4
4588 154F: MOVF 7A,W
4589 1550: MOVWF 30
4590 1551: MOVF 79,W
4591 1552: MOVWF 2F
4592 1553: MOVF 78,W
4593 1554: MOVWF 2E
4594 1555: MOVF 77,W
4595 1556: MOVWF 2D
4596 .................... printf("y/z %10.2f \r\n", a);
4597 1557: MOVLW 81
4598 1558: BSF 03.6
4599 1559: MOVWF 0D
4600 155A: MOVLW 00
4601 155B: MOVWF 0F
4602 155C: BCF 03.0
4603 155D: MOVLW 04
4604 155E: BCF 03.6
4605 155F: MOVWF 3D
4606 1560: BCF 0A.4
4607 1561: CALL 193
4608 1562: BSF 0A.4
4609 1563: MOVLW 09
4610 1564: MOVWF 04
4611 1565: MOVF 30,W
4612 1566: MOVWF 3F
4613 1567: MOVF 2F,W
4614 1568: MOVWF 3E
4615 1569: MOVF 2E,W
4616 156A: MOVWF 3D
4617 156B: MOVF 2D,W
4618 156C: MOVWF 3C
4619 156D: MOVLW 02
4620 156E: MOVWF 40
4621 156F: BCF 0A.4
4622 1570: CALL 4F7
4623 1571: BSF 0A.4
4624 1572: MOVLW 20
4625 1573: MOVWF 49
4626 1574: BCF 0A.4
4627 1575: CALL 098
4628 1576: BSF 0A.4
4629 1577: MOVLW 0D
4630 1578: MOVWF 49
4631 1579: BCF 0A.4
4632 157A: CALL 098
4633 157B: BSF 0A.4
4634 157C: MOVLW 0A
4635 157D: MOVWF 49
4636 157E: BCF 0A.4
4637 157F: CALL 098
4638 1580: BSF 0A.4
4639 .................... b=atan(a);
4640 1581: MOVF 30,W
4641 1582: MOVWF 3F
4642 1583: MOVF 2F,W
4643 1584: MOVWF 3E
4644 1585: MOVF 2E,W
4645 1586: MOVWF 3D
4646 1587: MOVF 2D,W
4647 1588: MOVWF 3C
4648 1589: BCF 0A.4
4649 158A: BSF 0A.3
4650 158B: GOTO 000
4651 158C: BSF 0A.4
4652 158D: BCF 0A.3
4653 158E: MOVF 7A,W
4654 158F: MOVWF 34
4655 1590: MOVF 79,W
4656 1591: MOVWF 33
4657 1592: MOVF 78,W
4658 1593: MOVWF 32
4659 1594: MOVF 77,W
4660 1595: MOVWF 31
4661 .................... printf("atan %10.2f \r\n", b);
4662 1596: MOVLW 88
4663 1597: BSF 03.6
4664 1598: MOVWF 0D
4665 1599: MOVLW 00
4666 159A: MOVWF 0F
4667 159B: BCF 03.0
4668 159C: MOVLW 05
4669 159D: BCF 03.6
4670 159E: MOVWF 3D
4671 159F: BCF 0A.4
4672 15A0: CALL 193
4673 15A1: BSF 0A.4
4674 15A2: MOVLW 09
4675 15A3: MOVWF 04
4676 15A4: MOVF 34,W
4677 15A5: MOVWF 3F
4678 15A6: MOVF 33,W
4679 15A7: MOVWF 3E
4680 15A8: MOVF 32,W
4681 15A9: MOVWF 3D
4682 15AA: MOVF 31,W
4683 15AB: MOVWF 3C
4684 15AC: MOVLW 02
4685 15AD: MOVWF 40
4686 15AE: BCF 0A.4
4687 15AF: CALL 4F7
4688 15B0: BSF 0A.4
4689 15B1: MOVLW 20
4690 15B2: MOVWF 49
4691 15B3: BCF 0A.4
4692 15B4: CALL 098
4693 15B5: BSF 0A.4
4694 15B6: MOVLW 0D
4695 15B7: MOVWF 49
4696 15B8: BCF 0A.4
4697 15B9: CALL 098
4698 15BA: BSF 0A.4
4699 15BB: MOVLW 0A
4700 15BC: MOVWF 49
4701 15BD: BCF 0A.4
4702 15BE: CALL 098
4703 15BF: BSF 0A.4
4704 .................... b = (b/3.14)*180;
4705 15C0: MOVF 34,W
4706 15C1: MOVWF 54
4707 15C2: MOVF 33,W
4708 15C3: MOVWF 53
4709 15C4: MOVF 32,W
4710 15C5: MOVWF 52
4711 15C6: MOVF 31,W
4712 15C7: MOVWF 51
4713 15C8: MOVLW C3
4714 15C9: MOVWF 58
4715 15CA: MOVLW F5
4716 15CB: MOVWF 57
4717 15CC: MOVLW 48
4718 15CD: MOVWF 56
4719 15CE: MOVLW 80
4720 15CF: MOVWF 55
4721 15D0: BCF 0A.4
4722 15D1: CALL 376
4723 15D2: BSF 0A.4
4724 15D3: MOVF 77,W
4725 15D4: MOVWF 3C
4726 15D5: MOVF 78,W
4727 15D6: MOVWF 3D
4728 15D7: MOVF 79,W
4729 15D8: MOVWF 3E
4730 15D9: MOVF 7A,W
4731 15DA: MOVWF 3F
4732 15DB: MOVWF 54
4733 15DC: MOVF 3E,W
4734 15DD: MOVWF 53
4735 15DE: MOVF 3D,W
4736 15DF: MOVWF 52
4737 15E0: MOVF 3C,W
4738 15E1: MOVWF 51
4739 15E2: CLRF 58
4740 15E3: CLRF 57
4741 15E4: MOVLW 34
4742 15E5: MOVWF 56
4743 15E6: MOVLW 86
4744 15E7: MOVWF 55
4745 15E8: BCF 0A.4
4746 15E9: CALL 440
4747 15EA: BSF 0A.4
4748 15EB: MOVF 7A,W
4749 15EC: MOVWF 34
4750 15ED: MOVF 79,W
4751 15EE: MOVWF 33
4752 15EF: MOVF 78,W
4753 15F0: MOVWF 32
4754 15F1: MOVF 77,W
4755 15F2: MOVWF 31
4756 .................... b=abs(b);
4757 15F3: MOVF 31,W
4758 15F4: MOVWF 77
4759 15F5: MOVF 32,W
4760 15F6: MOVWF 78
4761 15F7: MOVF 33,W
4762 15F8: MOVWF 79
4763 15F9: MOVF 34,W
4764 15FA: MOVWF 7A
4765 15FB: BCF 78.7
4766 15FC: MOVF 34,W
4767 15FD: MOVWF 34
4768 15FE: MOVF 33,W
4769 15FF: MOVWF 33
4770 1600: MOVF 78,W
4771 1601: MOVWF 32
4772 1602: MOVF 31,W
4773 1603: MOVWF 31
4774 .................... b=90-b;
4775 1604: BSF 03.1
4776 1605: CLRF 54
4777 1606: CLRF 53
4778 1607: MOVLW 34
4779 1608: MOVWF 52
4780 1609: MOVLW 85
4781 160A: MOVWF 51
4782 160B: MOVF 34,W
4783 160C: MOVWF 58
4784 160D: MOVF 33,W
4785 160E: MOVWF 57
4786 160F: MOVF 32,W
4787 1610: MOVWF 56
4788 1611: MOVF 31,W
4789 1612: MOVWF 55
4790 1613: BCF 0A.4
4791 1614: CALL 61D
4792 1615: BSF 0A.4
4793 1616: MOVF 7A,W
4794 1617: MOVWF 34
4795 1618: MOVF 79,W
4796 1619: MOVWF 33
4797 161A: MOVF 78,W
4798 161B: MOVWF 32
4799 161C: MOVF 77,W
4800 161D: MOVWF 31
4801 .................... printf("uhel %10.2f \r\n", b);
4802 161E: MOVLW 90
4803 161F: BSF 03.6
4804 1620: MOVWF 0D
4805 1621: MOVLW 00
4806 1622: MOVWF 0F
4807 1623: BCF 03.0
4808 1624: MOVLW 05
4809 1625: BCF 03.6
4810 1626: MOVWF 3D
4811 1627: BCF 0A.4
4812 1628: CALL 193
4813 1629: BSF 0A.4
4814 162A: MOVLW 09
4815 162B: MOVWF 04
4816 162C: MOVF 34,W
4817 162D: MOVWF 3F
4818 162E: MOVF 33,W
4819 162F: MOVWF 3E
4820 1630: MOVF 32,W
4821 1631: MOVWF 3D
4822 1632: MOVF 31,W
4823 1633: MOVWF 3C
4824 1634: MOVLW 02
4825 1635: MOVWF 40
4826 1636: BCF 0A.4
4827 1637: CALL 4F7
4828 1638: BSF 0A.4
4829 1639: MOVLW 20
4830 163A: MOVWF 49
4831 163B: BCF 0A.4
4832 163C: CALL 098
4833 163D: BSF 0A.4
4834 163E: MOVLW 0D
4835 163F: MOVWF 49
4836 1640: BCF 0A.4
4837 1641: CALL 098
4838 1642: BSF 0A.4
4839 1643: MOVLW 0A
4840 1644: MOVWF 49
4841 1645: BCF 0A.4
4842 1646: CALL 098
4843 1647: BSF 0A.4
4844 ....................
4845 .................... delay_ms (2000);
4846 1648: MOVLW 08
4847 1649: MOVWF 3C
4848 164A: MOVLW FA
4849 164B: MOVWF 3D
4850 164C: BCF 0A.4
4851 164D: GOTO 75E
4852 164E: BSF 0A.4
4853 164F: DECFSZ 3C,F
4854 1650: GOTO 64A
4855 ....................
4856 .................... }
4857 1651: GOTO 0AC
4858 .................... }
4859 1652: SLEEP
4860  
4861 Configuration Fuses:
4862 Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
4863 Word 2: 3FFF NOWRT BORV40