Imported Upstream version 2.9.0
[debian/cc1111] / device / lib / pic16 / libc / utils / cnvfrac.S
1 ;
2 ; Convertion routine of 24 bits floating point to ASCII
3 ;
4 ; written by Vangelis Rokas <vrokas AT otenet.gr>, 2004
5 ;
6 ;
7 ; This program is free software; you can redistribute it and/or
8 ; modify it under the terms of the GNU Library General Public License
9 ; as published by the Free Software Foundation; either version 2
10 ; of the License, or (at your option) any later version.
11 ;
12 ; This library is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ; GNU General Public License for more details.
16 ;
17 ; You should have received a copy of the GNU General Public License
18 ; along with this program; if not, write to the Free Software
19 ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 ;
21 ; $Id: cnvfrac.S 3711 2005-03-31 16:25:17Z vrokas $
22 ;
23         radix dec
24         list
25         nolist
26
27
28 WREG    equ     0xfe8
29 POSTINC0        equ     0xfee
30 POSTDEC1        equ     0xfe5
31 PREINC1 equ     0xfe4
32 STATUS  equ     0xfd8
33
34
35         global  _convert_frac
36
37
38 .registers      udata_ovr       0x000
39 r0x00   res     1
40 r0x01   res     1
41 r0x02   res     1
42 r0x03   res     1
43 round_digit     res     1
44 d0x00   res     1
45 d0x01   res     1
46 d0x02   res     1
47 d0x03   res     1
48 d0x04   res     1
49 d0x05   res     1
50 d0x06   res     1
51 d0x07   res     1
52 d0x08   res     1
53 d0x09   res     1
54 d0x10   res     1
55 d0x11   res     1
56 d0x12   res     1
57 d0x13   res     1
58 d0x14   res     1
59 d0x15   res     1
60 d0x16   res     1
61 d0x17   res     1
62 d0x18   res     1
63 d0x19   res     1
64 d0x20   res     1
65 d0x21   res     1
66 d0x22   res     1
67 d0x23   res     1
68 d0x24   res     1
69
70
71 S__convert_frac code
72 _convert_frac:
73
74         movff   d0x00, POSTDEC1
75         movff   d0x01, POSTDEC1
76         movff   d0x02, POSTDEC1
77         movff   d0x03, POSTDEC1
78         movff   d0x04, POSTDEC1
79         movff   d0x05, POSTDEC1
80         movff   d0x06, POSTDEC1
81         movff   d0x07, POSTDEC1
82         movff   d0x08, POSTDEC1
83         movff   d0x09, POSTDEC1
84         movff   d0x10, POSTDEC1
85         movff   d0x11, POSTDEC1
86         movff   d0x12, POSTDEC1
87         movff   d0x13, POSTDEC1
88         movff   d0x14, POSTDEC1
89         movff   d0x15, POSTDEC1
90         movff   d0x16, POSTDEC1
91         movff   d0x17, POSTDEC1
92         movff   d0x18, POSTDEC1
93         movff   d0x19, POSTDEC1
94         movff   d0x20, POSTDEC1
95         movff   d0x21, POSTDEC1
96         movff   d0x22, POSTDEC1
97         movff   d0x23, POSTDEC1
98         movff   d0x24, POSTDEC1
99
100
101 ; adding digit 0
102 ;       movff   0xf7f, 0xfe8
103
104         movlw   0
105
106         btfsc   r0x00, 0                ; bit 0
107         addlw   5
108
109
110         clrf    d0x01
111 @1:
112         addlw   -10
113         bnc     @2
114         incf    d0x01, f
115         bra     @1
116 @2:
117         addlw   10
118         movwf   d0x00
119
120
121         decfsz  round_digit, f
122         bra     @3
123         addlw   251
124         bnc     @3
125         incf    d0x01, f
126
127 @3:
128
129 ; adding digit 1
130         movf    d0x01, w
131
132         btfsc   r0x00, 0                ; bit 0
133         addlw   2
134
135         btfsc   r0x00, 1                ; bit 1
136         addlw   5
137
138
139         clrf    d0x02
140 @4:
141         addlw   -10
142         bnc     @5
143         incf    d0x02, f
144         bra     @4
145 @5:
146         addlw   10
147         movwf   d0x01
148
149
150         decfsz  round_digit, f
151         bra     @6
152         addlw   251
153         bnc     @6
154         incf    d0x02, f
155
156 @6:
157
158 ; adding digit 2
159         movf    d0x02, w
160
161         btfsc   r0x00, 0                ; bit 0
162         addlw   6
163
164         btfsc   r0x00, 1                ; bit 1
165         addlw   2
166
167         btfsc   r0x00, 2                ; bit 2
168         addlw   5
169
170
171         clrf    d0x03
172 @7:
173         addlw   -10
174         bnc     @8
175         incf    d0x03, f
176         bra     @7
177 @8:
178         addlw   10
179         movwf   d0x02
180
181
182         decfsz  round_digit, f
183         bra     @9
184         addlw   251
185         bnc     @9
186         incf    d0x03, f
187
188 @9:
189
190 ; adding digit 3
191         movf    d0x03, w
192
193         btfsc   r0x00, 1                ; bit 1
194         addlw   1
195
196         btfsc   r0x00, 2                ; bit 2
197         addlw   2
198
199         btfsc   r0x00, 3                ; bit 3
200         addlw   5
201
202
203         clrf    d0x04
204 @10:
205         addlw   -10
206         bnc     @11
207         incf    d0x04, f
208         bra     @10
209 @11:
210         addlw   10
211         movwf   d0x03
212
213
214         decfsz  round_digit, f
215         bra     @12
216         addlw   251
217         bnc     @12
218         incf    d0x04, f
219
220 @12:
221
222 ; adding digit 4
223         movf    d0x04, w
224
225         btfsc   r0x00, 0                ; bit 0
226         addlw   9
227
228         btfsc   r0x00, 1                ; bit 1
229         addlw   8
230
231         btfsc   r0x00, 2                ; bit 2
232         addlw   6
233
234         btfsc   r0x00, 3                ; bit 3
235         addlw   2
236
237         btfsc   r0x00, 4                ; bit 4
238         addlw   5
239
240
241         clrf    d0x05
242 @13:
243         addlw   -10
244         bnc     @14
245         incf    d0x05, f
246         bra     @13
247 @14:
248         addlw   10
249         movwf   d0x04
250
251
252         decfsz  round_digit, f
253         bra     @15
254         addlw   251
255         bnc     @15
256         incf    d0x05, f
257
258 @15:
259
260 ; adding digit 5
261         movf    d0x05, w
262
263         btfsc   r0x00, 0                ; bit 0
264         addlw   3
265
266         btfsc   r0x00, 1                ; bit 1
267         addlw   7
268
269         btfsc   r0x00, 2                ; bit 2
270         addlw   5
271
272         btfsc   r0x00, 3                ; bit 3
273         addlw   1
274
275         btfsc   r0x00, 4                ; bit 4
276         addlw   2
277
278         btfsc   r0x00, 5                ; bit 5
279         addlw   5
280
281
282         clrf    d0x06
283 @16:
284         addlw   -10
285         bnc     @17
286         incf    d0x06, f
287         bra     @16
288 @17:
289         addlw   10
290         movwf   d0x05
291
292
293         decfsz  round_digit, f
294         bra     @18
295         addlw   251
296         bnc     @18
297         incf    d0x06, f
298
299 @18:
300
301 ; adding digit 6
302         movf    d0x06, w
303
304         btfsc   r0x00, 0                ; bit 0
305         addlw   5
306
307         btfsc   r0x00, 2                ; bit 2
308         addlw   1
309
310         btfsc   r0x00, 3                ; bit 3
311         addlw   3
312
313         btfsc   r0x00, 4                ; bit 4
314         addlw   6
315
316         btfsc   r0x00, 5                ; bit 5
317         addlw   2
318
319         btfsc   r0x00, 6                ; bit 6
320         addlw   5
321
322
323         clrf    d0x07
324 @19:
325         addlw   -10
326         bnc     @20
327         incf    d0x07, f
328         bra     @19
329 @20:
330         addlw   10
331         movwf   d0x06
332
333
334         decfsz  round_digit, f
335         bra     @21
336         addlw   251
337         bnc     @21
338         incf    d0x07, f
339
340 @21:
341
342 ; adding digit 7
343         movf    d0x07, w
344
345         btfsc   r0x00, 0                ; bit 0
346         addlw   7
347
348         btfsc   r0x00, 1                ; bit 1
349         addlw   5
350
351         btfsc   r0x00, 5                ; bit 5
352         addlw   1
353
354         btfsc   r0x00, 6                ; bit 6
355         addlw   2
356
357         btfsc   r0x00, 7                ; bit 7
358         addlw   5
359
360
361         clrf    d0x08
362 @22:
363         addlw   -10
364         bnc     @23
365         incf    d0x08, f
366         bra     @22
367 @23:
368         addlw   10
369         movwf   d0x07
370
371
372         decfsz  round_digit, f
373         bra     @24
374         addlw   251
375         bnc     @24
376         incf    d0x08, f
377
378 @24:
379
380 ; adding digit 8
381         movf    d0x08, w
382
383         btfsc   r0x00, 0                ; bit 0
384         addlw   7
385
386         btfsc   r0x00, 1                ; bit 1
387         addlw   5
388
389         btfsc   r0x00, 2                ; bit 2
390         addlw   1
391
392         btfsc   r0x00, 3                ; bit 3
393         addlw   2
394
395         btfsc   r0x00, 4                ; bit 4
396         addlw   4
397
398         btfsc   r0x00, 5                ; bit 5
399         addlw   8
400
401         btfsc   r0x00, 6                ; bit 6
402         addlw   6
403
404         btfsc   r0x00, 7                ; bit 7
405         addlw   2
406
407         btfsc   r0x01, 0                ; bit 8
408         addlw   5
409
410
411         clrf    d0x09
412 @25:
413         addlw   -10
414         bnc     @26
415         incf    d0x09, f
416         bra     @25
417 @26:
418         addlw   10
419         movwf   d0x08
420
421
422         decfsz  round_digit, f
423         bra     @27
424         addlw   251
425         bnc     @27
426         incf    d0x09, f
427
428 @27:
429
430 ; adding digit 9
431         movf    d0x09, w
432
433         btfsc   r0x00, 0                ; bit 0
434         addlw   4
435
436         btfsc   r0x00, 1                ; bit 1
437         addlw   9
438
439         btfsc   r0x00, 2                ; bit 2
440         addlw   9
441
442         btfsc   r0x00, 3                ; bit 3
443         addlw   8
444
445         btfsc   r0x00, 4                ; bit 4
446         addlw   6
447
448         btfsc   r0x00, 5                ; bit 5
449         addlw   2
450
451         btfsc   r0x00, 6                ; bit 6
452         addlw   5
453
454         btfsc   r0x00, 7                ; bit 7
455         addlw   1
456
457         btfsc   r0x01, 0                ; bit 8
458         addlw   2
459
460         btfsc   r0x01, 1                ; bit 9
461         addlw   5
462
463
464         clrf    d0x10
465 @28:
466         addlw   -10
467         bnc     @29
468         incf    d0x10, f
469         bra     @28
470 @29:
471         addlw   10
472         movwf   d0x09
473
474
475         decfsz  round_digit, f
476         bra     @30
477         addlw   251
478         bnc     @30
479         incf    d0x10, f
480
481 @30:
482
483 ; adding digit 10
484         movf    d0x10, w
485
486         btfsc   r0x00, 0                ; bit 0
487         addlw   4
488
489         btfsc   r0x00, 1                ; bit 1
490         addlw   8
491
492         btfsc   r0x00, 2                ; bit 2
493         addlw   7
494
495         btfsc   r0x00, 3                ; bit 3
496         addlw   5
497
498         btfsc   r0x00, 4                ; bit 4
499         addlw   1
500
501         btfsc   r0x00, 5                ; bit 5
502         addlw   3
503
504         btfsc   r0x00, 6                ; bit 6
505         addlw   6
506
507         btfsc   r0x00, 7                ; bit 7
508         addlw   3
509
510         btfsc   r0x01, 0                ; bit 8
511         addlw   6
512
513         btfsc   r0x01, 1                ; bit 9
514         addlw   2
515
516         btfsc   r0x01, 2                ; bit 10
517         addlw   5
518
519
520         clrf    d0x11
521 @31:
522         addlw   -10
523         bnc     @32
524         incf    d0x11, f
525         bra     @31
526 @32:
527         addlw   10
528         movwf   d0x10
529
530
531         decfsz  round_digit, f
532         bra     @33
533         addlw   251
534         bnc     @33
535         incf    d0x11, f
536
537 @33:
538
539 ; adding digit 11
540         movf    d0x11, w
541
542         btfsc   r0x00, 0                ; bit 0
543         addlw   6
544
545         btfsc   r0x00, 1                ; bit 1
546         addlw   2
547
548         btfsc   r0x00, 2                ; bit 2
549         addlw   5
550
551         btfsc   r0x00, 3                ; bit 3
552         addlw   1
553
554         btfsc   r0x00, 4                ; bit 4
555         addlw   3
556
557         btfsc   r0x00, 5                ; bit 5
558         addlw   6
559
560         btfsc   r0x00, 6                ; bit 6
561         addlw   2
562
563         btfsc   r0x00, 7                ; bit 7
564         addlw   5
565
566         btfsc   r0x01, 1                ; bit 9
567         addlw   1
568
569         btfsc   r0x01, 2                ; bit 10
570         addlw   2
571
572         btfsc   r0x01, 3                ; bit 11
573         addlw   5
574
575
576         clrf    d0x12
577 @34:
578         addlw   -10
579         bnc     @35
580         incf    d0x12, f
581         bra     @34
582 @35:
583         addlw   10
584         movwf   d0x11
585
586
587         decfsz  round_digit, f
588         bra     @36
589         addlw   251
590         bnc     @36
591         incf    d0x12, f
592
593 @36:
594
595 ; adding digit 12
596         movf    d0x12, w
597
598         btfsc   r0x00, 0                ; bit 0
599         addlw   4
600
601         btfsc   r0x00, 1                ; bit 1
602         addlw   9
603
604         btfsc   r0x00, 2                ; bit 2
605         addlw   8
606
607         btfsc   r0x00, 3                ; bit 3
608         addlw   7
609
610         btfsc   r0x00, 4                ; bit 4
611         addlw   4
612
613         btfsc   r0x00, 5                ; bit 5
614         addlw   8
615
616         btfsc   r0x00, 6                ; bit 6
617         addlw   7
618
619         btfsc   r0x00, 7                ; bit 7
620         addlw   4
621
622         btfsc   r0x01, 0                ; bit 8
623         addlw   9
624
625         btfsc   r0x01, 1                ; bit 9
626         addlw   8
627
628         btfsc   r0x01, 2                ; bit 10
629         addlw   6
630
631         btfsc   r0x01, 3                ; bit 11
632         addlw   2
633
634         btfsc   r0x01, 4                ; bit 12
635         addlw   5
636
637
638         clrf    d0x13
639 @37:
640         addlw   -10
641         bnc     @38
642         incf    d0x13, f
643         bra     @37
644 @38:
645         addlw   10
646         movwf   d0x12
647
648
649         decfsz  round_digit, f
650         bra     @39
651         addlw   251
652         bnc     @39
653         incf    d0x13, f
654
655 @39:
656
657 ; adding digit 13
658         movf    d0x13, w
659
660         btfsc   r0x00, 2                ; bit 2
661         addlw   1
662
663         btfsc   r0x00, 3                ; bit 3
664         addlw   3
665
666         btfsc   r0x00, 4                ; bit 4
667         addlw   7
668
669         btfsc   r0x00, 5                ; bit 5
670         addlw   4
671
672         btfsc   r0x00, 6                ; bit 6
673         addlw   9
674
675         btfsc   r0x00, 7                ; bit 7
676         addlw   9
677
678         btfsc   r0x01, 0                ; bit 8
679         addlw   8
680
681         btfsc   r0x01, 1                ; bit 9
682         addlw   7
683
684         btfsc   r0x01, 2                ; bit 10
685         addlw   5
686
687         btfsc   r0x01, 3                ; bit 11
688         addlw   1
689
690         btfsc   r0x01, 4                ; bit 12
691         addlw   2
692
693         btfsc   r0x01, 5                ; bit 13
694         addlw   5
695
696
697         clrf    d0x14
698 @40:
699         addlw   -10
700         bnc     @41
701         incf    d0x14, f
702         bra     @40
703 @41:
704         addlw   10
705         movwf   d0x13
706
707
708         decfsz  round_digit, f
709         bra     @42
710         addlw   251
711         bnc     @42
712         incf    d0x14, f
713
714 @42:
715
716 ; adding digit 14
717         movf    d0x14, w
718
719         btfsc   r0x00, 0                ; bit 0
720         addlw   6
721
722         btfsc   r0x00, 1                ; bit 1
723         addlw   2
724
725         btfsc   r0x00, 2                ; bit 2
726         addlw   4
727
728         btfsc   r0x00, 3                ; bit 3
729         addlw   8
730
731         btfsc   r0x00, 4                ; bit 4
732         addlw   6
733
734         btfsc   r0x00, 5                ; bit 5
735         addlw   3
736
737         btfsc   r0x00, 6                ; bit 6
738         addlw   6
739
740         btfsc   r0x00, 7                ; bit 7
741         addlw   3
742
743         btfsc   r0x01, 0                ; bit 8
744         addlw   7
745
746         btfsc   r0x01, 1                ; bit 9
747         addlw   5
748
749         btfsc   r0x01, 2                ; bit 10
750         addlw   1
751
752         btfsc   r0x01, 3                ; bit 11
753         addlw   3
754
755         btfsc   r0x01, 4                ; bit 12
756         addlw   6
757
758         btfsc   r0x01, 5                ; bit 13
759         addlw   2
760
761         btfsc   r0x01, 6                ; bit 14
762         addlw   5
763
764
765         clrf    d0x15
766 @43:
767         addlw   -10
768         bnc     @44
769         incf    d0x15, f
770         bra     @43
771 @44:
772         addlw   10
773         movwf   d0x14
774
775
776         decfsz  round_digit, f
777         bra     @45
778         addlw   251
779         bnc     @45
780         incf    d0x15, f
781
782 @45:
783
784 ; adding digit 15
785         movf    d0x15, w
786
787         btfsc   r0x00, 0                ; bit 0
788         addlw   9
789
790         btfsc   r0x00, 1                ; bit 1
791         addlw   9
792
793         btfsc   r0x00, 2                ; bit 2
794         addlw   8
795
796         btfsc   r0x00, 3                ; bit 3
797         addlw   6
798
799         btfsc   r0x00, 4                ; bit 4
800         addlw   3
801
802         btfsc   r0x00, 5                ; bit 5
803         addlw   7
804
805         btfsc   r0x00, 6                ; bit 6
806         addlw   4
807
808         btfsc   r0x00, 7                ; bit 7
809         addlw   9
810
811         btfsc   r0x01, 0                ; bit 8
812         addlw   8
813
814         btfsc   r0x01, 1                ; bit 9
815         addlw   7
816
817         btfsc   r0x01, 2                ; bit 10
818         addlw   5
819
820         btfsc   r0x01, 5                ; bit 13
821         addlw   1
822
823         btfsc   r0x01, 6                ; bit 14
824         addlw   2
825
826         btfsc   r0x01, 7                ; bit 15
827         addlw   5
828
829
830         clrf    d0x16
831 @46:
832         addlw   -10
833         bnc     @47
834         incf    d0x16, f
835         bra     @46
836 @47:
837         addlw   10
838         movwf   d0x15
839
840
841         decfsz  round_digit, f
842         bra     @48
843         addlw   251
844         bnc     @48
845         incf    d0x16, f
846
847 @48:
848
849 ; adding digit 16
850         movf    d0x16, w
851
852         btfsc   r0x00, 0                ; bit 0
853         addlw   5
854
855         btfsc   r0x00, 1                ; bit 1
856         addlw   1
857
858         btfsc   r0x00, 2                ; bit 2
859         addlw   3
860
861         btfsc   r0x00, 3                ; bit 3
862         addlw   7
863
864         btfsc   r0x00, 4                ; bit 4
865         addlw   5
866
867         btfsc   r0x00, 6                ; bit 6
868         addlw   1
869
870         btfsc   r0x00, 7                ; bit 7
871         addlw   2
872
873         btfsc   r0x01, 0                ; bit 8
874         addlw   5
875
876         btfsc   r0x01, 1                ; bit 9
877         addlw   1
878
879         btfsc   r0x01, 2                ; bit 10
880         addlw   3
881
882         btfsc   r0x01, 3                ; bit 11
883         addlw   7
884
885         btfsc   r0x01, 4                ; bit 12
886         addlw   4
887
888         btfsc   r0x01, 5                ; bit 13
889         addlw   8
890
891         btfsc   r0x01, 6                ; bit 14
892         addlw   6
893
894         btfsc   r0x01, 7                ; bit 15
895         addlw   2
896
897         btfsc   r0x02, 0                ; bit 16
898         addlw   5
899
900
901         clrf    d0x17
902 @49:
903         addlw   -10
904         bnc     @50
905         incf    d0x17, f
906         bra     @49
907 @50:
908         addlw   10
909         movwf   d0x16
910
911
912         decfsz  round_digit, f
913         bra     @51
914         addlw   251
915         bnc     @51
916         incf    d0x17, f
917
918 @51:
919
920 ; adding digit 17
921         movf    d0x17, w
922
923         btfsc   r0x00, 1                ; bit 1
924         addlw   1
925
926         btfsc   r0x00, 2                ; bit 2
927         addlw   2
928
929         btfsc   r0x00, 3                ; bit 3
930         addlw   4
931
932         btfsc   r0x00, 4                ; bit 4
933         addlw   9
934
935         btfsc   r0x00, 5                ; bit 5
936         addlw   9
937
938         btfsc   r0x00, 6                ; bit 6
939         addlw   8
940
941         btfsc   r0x00, 7                ; bit 7
942         addlw   6
943
944         btfsc   r0x01, 0                ; bit 8
945         addlw   2
946
947         btfsc   r0x01, 1                ; bit 9
948         addlw   5
949
950         btfsc   r0x01, 4                ; bit 12
951         addlw   1
952
953         btfsc   r0x01, 5                ; bit 13
954         addlw   2
955
956         btfsc   r0x01, 6                ; bit 14
957         addlw   5
958
959         btfsc   r0x01, 7                ; bit 15
960         addlw   1
961
962         btfsc   r0x02, 0                ; bit 16
963         addlw   2
964
965         btfsc   r0x02, 1                ; bit 17
966         addlw   5
967
968
969         clrf    d0x18
970 @52:
971         addlw   -10
972         bnc     @53
973         incf    d0x18, f
974         bra     @52
975 @53:
976         addlw   10
977         movwf   d0x17
978
979
980         decfsz  round_digit, f
981         bra     @54
982         addlw   251
983         bnc     @54
984         incf    d0x18, f
985
986 @54:
987
988 ; adding digit 18
989         movf    d0x18, w
990
991         btfsc   r0x00, 5                ; bit 5
992         addlw   1
993
994         btfsc   r0x00, 6                ; bit 6
995         addlw   3
996
997         btfsc   r0x00, 7                ; bit 7
998         addlw   7
999
1000         btfsc   r0x01, 0                ; bit 8
1001         addlw   5
1002
1003         btfsc   r0x01, 2                ; bit 10
1004         addlw   1
1005
1006         btfsc   r0x01, 3                ; bit 11
1007         addlw   2
1008
1009         btfsc   r0x01, 4                ; bit 12
1010         addlw   4
1011
1012         btfsc   r0x01, 5                ; bit 13
1013         addlw   8
1014
1015         btfsc   r0x01, 6                ; bit 14
1016         addlw   6
1017
1018         btfsc   r0x01, 7                ; bit 15
1019         addlw   3
1020
1021         btfsc   r0x02, 0                ; bit 16
1022         addlw   6
1023
1024         btfsc   r0x02, 1                ; bit 17
1025         addlw   2
1026
1027         btfsc   r0x02, 2                ; bit 18
1028         addlw   5
1029
1030
1031         clrf    d0x19
1032 @55:
1033         addlw   -10
1034         bnc     @56
1035         incf    d0x19, f
1036         bra     @55
1037 @56:
1038         addlw   10
1039         movwf   d0x18
1040
1041
1042         decfsz  round_digit, f
1043         bra     @57
1044         addlw   251
1045         bnc     @57
1046         incf    d0x19, f
1047
1048 @57:
1049
1050 ; adding digit 19
1051         movf    d0x19, w
1052
1053         btfsc   r0x01, 0                ; bit 8
1054         addlw   1
1055
1056         btfsc   r0x01, 1                ; bit 9
1057         addlw   3
1058
1059         btfsc   r0x01, 2                ; bit 10
1060         addlw   6
1061
1062         btfsc   r0x01, 3                ; bit 11
1063         addlw   2
1064
1065         btfsc   r0x01, 4                ; bit 12
1066         addlw   4
1067
1068         btfsc   r0x01, 5                ; bit 13
1069         addlw   8
1070
1071         btfsc   r0x01, 6                ; bit 14
1072         addlw   7
1073
1074         btfsc   r0x01, 7                ; bit 15
1075         addlw   5
1076
1077         btfsc   r0x02, 1                ; bit 17
1078         addlw   1
1079
1080         btfsc   r0x02, 2                ; bit 18
1081         addlw   2
1082
1083         btfsc   r0x02, 3                ; bit 19
1084         addlw   5
1085
1086
1087         clrf    d0x20
1088 @58:
1089         addlw   -10
1090         bnc     @59
1091         incf    d0x20, f
1092         bra     @58
1093 @59:
1094         addlw   10
1095         movwf   d0x19
1096
1097
1098         decfsz  round_digit, f
1099         bra     @60
1100         addlw   251
1101         bnc     @60
1102         incf    d0x20, f
1103
1104 @60:
1105
1106 ; adding digit 20
1107         movf    d0x20, w
1108
1109         btfsc   r0x01, 3                ; bit 11
1110         addlw   1
1111
1112         btfsc   r0x01, 4                ; bit 12
1113         addlw   2
1114
1115         btfsc   r0x01, 5                ; bit 13
1116         addlw   4
1117
1118         btfsc   r0x01, 6                ; bit 14
1119         addlw   9
1120
1121         btfsc   r0x01, 7                ; bit 15
1122         addlw   9
1123
1124         btfsc   r0x02, 0                ; bit 16
1125         addlw   9
1126
1127         btfsc   r0x02, 1                ; bit 17
1128         addlw   8
1129
1130         btfsc   r0x02, 2                ; bit 18
1131         addlw   6
1132
1133         btfsc   r0x02, 3                ; bit 19
1134         addlw   2
1135
1136         btfsc   r0x02, 4                ; bit 20
1137         addlw   5
1138
1139
1140         clrf    d0x21
1141 @61:
1142         addlw   -10
1143         bnc     @62
1144         incf    d0x21, f
1145         bra     @61
1146 @62:
1147         addlw   10
1148         movwf   d0x20
1149
1150
1151         decfsz  round_digit, f
1152         bra     @63
1153         addlw   251
1154         bnc     @63
1155         incf    d0x21, f
1156
1157 @63:
1158
1159 ; adding digit 21
1160         movf    d0x21, w
1161
1162         btfsc   r0x01, 7                ; bit 15
1163         addlw   1
1164
1165         btfsc   r0x02, 0                ; bit 16
1166         addlw   3
1167
1168         btfsc   r0x02, 1                ; bit 17
1169         addlw   7
1170
1171         btfsc   r0x02, 2                ; bit 18
1172         addlw   5
1173
1174         btfsc   r0x02, 3                ; bit 19
1175         addlw   1
1176
1177         btfsc   r0x02, 4                ; bit 20
1178         addlw   2
1179
1180         btfsc   r0x02, 5                ; bit 21
1181         addlw   5
1182
1183
1184         clrf    d0x22
1185 @64:
1186         addlw   -10
1187         bnc     @65
1188         incf    d0x22, f
1189         bra     @64
1190 @65:
1191         addlw   10
1192         movwf   d0x21
1193
1194
1195         decfsz  round_digit, f
1196         bra     @66
1197         addlw   251
1198         bnc     @66
1199         incf    d0x22, f
1200
1201 @66:
1202
1203 ; adding digit 22
1204         movf    d0x22, w
1205
1206         btfsc   r0x02, 2                ; bit 18
1207         addlw   1
1208
1209         btfsc   r0x02, 3                ; bit 19
1210         addlw   3
1211
1212         btfsc   r0x02, 4                ; bit 20
1213         addlw   6
1214
1215         btfsc   r0x02, 5                ; bit 21
1216         addlw   2
1217
1218         btfsc   r0x02, 6                ; bit 22
1219         addlw   5
1220
1221
1222         clrf    d0x23
1223 @67:
1224         addlw   -10
1225         bnc     @68
1226         incf    d0x23, f
1227         bra     @67
1228 @68:
1229         addlw   10
1230         movwf   d0x22
1231
1232
1233         decfsz  round_digit, f
1234         bra     @69
1235         addlw   251
1236         bnc     @69
1237         incf    d0x23, f
1238
1239 @69:
1240
1241 ; adding digit 23
1242         movf    d0x23, w
1243
1244         btfsc   r0x02, 5                ; bit 21
1245         addlw   1
1246
1247         btfsc   r0x02, 6                ; bit 22
1248         addlw   2
1249
1250         btfsc   r0x02, 7                ; bit 23
1251         addlw   5
1252
1253
1254         clrf    d0x24
1255 @70:
1256         addlw   -10
1257         bnc     @71
1258         incf    d0x24, f
1259         bra     @70
1260 @71:
1261         addlw   10
1262         movwf   d0x23
1263
1264
1265         decfsz  round_digit, f
1266         bra     @72
1267         addlw   251
1268         bnc     @72
1269         incf    d0x24, f
1270
1271 @72:
1272
1273
1274 ; finalization
1275 @73:
1276         addlw   48
1277         movwf   POSTINC0
1278         movf    d0x22, w
1279 @74:
1280         addlw   48
1281         movwf   POSTINC0
1282         movf    d0x21, w
1283 @75:
1284         addlw   48
1285         movwf   POSTINC0
1286         movf    d0x20, w
1287 @76:
1288         addlw   48
1289         movwf   POSTINC0
1290         movf    d0x19, w
1291 @77:
1292         addlw   48
1293         movwf   POSTINC0
1294         movf    d0x18, w
1295 @78:
1296         addlw   48
1297         movwf   POSTINC0
1298         movf    d0x17, w
1299 @79:
1300         addlw   48
1301         movwf   POSTINC0
1302         movf    d0x16, w
1303 @80:
1304         addlw   48
1305         movwf   POSTINC0
1306         movf    d0x15, w
1307 @81:
1308         addlw   48
1309         movwf   POSTINC0
1310         movf    d0x14, w
1311 @82:
1312         addlw   48
1313         movwf   POSTINC0
1314         movf    d0x13, w
1315 @83:
1316         addlw   48
1317         movwf   POSTINC0
1318         movf    d0x12, w
1319 @84:
1320         addlw   48
1321         movwf   POSTINC0
1322         movf    d0x11, w
1323 @85:
1324         addlw   48
1325         movwf   POSTINC0
1326         movf    d0x10, w
1327 @86:
1328         addlw   48
1329         movwf   POSTINC0
1330         movf    d0x09, w
1331 @87:
1332         addlw   48
1333         movwf   POSTINC0
1334         movf    d0x08, w
1335 @88:
1336         addlw   48
1337         movwf   POSTINC0
1338         movf    d0x07, w
1339 @89:
1340         addlw   48
1341         movwf   POSTINC0
1342         movf    d0x06, w
1343 @90:
1344         addlw   48
1345         movwf   POSTINC0
1346         movf    d0x05, w
1347 @91:
1348         addlw   48
1349         movwf   POSTINC0
1350         movf    d0x04, w
1351 @92:
1352         addlw   48
1353         movwf   POSTINC0
1354         movf    d0x03, w
1355 @93:
1356         addlw   48
1357         movwf   POSTINC0
1358         movf    d0x02, w
1359 @94:
1360         addlw   48
1361         movwf   POSTINC0
1362         movf    d0x01, w
1363 @95:
1364         addlw   48
1365         movwf   POSTINC0
1366         movf    d0x00, w
1367 @96:
1368         addlw   48
1369         movwf   POSTINC0
1370
1371         movlw   23
1372
1373         movff   PREINC1, d0x24
1374         movff   PREINC1, d0x23
1375         movff   PREINC1, d0x22
1376         movff   PREINC1, d0x21
1377         movff   PREINC1, d0x20
1378         movff   PREINC1, d0x19
1379         movff   PREINC1, d0x18
1380         movff   PREINC1, d0x17
1381         movff   PREINC1, d0x16
1382         movff   PREINC1, d0x15
1383         movff   PREINC1, d0x14
1384         movff   PREINC1, d0x13
1385         movff   PREINC1, d0x12
1386         movff   PREINC1, d0x11
1387         movff   PREINC1, d0x10
1388         movff   PREINC1, d0x09
1389         movff   PREINC1, d0x08
1390         movff   PREINC1, d0x07
1391         movff   PREINC1, d0x06
1392         movff   PREINC1, d0x05
1393         movff   PREINC1, d0x04
1394         movff   PREINC1, d0x03
1395         movff   PREINC1, d0x02
1396         movff   PREINC1, d0x01
1397         movff   PREINC1, d0x00
1398         return
1399
1400         end
1401
1402 ; Converstion table
1403 ;
1404 ;00     0.5000000000000000000000000     5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1405 ;01     0.2500000000000000000000000     2 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1406 ;02     0.1250000000000000000000000     1 2 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1407 ;03     0.0625000000000000000000000     0 6 2 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1408 ;04     0.0312500000000000000000000     0 3 1 2 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1409 ;05     0.0156250000000000000000000     0 1 5 6 2 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1410 ;06     0.0078125000000000000000000     0 0 7 8 1 2 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1411 ;07     0.0039062500000000000000000     0 0 3 9 0 6 2 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1412 ;08     0.0019531250000000000000000     0 0 1 9 5 3 1 2 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1413 ;09     0.0009765625000000000000000     0 0 0 9 7 6 5 6 2 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1414 ;10     0.0004882812500000000000000     0 0 0 4 8 8 2 8 1 2 5 0 0 0 0 0 0 0 0 0 0 0 0 0 
1415 ;11     0.0002441406250000000000000     0 0 0 2 4 4 1 4 0 6 2 5 0 0 0 0 0 0 0 0 0 0 0 0 
1416 ;12     0.0001220703125000000000000     0 0 0 1 2 2 0 7 0 3 1 2 5 0 0 0 0 0 0 0 0 0 0 0 
1417 ;13     0.0000610351562500000000000     0 0 0 0 6 1 0 3 5 1 5 6 2 5 0 0 0 0 0 0 0 0 0 0 
1418 ;14     0.0000305175781250000000000     0 0 0 0 3 0 5 1 7 5 7 8 1 2 5 0 0 0 0 0 0 0 0 0 
1419 ;15     0.0000152587890625000000000     0 0 0 0 1 5 2 5 8 7 8 9 0 6 2 5 0 0 0 0 0 0 0 0 
1420 ;16     0.0000076293945312500000000     0 0 0 0 0 7 6 2 9 3 9 4 5 3 1 2 5 0 0 0 0 0 0 0 
1421 ;17     0.0000038146972656250000000     0 0 0 0 0 3 8 1 4 6 9 7 2 6 5 6 2 5 0 0 0 0 0 0 
1422 ;18     0.0000019073486328125000000     0 0 0 0 0 1 9 0 7 3 4 8 6 3 2 8 1 2 5 0 0 0 0 0 
1423 ;19     0.0000009536743164062500000     0 0 0 0 0 0 9 5 3 6 7 4 3 1 6 4 0 6 2 5 0 0 0 0 
1424 ;20     0.0000004768371582031250000     0 0 0 0 0 0 4 7 6 8 3 7 1 5 8 2 0 3 1 2 5 0 0 0 
1425 ;21     0.0000002384185791015625000     0 0 0 0 0 0 2 3 8 4 1 8 5 7 9 1 0 1 5 6 2 5 0 0 
1426 ;22     0.0000001192092895507812500     0 0 0 0 0 0 1 1 9 2 0 9 2 8 9 5 5 0 7 8 1 2 5 0 
1427 ;23     0.0000000596046447753906250     0 0 0 0 0 0 0 5 9 6 0 4 6 4 4 7 7 5 3 9 0 6 2 5