Mercurial > public > hwos_code
annotate src/convert.asm @ 448:aadfe9f2edaf
work on new battery options
author | heinrichsweikamp |
---|---|
date | Tue, 30 Aug 2016 17:26:21 +0200 |
parents | a5fc007634c5 |
children | b455b31ce022 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File convert.asm | |
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 | |
275 | 14 #include "hwos.inc" ; Mandatory header |
0 | 15 |
16 ;============================================================================= | |
17 | |
418 | 18 CBLOCK tmp+0x09 ; space for aa_wordprocessor |
0 | 19 temp3 |
20 temp4 | |
21 cvt_flags2 | |
418 | 22 ; Reserved to tmp+0x11... |
0 | 23 ENDC |
24 | |
25 #define pre_zero_flag cvt_flags2,0 | |
26 #define all_zeros_flag cvt_flags2,1 | |
27 #define DP_done cvt_flags2,2 | |
28 #define DP_done2 cvt_flags2,3 | |
29 #define show_last3 cvt_flags2,4 | |
30 #define leading_zeros cvt_flags2,5 | |
300
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
31 #define show_last4 cvt_flags2,6 |
0 | 32 |
33 basic CODE | |
34 | |
35 ;============================================================================= | |
36 global output99_call | |
37 output99_call: | |
38 clrf ignore_digits | |
39 incf ignore_digits,F | |
40 clrf temp4 | |
41 | |
42 global output99 | |
43 output99: | |
44 movlw d'99' | |
45 cpfslt lo | |
46 movwf lo ; Limit to 99 | |
47 movff lo,lo_temp | |
48 clrf hi_temp | |
49 bcf pre_zero_flag ; do not display leading zeros | |
50 | |
51 LCD_val99_2: | |
52 movlw b'00001010' ; 10 | |
53 movwf temp2 | |
54 clrf temp3 | |
55 rcall DEC2ASCII | |
56 | |
57 movlw b'00000001' ; 1 | |
58 movwf temp2 | |
59 clrf temp3 | |
60 bsf pre_zero_flag ; last figure, display zero (0) | |
61 rcall DEC2ASCII | |
62 RETURN | |
63 | |
64 global output99x_call | |
65 | |
66 output99x_call: | |
67 clrf ignore_digits | |
68 incf ignore_digits,F | |
69 clrf temp4 | |
70 | |
71 movlw d'99' | |
72 cpfslt lo | |
73 movwf lo ; Limit to 99 | |
74 movff lo, lo_temp | |
75 clrf hi_temp | |
76 bsf pre_zero_flag ; display leading zeros | |
77 bra LCD_val99_2 | |
78 | |
79 global output8_call | |
80 | |
81 output8_call: | |
82 clrf ignore_digits | |
83 incf ignore_digits,F | |
84 clrf temp4 | |
85 | |
86 output8: | |
87 movff lo, lo_temp | |
88 clrf hi_temp | |
89 bcf pre_zero_flag ; do not display leading zeros | |
90 | |
91 movlw b'01100100' ; 100 | |
92 movwf temp2 | |
93 clrf temp3 | |
94 rcall DEC2ASCII | |
95 bra LCD_val99_2 | |
96 | |
300
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
97 global output16_4_call |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
98 output16_4_call: ; limit to 9999 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
99 bsf show_last4 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
100 ; 9999 = 27 0F = [39][15] |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
101 movlw .40 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
102 cpfslt hi ; hi < 40 ? |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
103 bra output16_4_call_2 ; No, hi >= 40, do limit |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
104 ; Yes, hi <= 39 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
105 movlw .39 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
106 cpfseq hi ; hi = 39 ? |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
107 bra output16_4_call_3 ; No, hi < 39, no limit needed |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
108 ; Yes, hi = 39 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
109 movlw .15 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
110 cpfslt lo ; lo < 15 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
111 movwf lo ; No, lo >= 15, set lo = 15. |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
112 ; Yes, lo <= 14 or lo set to =15 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
113 bra output16_4_call_3 ; done. |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
114 output16_4_call_2: ; Set to 9999 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
115 movlw LOW .9999 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
116 movwf lo |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
117 movlw HIGH .9999 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
118 movwf hi |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
119 output16_4_call_3: |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
120 bra output16_call |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
121 |
0 | 122 global output16_3_call |
123 global output16_call | |
124 global output16 | |
225
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
125 output16_3_call: ; limit to 999 |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
126 bsf show_last3 |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
127 ; Limit to 3 |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
128 movlw .4 |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
129 cpfslt hi |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
130 bra output16_3_call_2 |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
131 movlw .3 |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
132 cpfseq hi ; =3? |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
133 bra output16_3_call_3 ; No, done. |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
134 movlw .231 ; Limit to 231(+768=999...) |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
135 cpfslt lo |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
136 movwf lo |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
137 bra output16_3_call_3 ; done. |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
138 output16_3_call_2: ; Set to .999 |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
139 movlw LOW .999 |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
140 movwf lo |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
141 movlw HIGH .999 |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
142 movwf hi |
31088352ee32
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
0
diff
changeset
|
143 output16_3_call_3: |
0 | 144 output16_call: |
145 clrf ignore_digits | |
146 incf ignore_digits,F | |
147 clrf WREG | |
148 output16: | |
149 movwf temp4 ; Passed from output16dp macro, cleared by others. | |
150 | |
151 bcf all_zeros_flag ; do not display any zero from here unless there was at least one figure /zero | |
152 | |
153 bsf leading_zeros | |
154 tstfsz temp4 ; Display leading zeros at all? | |
155 bcf leading_zeros | |
156 | |
157 bsf DP_done2 | |
158 tstfsz temp4 | |
159 bcf DP_done2 ; decimal point not yet set | |
160 | |
161 movff lo, lo_temp | |
162 movff hi, hi_temp | |
163 bcf pre_zero_flag ; do not display leading zeros | |
164 | |
165 movlw b'00010000' ; 10000s | |
166 movwf temp2 | |
167 movlw b'00100111' | |
168 movwf temp3 | |
300
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
169 btfsc show_last3 ; display only last three figures? |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
170 bra output16_sk5 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
171 btfsc show_last4 ; display only last four figures? |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
172 bra output16_sk5 |
0 | 173 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
|
174 |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
175 output16_sk5: |
5ad479f2a868
Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents:
275
diff
changeset
|
176 bcf show_last4 |
0 | 177 movlw b'11101000' ; 1000s |
178 movwf temp2 | |
179 movlw b'00000011' | |
180 movwf temp3 | |
181 btfsc DP_done2 ; Is there a decimal point at all? | |
182 bra output16_2 ; no, use normal display mode | |
183 | |
184 btfsc all_zeros_flag ; display any zero from here | |
185 bra output16_1 ; there was a figure /zero already | |
186 | |
187 bsf pre_zero_flag ; display figure if zero? | |
188 decfsz temp4,W | |
189 bcf pre_zero_flag ; No | |
190 | |
191 output16_1: | |
192 btfsc DP_done ; Decimal point set already? | |
193 bsf pre_zero_flag ; Yes, so display the rest | |
194 output16_2: | |
195 btfss show_last3 ; display only last three figures? | |
196 rcall DEC2ASCII ; No, show all. Here: 4th order digit | |
197 bcf show_last3 ; Yes, so display the rest | |
198 | |
199 movlw b'01100100' ; 100s | |
200 movwf temp2 | |
201 clrf temp3 | |
202 | |
203 btfsc ignore_digit3 ; Ignore 3rd-5th digit? | |
204 bra output16_5 ; Yes, skip the rest | |
205 | |
206 btfsc DP_done2 ; Is there a decimal point at all? | |
207 bra output16_3 ; no, use normal display mode | |
208 | |
209 btfsc all_zeros_flag ; display any zero from here | |
210 bra output16_2_1 ; there was a figure /zero already | |
211 | |
212 bsf pre_zero_flag ; display figure if zero? | |
213 decfsz temp4,W | |
214 bcf pre_zero_flag ; No | |
215 | |
216 output16_2_1: | |
217 btfsc DP_done ; Decimal point set already? | |
218 bsf pre_zero_flag ; Yes, so display the rest | |
219 btfsc DP_done2 ; Is there a decimal point at all? | |
220 bsf pre_zero_flag ; No, so display the rest | |
221 output16_3: | |
222 rcall DEC2ASCII ;3th order digit... | |
223 | |
224 movlw b'00001010' ; 10s | |
225 movwf temp2 | |
226 clrf temp3 | |
227 btfsc DP_done2 | |
228 bra output16_4 | |
229 | |
230 btfsc all_zeros_flag ; display any zero from here | |
231 bra output16_3_1 ; there was a figure /zero already | |
232 | |
233 bsf pre_zero_flag | |
234 decfsz temp4,W | |
235 bcf pre_zero_flag | |
236 | |
237 output16_3_1: | |
238 btfsc DP_done | |
239 bsf pre_zero_flag | |
240 btfsc DP_done2 | |
241 bsf pre_zero_flag | |
242 output16_4: | |
243 btfsc ignore_digit4 ; Ignore 4-5th digit? | |
244 bra output16_5 ; Yes, skip the rest | |
245 rcall DEC2ASCII ; 2nd order digit | |
246 | |
247 movlw b'00000001' ; 1s | |
248 movwf temp2 | |
249 clrf temp3 | |
250 bsf pre_zero_flag | |
251 btfss ignore_digit5 ; Ignore 5th digit? | |
252 rcall DEC2ASCII ; 1st order digit | |
253 bcf ignore_digit5 ; yes, and clear flag | |
254 output16_5: | |
255 bcf ignore_digit4 ; Clear flag | |
256 bcf ignore_digit3 ; Clear flag | |
257 clrf ignore_digits | |
258 incf ignore_digits,F | |
259 bcf DP_done | |
260 RETURN ; Done with convert.asm... | |
261 | |
262 DEC2ASCII clrf temp1 ; converts into ASCII code | |
263 DEC2ASCII_2 movf temp3,W | |
264 subwf hi_temp,W | |
265 btfss STATUS,C | |
266 bra DEC2ASCII_4 | |
267 bnz DEC2ASCII_3 | |
268 | |
269 movf temp2,W | |
270 subwf lo_temp,W | |
271 btfss STATUS,C | |
272 bra DEC2ASCII_4 | |
273 | |
274 DEC2ASCII_3 movf temp3,W | |
275 subwf hi_temp,F | |
276 movf temp2,W | |
277 subwf lo_temp,F | |
278 btfss STATUS,C | |
279 decf hi_temp,F | |
280 incf temp1,F | |
281 bsf pre_zero_flag | |
282 bra DEC2ASCII_2 | |
283 | |
284 DEC2ASCII_4 | |
285 decfsz ignore_digits,F | |
286 return | |
287 incf ignore_digits,F ; so ignore_digits stays zero for the test above | |
288 movlw '0' ; Offset for Ascii-value | |
289 addwf temp1,W | |
290 btfsc pre_zero_flag ; is this a leading zero? | |
291 bra DEC2ASCII_4_1 ; no | |
292 btfsc leftbind | |
293 bra DEC2ASCII_6 | |
294 movlw ' ' ; instead of leading zeros a space! | |
295 bra DEC2ASCII_5 | |
296 DEC2ASCII_4_1: | |
297 bsf all_zeros_flag ; display any zero from here | |
298 DEC2ASCII_5 | |
299 movwf POSTINC2 | |
300 DEC2ASCII_6 | |
301 decfsz temp4,F ; Set decimal point? | |
302 RETURN ; No | |
303 movlw "." ; Yes | |
304 movwf POSTINC2 | |
305 bsf DP_done | |
306 RETURN | |
307 | |
308 END |