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