annotate code_part1/OSTC_code_asm_part1/valconv.asm @ 2:d11ef8dc4b2c

Bugfix: PC simulator
author heinrichsweikamp
date Wed, 20 Jan 2010 15:17:37 +0100
parents 96a35aeda5f2
children e8756eba54ee
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
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
21 ; last updated: 5/11/07
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
22 ; known bugs:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
23 ; ToDo: clean up!!!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
24
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
25
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
26 output_16_3 macro ; displays only last three figures from a 16Bit value (0-999)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
27 clrf ignore_digits
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
28 incf ignore_digits,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
29 clrf temp4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
30 bsf show_last3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
31 movf temp4,W ; Temp4 stores position for decimal point
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
32 call output16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
33 endm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
34
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
35 output_16dp macro temp4 ; 16Bit with decimal point
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
36 movlw temp4 ; Temp4 stores position for decimal point
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
37 call output16
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_16 macro ; 16Bit Normal
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
41 clrf ignore_digits
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
42 incf ignore_digits,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
43 clrf temp4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
44 movf temp4,W ; Temp4 stores position for decimal point
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
45 call output16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
46 endm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
47
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
48 output_8 macro ; 8 Bit Normal
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
49 clrf ignore_digits
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
50 incf ignore_digits,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
51 clrf temp4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
52 call output8
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
53 endm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
54
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
55 output_99 macro ; displays only last two figures from a 8Bit value (0-99)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
56 clrf ignore_digits
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
57 incf ignore_digits,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
58 clrf temp4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
59 call output99
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
60 endm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
61
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
62 output_99x macro ; displays only last two figures from a 8Bit value with leading zero (00-99)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
63 clrf ignore_digits
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
64 incf ignore_digits,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
65 clrf temp4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
66 call output99x
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
67 endm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
68
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
69 output99:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
70 movlw d'99'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
71 cpfslt lo
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
72 movwf lo ; Limit to 99
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
73 movff lo, lo_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
74 clrf hi_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
75 bcf pre_zero_flag ; do not display leading zeros
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
76
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
77 LCD_val99_2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
78 movlw b'00001010' ; 10
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
79 movwf temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
80 clrf temp3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
81 rcall DEC2ASCII
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
82
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
83 movlw b'00000001' ; 1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
84 movwf temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
85 clrf temp3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
86 bsf pre_zero_flag ; last figure, display zero (0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
87 rcall DEC2ASCII
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
88 RETURN
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
89
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
90 output99x:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
91 movff lo, lo_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
92 clrf hi_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
93 bsf pre_zero_flag ; display leading zeros
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
94 bra LCD_val99_2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
95
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
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
107 output16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
108 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
109
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
110 movwf temp4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
111
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
112 bsf leading_zeros
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
113 incf temp4,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
114 decfsz temp4,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
115 bcf leading_zeros
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
116
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
117 bsf DP_done2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
118 incf temp4,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
119 decfsz temp4,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
120 bcf DP_done2 ; decimal point not yet set
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
121
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
122 movff lo, lo_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
123 movff hi, hi_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
124 bcf pre_zero_flag ; do not display leading zeros
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
125
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
126 movlw b'00010000' ; 10000s
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
127 movwf temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
128 movlw b'00100111'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
129 movwf temp3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
130 btfss show_last3 ; display only last three figures?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
131 rcall DEC2ASCII
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
132
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
133 movlw b'11101000' ; 1000s
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
134 movwf temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
135 movlw b'00000011'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
136 movwf temp3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
137 btfsc DP_done2 ; Is there a decimal point at all?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
138 bra output16_2 ; no, use normal display mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
139
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
140 btfsc all_zeros_flag ; display any zero from here
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
141 bra output16_1 ; there was a figure /zero already
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
142
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
143 bsf pre_zero_flag ; display figure if zero?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
144 decfsz temp4,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
145 bcf pre_zero_flag ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
146
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
147 output16_1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
148 btfsc DP_done ; Decimal point set already?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
149 bsf pre_zero_flag ; Yes, so display the rest
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
150 output16_2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
151 btfss show_last3 ; display only last three figures?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
152 rcall DEC2ASCII
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
153 bcf show_last3 ; No, so display the rest
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
154
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
155 movlw b'01100100' ; 100s
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
156 movwf temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
157 clrf temp3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
158
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
159 btfsc ignore_digit3 ; Ignore 3rd-5th digit?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
160 bra output16_5 ; Yes, skip the rest
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
161
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
162 btfsc DP_done2 ; Is there a decimal point at all?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
163 bra output16_3 ; no, use normal display mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
164
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
165 btfsc all_zeros_flag ; display any zero from here
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
166 bra output16_2_1 ; there was a figure /zero already
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
167
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
168 bsf pre_zero_flag ; display figure if zero?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
169 decfsz temp4,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
170 bcf pre_zero_flag ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
171
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
172 output16_2_1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
173 btfsc DP_done ; Decimal point set already?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
174 bsf pre_zero_flag ; Yes, so display the rest
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
175 btfsc DP_done2 ; Is there a decimal point at all?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
176 bsf pre_zero_flag ; No, so display the rest
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
177 output16_3:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
178 rcall DEC2ASCII
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
179
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
180 movlw b'00001010' ; 10s
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
181 movwf temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
182 clrf temp3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
183 btfsc DP_done2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
184 bra output16_4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
185
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
186 btfsc all_zeros_flag ; display any zero from here
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
187 bra output16_3_1 ; there was a figure /zero already
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
188
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
189 bsf pre_zero_flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
190 decfsz temp4,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
191 bcf pre_zero_flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
192
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
193 output16_3_1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
194 btfsc DP_done
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
195 bsf pre_zero_flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
196 btfsc DP_done2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
197 bsf pre_zero_flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
198 output16_4:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
199 btfsc ignore_digit4 ; Ignore 4-5th digit?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
200 bra output16_5 ; Yes, skip the rest
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
201 rcall DEC2ASCII
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
202
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
203 movlw b'00000001' ; 1s
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
204 movwf temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
205 clrf temp3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
206 bsf pre_zero_flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
207 btfss ignore_digit5 ; Ignore 5th digit?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
208 rcall DEC2ASCII ; No!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
209 bcf ignore_digit5 ; yes, and clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
210 output16_5:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
211 bcf ignore_digit3 ; Clear flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
212 clrf ignore_digits
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
213 incf ignore_digits,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
214 bcf DP_done
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
215 RETURN
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
216
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
217 DEC2ASCII clrf temp1 ; converts into ASCII code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
218 DEC2ASCII_2 movf temp3,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
219 subwf hi_temp,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
220 btfss STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
221 bra DEC2ASCII_4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
222 bnz DEC2ASCII_3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
223
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
224 movf temp2,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
225 subwf lo_temp,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
226 btfss STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
227 bra DEC2ASCII_4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
228
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
229 DEC2ASCII_3 movf temp3,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
230 subwf hi_temp,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
231 movf temp2,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
232 subwf lo_temp,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
233 btfss STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
234 decf hi_temp,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
235 incf temp1,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
236 bsf pre_zero_flag
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
237 bra DEC2ASCII_2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
238
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
239 DEC2ASCII_4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
240 decfsz ignore_digits,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
241 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
242 incf ignore_digits,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
243 movlw '0' ; Offset for Ascii-value
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
244 addwf temp1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
245 btfsc pre_zero_flag ; is this a leading zero?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
246 bra DEC2ASCII_4_1 ; no
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
247 btfsc leftbind
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
248 bra DEC2ASCII_6
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
249 movlw ' ' ; instead of leading zeros a space!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
250 bra DEC2ASCII_5
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
251
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
252 DEC2ASCII_4_1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
253 bsf all_zeros_flag ; display any zero from here
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
254 DEC2ASCII_5
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
255 movwf POSTINC2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
256 DEC2ASCII_6
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
257 decfsz temp4,F ; Set decimal point?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
258 RETURN ; No
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
259 movlw "." ; Yes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
260 movwf POSTINC2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
261 bsf DP_done
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
262 RETURN