annotate code_part1/OSTC_code_asm_part1/valconv.asm @ 841:8d73c9dcf851 default tip

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