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