Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/valconv.asm @ 815:2a0e5d884fc3
BUGFIX: Fix licence in German
BUGFIX: Fix minor layout bug in surface mode
author | heinrichsweikamp |
---|---|
date | Tue, 12 May 2015 11:30:35 +0200 |
parents | c50296c3059e |
children |
rev | line source |
---|---|
815 | 1 ; OSTC Mk.2, 2N and 2C - diving computer code |
807
c50296c3059e
BUGFIX: Divetime had unwanted "." behind the minutes
heinrichsweikamp
parents:
805
diff
changeset
|
2 ; Copyright (C) 2015 HeinrichsWeikamp GbR |
0 | 3 |
4 ; This program is free software: you can redistribute it and/or modify | |
5 ; it under the terms of the GNU General Public License as published by | |
6 ; the Free Software Foundation, either version 3 of the License, or | |
7 ; (at your option) any later version. | |
8 | |
9 ; This program is distributed in the hope that it will be useful, | |
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ; GNU General Public License for more details. | |
13 | |
14 ; You should have received a copy of the GNU General Public License | |
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | |
17 | |
18 ; converts hex values to dez values | |
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
20 ; written: 13/10/07 | |
103 | 21 ; 10/12/2010 jDG: optimize macro size. |
22 ; last updated: 10/12/2010 | |
0 | 23 ; known bugs: |
24 ; ToDo: clean up!!! | |
25 | |
26 | |
27 output_16_3 macro ; displays only last three figures from a 16Bit value (0-999) | |
103 | 28 call output16_3_call |
0 | 29 endm |
30 | |
31 output_16dp macro temp4 ; 16Bit with decimal point | |
32 movlw temp4 ; Temp4 stores position for decimal point | |
33 call output16 | |
34 endm | |
35 | |
36 output_16 macro ; 16Bit Normal | |
103 | 37 call output16_call |
0 | 38 endm |
39 | |
40 output_8 macro ; 8 Bit Normal | |
103 | 41 call output8_call |
42 endm | |
43 | |
44 output_99 macro ; displays only last two figures from a 8Bit value (0-99) | |
45 call output99_call | |
46 endm | |
47 | |
48 output_99x macro ; displays only last two figures from a 8Bit value with leading zero (00-99) | |
49 call output99x_call | |
50 endm | |
51 | |
52 output99_call: | |
0 | 53 clrf ignore_digits |
54 incf ignore_digits,F | |
55 clrf temp4 | |
56 | |
57 output99: | |
58 movlw d'99' | |
59 cpfslt lo | |
60 movwf lo ; Limit to 99 | |
64 | 61 movff lo,lo_temp |
0 | 62 clrf hi_temp |
63 bcf pre_zero_flag ; do not display leading zeros | |
64 | |
65 LCD_val99_2: | |
66 movlw b'00001010' ; 10 | |
67 movwf temp2 | |
68 clrf temp3 | |
69 rcall DEC2ASCII | |
70 | |
71 movlw b'00000001' ; 1 | |
72 movwf temp2 | |
73 clrf temp3 | |
74 bsf pre_zero_flag ; last figure, display zero (0) | |
75 rcall DEC2ASCII | |
76 RETURN | |
77 | |
103 | 78 output99x_call: |
79 clrf ignore_digits | |
80 incf ignore_digits,F | |
81 clrf temp4 | |
82 | |
64 | 83 movlw d'99' |
84 cpfslt lo | |
85 movwf lo ; Limit to 99 | |
0 | 86 movff lo, lo_temp |
87 clrf hi_temp | |
88 bsf pre_zero_flag ; display leading zeros | |
89 bra LCD_val99_2 | |
90 | |
103 | 91 output8_call: |
92 clrf ignore_digits | |
93 incf ignore_digits,F | |
94 clrf temp4 | |
95 | |
807
c50296c3059e
BUGFIX: Divetime had unwanted "." behind the minutes
heinrichsweikamp
parents:
805
diff
changeset
|
96 output8: |
0 | 97 movff lo, lo_temp |
98 clrf hi_temp | |
99 bcf pre_zero_flag ; do not display leading zeros | |
100 | |
101 movlw b'01100100' ; 100 | |
102 movwf temp2 | |
103 clrf temp3 | |
104 rcall DEC2ASCII | |
105 bra LCD_val99_2 | |
106 | |
103 | 107 output16_3_call: |
108 clrf ignore_digits | |
109 incf ignore_digits,F | |
106 | 110 bsf show_last3 |
805
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
111 ; Limit to 3 |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
112 movlw .4 |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
113 cpfslt hi |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
114 bra output16_3_call_2 |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
115 movlw .3 |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
116 cpfseq hi ; =3? |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
117 bra output16_3_call_3 ; No, done. |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
118 movlw .231 ; Limit to 231(+768=999...) |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
119 cpfslt lo |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
120 movwf lo |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
121 bra output16_3_call_3 ; done. |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
122 output16_3_call_2: ; Set to .999 |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
123 movlw LOW .999 |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
124 movwf lo |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
125 movlw HIGH .999 |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
126 movwf hi |
6256a891b2a0
BUGFIX: Show dives with >999mins divetime correctly
heinrichsweikamp
parents:
106
diff
changeset
|
127 output16_3_call_3: |
807
c50296c3059e
BUGFIX: Divetime had unwanted "." behind the minutes
heinrichsweikamp
parents:
805
diff
changeset
|
128 clrf WREG |
103 | 129 bra output16 |
130 | |
131 output16_call: | |
132 clrf ignore_digits | |
133 incf ignore_digits,F | |
134 clrf WREG | |
135 | |
807
c50296c3059e
BUGFIX: Divetime had unwanted "." behind the minutes
heinrichsweikamp
parents:
805
diff
changeset
|
136 output16: |
103 | 137 movwf temp4 ; Passed from output16dp macro, cleared by others. |
138 | |
0 | 139 bcf all_zeros_flag ; do not display any zero from here unless there was at least one figure /zero |
140 | |
141 bsf leading_zeros | |
142 incf temp4,1 | |
143 decfsz temp4,F | |
144 bcf leading_zeros | |
145 | |
146 bsf DP_done2 | |
147 incf temp4,1 | |
148 decfsz temp4,F | |
149 bcf DP_done2 ; decimal point not yet set | |
150 | |
151 movff lo, lo_temp | |
152 movff hi, hi_temp | |
153 bcf pre_zero_flag ; do not display leading zeros | |
154 | |
155 movlw b'00010000' ; 10000s | |
156 movwf temp2 | |
157 movlw b'00100111' | |
158 movwf temp3 | |
159 btfss show_last3 ; display only last three figures? | |
160 rcall DEC2ASCII | |
161 | |
162 movlw b'11101000' ; 1000s | |
163 movwf temp2 | |
164 movlw b'00000011' | |
165 movwf temp3 | |
166 btfsc DP_done2 ; Is there a decimal point at all? | |
167 bra output16_2 ; no, use normal display mode | |
168 | |
169 btfsc all_zeros_flag ; display any zero from here | |
170 bra output16_1 ; there was a figure /zero already | |
171 | |
172 bsf pre_zero_flag ; display figure if zero? | |
173 decfsz temp4,W | |
174 bcf pre_zero_flag ; No | |
175 | |
176 output16_1: | |
177 btfsc DP_done ; Decimal point set already? | |
178 bsf pre_zero_flag ; Yes, so display the rest | |
179 output16_2: | |
180 btfss show_last3 ; display only last three figures? | |
181 rcall DEC2ASCII | |
182 bcf show_last3 ; No, so display the rest | |
183 | |
184 movlw b'01100100' ; 100s | |
185 movwf temp2 | |
186 clrf temp3 | |
187 | |
188 btfsc ignore_digit3 ; Ignore 3rd-5th digit? | |
189 bra output16_5 ; Yes, skip the rest | |
190 | |
191 btfsc DP_done2 ; Is there a decimal point at all? | |
192 bra output16_3 ; no, use normal display mode | |
193 | |
194 btfsc all_zeros_flag ; display any zero from here | |
195 bra output16_2_1 ; there was a figure /zero already | |
196 | |
197 bsf pre_zero_flag ; display figure if zero? | |
198 decfsz temp4,W | |
199 bcf pre_zero_flag ; No | |
200 | |
201 output16_2_1: | |
202 btfsc DP_done ; Decimal point set already? | |
203 bsf pre_zero_flag ; Yes, so display the rest | |
204 btfsc DP_done2 ; Is there a decimal point at all? | |
205 bsf pre_zero_flag ; No, so display the rest | |
206 output16_3: | |
207 rcall DEC2ASCII | |
208 | |
209 movlw b'00001010' ; 10s | |
210 movwf temp2 | |
211 clrf temp3 | |
212 btfsc DP_done2 | |
213 bra output16_4 | |
214 | |
215 btfsc all_zeros_flag ; display any zero from here | |
216 bra output16_3_1 ; there was a figure /zero already | |
217 | |
218 bsf pre_zero_flag | |
219 decfsz temp4,W | |
220 bcf pre_zero_flag | |
221 | |
222 output16_3_1: | |
223 btfsc DP_done | |
224 bsf pre_zero_flag | |
225 btfsc DP_done2 | |
226 bsf pre_zero_flag | |
227 output16_4: | |
228 btfsc ignore_digit4 ; Ignore 4-5th digit? | |
229 bra output16_5 ; Yes, skip the rest | |
230 rcall DEC2ASCII | |
231 | |
232 movlw b'00000001' ; 1s | |
233 movwf temp2 | |
234 clrf temp3 | |
235 bsf pre_zero_flag | |
236 btfss ignore_digit5 ; Ignore 5th digit? | |
237 rcall DEC2ASCII ; No! | |
238 bcf ignore_digit5 ; yes, and clear flag | |
239 output16_5: | |
240 bcf ignore_digit3 ; Clear flag | |
241 clrf ignore_digits | |
242 incf ignore_digits,F | |
243 bcf DP_done | |
244 RETURN | |
245 | |
246 DEC2ASCII clrf temp1 ; converts into ASCII code | |
247 DEC2ASCII_2 movf temp3,W | |
248 subwf hi_temp,0 | |
249 btfss STATUS,C | |
250 bra DEC2ASCII_4 | |
251 bnz DEC2ASCII_3 | |
252 | |
253 movf temp2,W | |
254 subwf lo_temp,0 | |
255 btfss STATUS,C | |
256 bra DEC2ASCII_4 | |
257 | |
258 DEC2ASCII_3 movf temp3,W | |
259 subwf hi_temp,1 | |
260 movf temp2,W | |
261 subwf lo_temp,1 | |
262 btfss STATUS,C | |
263 decf hi_temp,1 | |
264 incf temp1,1 | |
265 bsf pre_zero_flag | |
266 bra DEC2ASCII_2 | |
267 | |
268 DEC2ASCII_4 | |
269 decfsz ignore_digits,F | |
270 return | |
271 incf ignore_digits,F | |
272 movlw '0' ; Offset for Ascii-value | |
273 addwf temp1,0 | |
274 btfsc pre_zero_flag ; is this a leading zero? | |
275 bra DEC2ASCII_4_1 ; no | |
276 btfsc leftbind | |
277 bra DEC2ASCII_6 | |
278 movlw ' ' ; instead of leading zeros a space! | |
279 bra DEC2ASCII_5 | |
280 | |
281 DEC2ASCII_4_1: | |
282 bsf all_zeros_flag ; display any zero from here | |
283 DEC2ASCII_5 | |
284 movwf POSTINC2 | |
285 DEC2ASCII_6 | |
286 decfsz temp4,F ; Set decimal point? | |
287 RETURN ; No | |
288 movlw "." ; Yes | |
289 movwf POSTINC2 | |
290 bsf DP_done | |
291 RETURN |