annotate src/convert.asm @ 628:cd58f7fc86db

3.05 stable work
author heinrichsweikamp
date Thu, 19 Sep 2019 12:01:29 +0200
parents c40025d8e750
children 4050675965ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
3 ; File convert.asm combined next generation V3.04.2
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Converts register values to string
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, Matthias Heinrichs, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2007-10-07 : [MH] Creation for OSTC sources
heinrichsweikamp
parents:
diff changeset
11 ; 2010-12-10 : [jDG] Optimize macro size
heinrichsweikamp
parents:
diff changeset
12 ;
heinrichsweikamp
parents:
diff changeset
13
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
14 #include "hwos.inc" ; Mandatory header
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
15
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
16 convert CODE
0
heinrichsweikamp
parents:
diff changeset
17
heinrichsweikamp
parents:
diff changeset
18 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
19
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
20 global output99DD_call
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
21 output99DD_call:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
22 tstfsz lo ; value = 0 ?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
23 bra output99_call ; NO - do normal output
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
24 movlw " " ; YES - print a space
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
25 movwf POSTINC2 ; - ...
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
26 bra output99dd_cont ; - continue with the double dots
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
27
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
28
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
29 global output99dd_call
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
30 output99dd_call:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
31 tstfsz lo ; value = 0 ?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
32 bra output99_call ; NO - do normal output
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
33 output99dd_cont:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
34 movlw "." ; YES - print double dots
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
35 movwf POSTINC2 ; - ...
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
36 movwf POSTINC2 ; - ...
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
37 return ; - done
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
38
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
39
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
40 global output99_call
0
heinrichsweikamp
parents:
diff changeset
41 output99_call:
heinrichsweikamp
parents:
diff changeset
42 clrf ignore_digits
heinrichsweikamp
parents:
diff changeset
43 incf ignore_digits,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
44 clrf cvt_temp4
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
45 ;bra output99
0
heinrichsweikamp
parents:
diff changeset
46
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
47
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
48 global output99
0
heinrichsweikamp
parents:
diff changeset
49 output99:
heinrichsweikamp
parents:
diff changeset
50 movlw d'99'
heinrichsweikamp
parents:
diff changeset
51 cpfslt lo
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
52 movwf lo ; limit to 99
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
53 movff lo,cvt_temp_lo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
54 clrf cvt_temp_hi
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
55 bcf pre_zero_flag ; do not display leading zeros
0
heinrichsweikamp
parents:
diff changeset
56
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
57 LCD_val99_2:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
58 movlw .10 ; 10
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
59 movwf cvt_temp2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
60 clrf cvt_temp3
0
heinrichsweikamp
parents:
diff changeset
61 rcall DEC2ASCII
heinrichsweikamp
parents:
diff changeset
62
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
63 movlw .1 ; 1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
64 movwf cvt_temp2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
65 clrf cvt_temp3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
66 bsf pre_zero_flag ; last figure, display zero (0)
0
heinrichsweikamp
parents:
diff changeset
67 rcall DEC2ASCII
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
68 return
0
heinrichsweikamp
parents:
diff changeset
69
heinrichsweikamp
parents:
diff changeset
70 global output99x_call
heinrichsweikamp
parents:
diff changeset
71 output99x_call:
heinrichsweikamp
parents:
diff changeset
72 clrf ignore_digits
heinrichsweikamp
parents:
diff changeset
73 incf ignore_digits,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
74 clrf cvt_temp4
0
heinrichsweikamp
parents:
diff changeset
75
heinrichsweikamp
parents:
diff changeset
76 movlw d'99'
heinrichsweikamp
parents:
diff changeset
77 cpfslt lo
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
78 movwf lo ; limit to 99
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
79 movff lo,cvt_temp_lo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
80 clrf cvt_temp_hi
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
81 bsf pre_zero_flag ; display leading zeros
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
82 bra LCD_val99_2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
83
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
84
0
heinrichsweikamp
parents:
diff changeset
85 global output8_call
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
86 output8_call:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
87 clrf ignore_digits
0
heinrichsweikamp
parents:
diff changeset
88 incf ignore_digits,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
89 clrf cvt_temp4
0
heinrichsweikamp
parents:
diff changeset
90
heinrichsweikamp
parents:
diff changeset
91 output8:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
92 movff lo,cvt_temp_lo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
93 clrf cvt_temp_hi
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
94 bcf pre_zero_flag ; do not display leading zeros
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
95 movlw .100 ; 100
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
96 movwf cvt_temp2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
97 clrf cvt_temp3
0
heinrichsweikamp
parents:
diff changeset
98 rcall DEC2ASCII
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
99 bra LCD_val99_2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
100
0
heinrichsweikamp
parents:
diff changeset
101
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 275
diff changeset
102 global output16_4_call
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
103 output16_4_call: ; limit to 9999
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 275
diff changeset
104 bsf show_last4
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
105 ; 9999 = 27 0F = [39][15]
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
106 movlw .40
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
107 cpfslt hi ; hi < 40 ?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
108 bra output16_4_call_2 ; NO - hi >= 40, do limit
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
109 ; YES - hi <= 39
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
110 movlw .39
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
111 cpfseq hi ; hi = 39 ?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
112 bra output16_4_call_3 ; NO - hi < 39, no limit needed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
113 ; YES - hi = 39
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
114 movlw .15
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
115 cpfslt lo ; lo < 15
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
116 movwf lo ; NO - lo >= 15, set lo = 15
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
117 ; YES - lo <= 14 or lo set to =15
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
118 bra output16_4_call_3 ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
119
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
120 output16_4_call_2: ; set to 9999
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
121 MOVLI .9999,mpr
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 275
diff changeset
122 output16_4_call_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
123 bra output16_call
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 275
diff changeset
124
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
125
0
heinrichsweikamp
parents:
diff changeset
126 global output16_3_call
heinrichsweikamp
parents:
diff changeset
127 global output16_call
heinrichsweikamp
parents:
diff changeset
128 global output16
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
129 output16_3_call: ; limit to 999
225
31088352ee32 BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents: 0
diff changeset
130 bsf show_last3
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
131 ; Limit to 3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
132 movlw .4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
133 cpfslt hi
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
134 bra output16_3_call_2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
135 movlw .3
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
136 cpfseq hi ; = 3 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
137 bra output16_3_call_3 ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
138 movlw .231 ; limit to 231(+768=999...)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
139 cpfslt lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
140 movwf lo
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
141 bra output16_3_call_3 ; done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
142 output16_3_call_2: ; set to .999
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
143 MOVLI .999,mpr
225
31088352ee32 BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents: 0
diff changeset
144 output16_3_call_3:
0
heinrichsweikamp
parents:
diff changeset
145 output16_call:
heinrichsweikamp
parents:
diff changeset
146 clrf ignore_digits
heinrichsweikamp
parents:
diff changeset
147 incf ignore_digits,F
heinrichsweikamp
parents:
diff changeset
148 clrf WREG
heinrichsweikamp
parents:
diff changeset
149 output16:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
150 movwf cvt_temp4 ; passed from output16dp macro, cleared by others.
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
151 bcf all_zeros_flag ; do not display any zero from here unless there was at least one figure /zero
0
heinrichsweikamp
parents:
diff changeset
152 bsf leading_zeros
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
153 tstfsz cvt_temp4 ; display leading zeros at all?
0
heinrichsweikamp
parents:
diff changeset
154 bcf leading_zeros
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
155 bsf DP_done2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
156 tstfsz cvt_temp4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
157 bcf DP_done2 ; decimal point not yet set
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
158 movff lo,cvt_temp_lo ; copy hi:lo to cvt_temp_hi:cvt_temp_lo
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
159 movff hi,cvt_temp_hi ; ...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
160 bcf pre_zero_flag ; do not display leading zeros
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
161 movlw b'00010000' ; 10000s
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
162 movwf cvt_temp2
0
heinrichsweikamp
parents:
diff changeset
163 movlw b'00100111'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
164 movwf cvt_temp3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
165 btfsc show_last3 ; display only last three figures?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
166 bra output16_sk5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
167 btfsc show_last4 ; display only last four figures?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
168 bra output16_sk5
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
169 rcall DEC2ASCII ; NO - show all, here: 5th order digit
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 275
diff changeset
170
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 275
diff changeset
171 output16_sk5:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
172 bcf show_last4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
173 movlw b'11101000' ; 1000s
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
174 movwf cvt_temp2
0
heinrichsweikamp
parents:
diff changeset
175 movlw b'00000011'
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
176 movwf cvt_temp3
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
177 btfsc DP_done2 ; is there a decimal point at all?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
178 bra output16_2 ; NO - use normal display mode
0
heinrichsweikamp
parents:
diff changeset
179
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
180 btfsc all_zeros_flag ; display any zero from here
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
181 bra output16_1 ; there was a figure /zero already
0
heinrichsweikamp
parents:
diff changeset
182
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
183 bsf pre_zero_flag ; display figure if zero?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
184 decfsz cvt_temp4,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
185 bcf pre_zero_flag ; NO
0
heinrichsweikamp
parents:
diff changeset
186
heinrichsweikamp
parents:
diff changeset
187 output16_1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
188 btfsc DP_done ; decimal point set already?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
189 bsf pre_zero_flag ; YES - so display the rest
0
heinrichsweikamp
parents:
diff changeset
190 output16_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
191 btfss show_last3 ; display only last three figures?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
192 rcall DEC2ASCII ; NO - show all. Here: 4th order digit
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
193 bcf show_last3 ; YES - so display the rest
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
194 movlw b'01100100' ; 100s
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
195 movwf cvt_temp2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
196 clrf cvt_temp3
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
197 btfsc ignore_digit3 ; ignore 3rd-5th digit?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
198 bra output16_5 ; YES - skip the rest
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
199 btfsc DP_done2 ; is there a decimal point at all?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
200 bra output16_3 ; NO - use normal display mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
201 btfsc all_zeros_flag ; display any zero from here
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
202 bra output16_2_1 ; there was a figure /zero already
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
203 bsf pre_zero_flag ; display figure if zero?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
204 decfsz cvt_temp4,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
205 bcf pre_zero_flag ; NO
0
heinrichsweikamp
parents:
diff changeset
206
heinrichsweikamp
parents:
diff changeset
207 output16_2_1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
208 btfsc DP_done ; decimal point set already?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
209 bsf pre_zero_flag ; YES - so display the rest
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
210 btfsc DP_done2 ; is there a decimal point at all?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
211 bsf pre_zero_flag ; NO - so display the rest
0
heinrichsweikamp
parents:
diff changeset
212 output16_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
213 rcall DEC2ASCII ; 3th order digit...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
214 movlw b'00001010' ; 10s
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
215 movwf cvt_temp2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
216 clrf cvt_temp3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
217 btfsc DP_done2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
218 bra output16_4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
219 btfsc all_zeros_flag ; display any zero from here
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
220 bra output16_3_1 ; there was a figure /zero already
0
heinrichsweikamp
parents:
diff changeset
221 bsf pre_zero_flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
222 decfsz cvt_temp4,W
0
heinrichsweikamp
parents:
diff changeset
223 bcf pre_zero_flag
heinrichsweikamp
parents:
diff changeset
224
heinrichsweikamp
parents:
diff changeset
225 output16_3_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
226 btfsc DP_done
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
227 bsf pre_zero_flag
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
228 btfsc DP_done2
0
heinrichsweikamp
parents:
diff changeset
229 bsf pre_zero_flag
heinrichsweikamp
parents:
diff changeset
230 output16_4:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
231 btfsc ignore_digit4 ; ignore 4-5th digit?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
232 bra output16_5 ; YES - skip the rest
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
233 rcall DEC2ASCII ; 2nd order digit
0
heinrichsweikamp
parents:
diff changeset
234
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
235 movlw b'00000001' ; 1s
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
236 movwf cvt_temp2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
237 clrf cvt_temp3
0
heinrichsweikamp
parents:
diff changeset
238 bsf pre_zero_flag
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
239 btfss ignore_digit5 ; ignore 5th digit?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
240 rcall DEC2ASCII ; 1st order digit
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
241 bcf ignore_digit5 ; YES - clear flag
0
heinrichsweikamp
parents:
diff changeset
242 output16_5:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
243 bcf ignore_digit4 ; clear flag
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
244 bcf ignore_digit3 ; clear flag
0
heinrichsweikamp
parents:
diff changeset
245 clrf ignore_digits
heinrichsweikamp
parents:
diff changeset
246 incf ignore_digits,F
heinrichsweikamp
parents:
diff changeset
247 bcf DP_done
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
248 return ; done with convert.asm...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
249
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
250
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
251 DEC2ASCII:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
252 clrf cvt_temp1 ; converts into ASCII code
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
253 DEC2ASCII_2:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
254 movf cvt_temp3,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
255 subwf cvt_temp_hi,W
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
256 btfss STATUS,C
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
257 bra DEC2ASCII_4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
258 bnz DEC2ASCII_3
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
259 movf cvt_temp2,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
260 subwf cvt_temp_lo,W
0
heinrichsweikamp
parents:
diff changeset
261 btfss STATUS,C
heinrichsweikamp
parents:
diff changeset
262 bra DEC2ASCII_4
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
263 DEC2ASCII_3:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
264 movf cvt_temp3,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
265 subwf cvt_temp_hi,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
266 movf cvt_temp2,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
267 subwf cvt_temp_lo,F
0
heinrichsweikamp
parents:
diff changeset
268 btfss STATUS,C
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
269 decf cvt_temp_hi,F
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
270 incf cvt_temp1,F
0
heinrichsweikamp
parents:
diff changeset
271 bsf pre_zero_flag
heinrichsweikamp
parents:
diff changeset
272 bra DEC2ASCII_2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
273 DEC2ASCII_4:
0
heinrichsweikamp
parents:
diff changeset
274 decfsz ignore_digits,F
heinrichsweikamp
parents:
diff changeset
275 return
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
276 incf ignore_digits,F ; so ignore_digits stays zero for the test above
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
277 movlw '0' ; offset for ASCII-value
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
278 addwf cvt_temp1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
279 btfsc pre_zero_flag ; is this a leading zero?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
280 bra DEC2ASCII_4_1 ; NO
0
heinrichsweikamp
parents:
diff changeset
281 btfsc leftbind
heinrichsweikamp
parents:
diff changeset
282 bra DEC2ASCII_6
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
283 movlw ' ' ; instead of leading zeros a space!
0
heinrichsweikamp
parents:
diff changeset
284 bra DEC2ASCII_5
heinrichsweikamp
parents:
diff changeset
285 DEC2ASCII_4_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
286 bsf all_zeros_flag ; display any zero from here
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
287 DEC2ASCII_5:
0
heinrichsweikamp
parents:
diff changeset
288 movwf POSTINC2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
289 DEC2ASCII_6:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
290 decfsz cvt_temp4,F ; set decimal point?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
291 RETURN ; NO
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
292 movlw "." ; YES
0
heinrichsweikamp
parents:
diff changeset
293 movwf POSTINC2
heinrichsweikamp
parents:
diff changeset
294 bsf DP_done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
295 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
296
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
297
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
298 global outputHEX_call
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
299 outputHEX_call: ; coverts 8 Bit integer into two hex digits
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
300 movwf cvt_temp1 ; copy byte to process from WREG to local temp
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
301 swapf cvt_temp1,F ; swap nibbles to process upper nibble first
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
302 rcall outputHEX_nibble ; print nibble as ASCII
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
303 swapf cvt_temp1,F ; swap back to process lower nibble
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
304 outputHEX_nibble:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
305 movff cvt_temp1,cvt_temp2 ; create a working copy
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
306 movlw 0x0F ; mask for lower nibble
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
307 andwf cvt_temp2,F ; isolate lower nibble
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
308 movlw 0x30 ; offset from binary 0 to ASCII code for "0"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
309 addwf cvt_temp2,F ; add offset
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
310 movlw 0x39 ; ASCII code for "9"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
311 cpfsgt cvt_temp2 ; character code in cvt_temp2 pointing to something after "9"?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
312 bra outputHEX_1 ; NO - character code represents "0"..."9", can be printed
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
313 movlw 0x07 ; YES - offset from ASCII code for character after "9" to character "A"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
314 addwf cvt_temp2,F ; - add offset, character code now represents "A"..."F", can be printed now
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
315 outputHEX_1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
316 movff cvt_temp2,POSTINC2 ; copy character code to output buffer
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
317 return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
318
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
319
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
320 END