annotate code_part1/OSTC_code_asm_part1/valconv.asm @ 295:1a15d75702f7

Menu3 marker bugfix
author Heinrichsweikamp
date Thu, 28 Apr 2011 18:14:02 +0200
parents 966ebf905514
children 6256a891b2a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1 ; OSTC - diving computer code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2 ; Copyright (C) 2008 HeinrichsWeikamp GbR
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
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
96 output8
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
103
fe195f766014 Codesize optimized valconv.asm
JeanDo
parents: 64
diff changeset
111 clrf WREG
fe195f766014 Codesize optimized valconv.asm
JeanDo
parents: 64
diff changeset
112 bra output16
fe195f766014 Codesize optimized valconv.asm
JeanDo
parents: 64
diff changeset
113
fe195f766014 Codesize optimized valconv.asm
JeanDo
parents: 64
diff changeset
114 output16_call:
fe195f766014 Codesize optimized valconv.asm
JeanDo
parents: 64
diff changeset
115 clrf ignore_digits
fe195f766014 Codesize optimized valconv.asm
JeanDo
parents: 64
diff changeset
116 incf ignore_digits,F
fe195f766014 Codesize optimized valconv.asm
JeanDo
parents: 64
diff changeset
117 clrf WREG
fe195f766014 Codesize optimized valconv.asm
JeanDo
parents: 64
diff changeset
118
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
119 output16
103
fe195f766014 Codesize optimized valconv.asm
JeanDo
parents: 64
diff changeset
120 movwf temp4 ; Passed from output16dp macro, cleared by others.
fe195f766014 Codesize optimized valconv.asm
JeanDo
parents: 64
diff changeset
121
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
122 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
123
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
124 bsf leading_zeros
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
125 incf temp4,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
126 decfsz temp4,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
127 bcf leading_zeros
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
128
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
129 bsf DP_done2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
130 incf temp4,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
131 decfsz temp4,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
132 bcf DP_done2 ; decimal point not yet set
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
133
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
134 movff lo, lo_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
135 movff hi, hi_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
136 bcf pre_zero_flag ; do not display leading zeros
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
137
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
138 movlw b'00010000' ; 10000s
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
139 movwf temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
140 movlw b'00100111'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
141 movwf temp3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
142 btfss show_last3 ; display only last three figures?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
143 rcall DEC2ASCII
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
144
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
145 movlw b'11101000' ; 1000s
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
146 movwf temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
147 movlw b'00000011'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
148 movwf temp3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
149 btfsc DP_done2 ; Is there a decimal point at all?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
150 bra output16_2 ; no, use normal display mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
151
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
152 btfsc all_zeros_flag ; display any zero from here
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
153 bra output16_1 ; there was a figure /zero already
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
154
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
155 bsf pre_zero_flag ; display figure if zero?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
156 decfsz temp4,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
157 bcf pre_zero_flag ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
158
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
159 output16_1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
160 btfsc DP_done ; Decimal point set already?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
161 bsf pre_zero_flag ; Yes, so display the rest
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
162 output16_2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
163 btfss show_last3 ; display only last three figures?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
164 rcall DEC2ASCII
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
165 bcf show_last3 ; No, so display the rest
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
166
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
167 movlw b'01100100' ; 100s
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
168 movwf temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
169 clrf temp3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
170
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
171 btfsc ignore_digit3 ; Ignore 3rd-5th digit?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
172 bra output16_5 ; Yes, skip the rest
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
173
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
174 btfsc DP_done2 ; Is there a decimal point at all?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
175 bra output16_3 ; no, use normal display mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
176
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
177 btfsc all_zeros_flag ; display any zero from here
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
178 bra output16_2_1 ; there was a figure /zero already
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
179
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
180 bsf pre_zero_flag ; display figure if zero?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
181 decfsz temp4,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
182 bcf pre_zero_flag ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
183
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
184 output16_2_1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
185 btfsc DP_done ; Decimal point set already?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
186 bsf pre_zero_flag ; Yes, so display the rest
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
187 btfsc DP_done2 ; Is there a decimal point at all?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
188 bsf pre_zero_flag ; No, so display the rest
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
189 output16_3:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
190 rcall DEC2ASCII
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
191
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
192 movlw b'00001010' ; 10s
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
193 movwf temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
194 clrf temp3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
195 btfsc DP_done2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
196 bra output16_4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
197
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
198 btfsc all_zeros_flag ; display any zero from here
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
199 bra output16_3_1 ; there was a figure /zero already
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
200
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
201 bsf pre_zero_flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
202 decfsz temp4,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
203 bcf pre_zero_flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
204
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
205 output16_3_1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
206 btfsc DP_done
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
207 bsf pre_zero_flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
208 btfsc DP_done2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
209 bsf pre_zero_flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
210 output16_4:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
211 btfsc ignore_digit4 ; Ignore 4-5th digit?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
212 bra output16_5 ; Yes, skip the rest
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
213 rcall DEC2ASCII
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
214
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
215 movlw b'00000001' ; 1s
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
216 movwf temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
217 clrf temp3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
218 bsf pre_zero_flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
219 btfss ignore_digit5 ; Ignore 5th digit?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
220 rcall DEC2ASCII ; No!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
221 bcf ignore_digit5 ; yes, and clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
222 output16_5:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
223 bcf ignore_digit3 ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
224 clrf ignore_digits
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
225 incf ignore_digits,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
226 bcf DP_done
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
227 RETURN
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
228
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
229 DEC2ASCII clrf temp1 ; converts into ASCII code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
230 DEC2ASCII_2 movf temp3,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
231 subwf hi_temp,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
232 btfss STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
233 bra DEC2ASCII_4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
234 bnz DEC2ASCII_3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
235
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
236 movf temp2,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
237 subwf lo_temp,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
238 btfss STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
239 bra DEC2ASCII_4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
240
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
241 DEC2ASCII_3 movf temp3,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
242 subwf hi_temp,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
243 movf temp2,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
244 subwf lo_temp,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
245 btfss STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
246 decf hi_temp,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
247 incf temp1,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
248 bsf pre_zero_flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
249 bra DEC2ASCII_2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
250
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
251 DEC2ASCII_4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
252 decfsz ignore_digits,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
253 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
254 incf ignore_digits,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
255 movlw '0' ; Offset for Ascii-value
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
256 addwf temp1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
257 btfsc pre_zero_flag ; is this a leading zero?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
258 bra DEC2ASCII_4_1 ; no
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
259 btfsc leftbind
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
260 bra DEC2ASCII_6
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
261 movlw ' ' ; instead of leading zeros a space!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
262 bra DEC2ASCII_5
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
263
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
264 DEC2ASCII_4_1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
265 bsf all_zeros_flag ; display any zero from here
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
266 DEC2ASCII_5
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
267 movwf POSTINC2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
268 DEC2ASCII_6
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
269 decfsz temp4,F ; Set decimal point?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
270 RETURN ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
271 movlw "." ; Yes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
272 movwf POSTINC2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
273 bsf DP_done
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
274 RETURN