comparison src/convert.asm @ 623:c40025d8e750

3.03 beta released
author heinrichsweikamp
date Mon, 03 Jun 2019 14:01:48 +0200
parents ca4556fb60b9
children cd58f7fc86db
comparison
equal deleted inserted replaced
622:02d1386429a6 623:c40025d8e750
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File convert.asm ## V2.98c 3 ; File convert.asm combined next generation V3.0.1
4 ; 4 ;
5 ; Converts register values to string 5 ; Converts register values to string
6 ; 6 ;
7 ; Copyright (c) 2011, Matthias Heinrichs, HeinrichsWeikamp, all right reserved. 7 ; Copyright (c) 2011, Matthias Heinrichs, HeinrichsWeikamp, all right reserved.
8 ;============================================================================= 8 ;=============================================================================
11 ; 2010-12-10 : [jDG] Optimize macro size 11 ; 2010-12-10 : [jDG] Optimize macro size
12 ; 12 ;
13 13
14 #include "hwos.inc" ; Mandatory header 14 #include "hwos.inc" ; Mandatory header
15 15
16 convert CODE 16 convert CODE
17 17
18 ;============================================================================= 18 ;=============================================================================
19 19
20 global output99_call 20 global output99_call
21 output99_call: 21 output99_call:
22 clrf ignore_digits 22 clrf ignore_digits
23 incf ignore_digits,F 23 incf ignore_digits,F
24 clrf cvt_temp4 24 clrf cvt_temp4
25 ;bra output99
25 26
26 27
27 global output99 28 global output99
28 output99: 29 output99:
29 movlw d'99' 30 movlw d'99'
30 cpfslt lo 31 cpfslt lo
31 movwf lo ; limit to 99 32 movwf lo ; limit to 99
32 movff lo,lo_temp 33 movff lo,cvt_temp_lo
33 clrf hi_temp 34 clrf cvt_temp_hi
34 bcf pre_zero_flag ; do not display leading zeros 35 bcf pre_zero_flag ; do not display leading zeros
35 36
36 LCD_val99_2: 37 LCD_val99_2:
37 movlw .10 ; 10 38 movlw .10 ; 10
38 movwf cvt_temp2 39 movwf cvt_temp2
53 clrf cvt_temp4 54 clrf cvt_temp4
54 55
55 movlw d'99' 56 movlw d'99'
56 cpfslt lo 57 cpfslt lo
57 movwf lo ; limit to 99 58 movwf lo ; limit to 99
58 movff lo, lo_temp 59 movff lo,cvt_temp_lo
59 clrf hi_temp 60 clrf cvt_temp_hi
60 bsf pre_zero_flag ; display leading zeros 61 bsf pre_zero_flag ; display leading zeros
61 bra LCD_val99_2 62 bra LCD_val99_2
62 63
63 64
64 global output8_call 65 global output8_call
66 clrf ignore_digits 67 clrf ignore_digits
67 incf ignore_digits,F 68 incf ignore_digits,F
68 clrf cvt_temp4 69 clrf cvt_temp4
69 70
70 output8: 71 output8:
71 movff lo, lo_temp 72 movff lo,cvt_temp_lo
72 clrf hi_temp 73 clrf cvt_temp_hi
73 bcf pre_zero_flag ; do not display leading zeros 74 bcf pre_zero_flag ; do not display leading zeros
74 movlw .100 ; 100 75 movlw .100 ; 100
75 movwf cvt_temp2 76 movwf cvt_temp2
76 clrf cvt_temp3 77 clrf cvt_temp3
77 rcall DEC2ASCII 78 rcall DEC2ASCII
79 80
80 81
81 global output16_4_call 82 global output16_4_call
82 output16_4_call: ; limit to 9999 83 output16_4_call: ; limit to 9999
83 bsf show_last4 84 bsf show_last4
84 ; 9999 = 27 0F = [39][15] 85 ; 9999 = 27 0F = [39][15]
85 movlw .40 86 movlw .40
86 cpfslt hi ; hi < 40 ? 87 cpfslt hi ; hi < 40 ?
87 bra output16_4_call_2 ; NO - hi >= 40, do limit 88 bra output16_4_call_2 ; NO - hi >= 40, do limit
88 ; Yes, hi <= 39 89 ; YES - hi <= 39
89 movlw .39 90 movlw .39
90 cpfseq hi ; hi = 39 ? 91 cpfseq hi ; hi = 39 ?
91 bra output16_4_call_3 ; NO - hi < 39, no limit needed 92 bra output16_4_call_3 ; NO - hi < 39, no limit needed
92 ; Yes, hi = 39 93 ; YES - hi = 39
93 movlw .15 94 movlw .15
94 cpfslt lo ; lo < 15 95 cpfslt lo ; lo < 15
95 movwf lo ; NO - lo >= 15, set lo = 15. 96 movwf lo ; NO - lo >= 15, set lo = 15
96 ; Yes, lo <= 14 or lo set to =15 97 ; YES - lo <= 14 or lo set to =15
97 bra output16_4_call_3 ; done 98 bra output16_4_call_3 ; - done
99
98 output16_4_call_2: ; set to 9999 100 output16_4_call_2: ; set to 9999
99 movlw LOW .9999 101 MOVLI .9999,mpr
100 movwf lo
101 movlw HIGH .9999
102 movwf hi
103 output16_4_call_3: 102 output16_4_call_3:
104 bra output16_call 103 bra output16_call
104
105 105
106 global output16_3_call 106 global output16_3_call
107 global output16_call 107 global output16_call
108 global output16 108 global output16
109 output16_3_call: ; limit to 999 109 output16_3_call: ; limit to 999
110 bsf show_last3 110 bsf show_last3
111 ; Limit to 3 111 ; Limit to 3
112 movlw .4 112 movlw .4
113 cpfslt hi 113 cpfslt hi
114 bra output16_3_call_2 114 bra output16_3_call_2
115 movlw .3 115 movlw .3
116 cpfseq hi ; = 3 ? 116 cpfseq hi ; = 3 ?
117 bra output16_3_call_3 ; NO - done 117 bra output16_3_call_3 ; NO - done
118 movlw .231 ; limit to 231(+768=999...) 118 movlw .231 ; limit to 231(+768=999...)
119 cpfslt lo 119 cpfslt lo
120 movwf lo 120 movwf lo
121 bra output16_3_call_3 ; done 121 bra output16_3_call_3 ; done
122 output16_3_call_2: ; set to .999 122 output16_3_call_2: ; set to .999
123 movlw LOW .999 123 MOVLI .999,mpr
124 movwf lo
125 movlw HIGH .999
126 movwf hi
127 output16_3_call_3: 124 output16_3_call_3:
128 output16_call: 125 output16_call:
129 clrf ignore_digits 126 clrf ignore_digits
130 incf ignore_digits,F 127 incf ignore_digits,F
131 clrf WREG 128 clrf WREG
136 tstfsz cvt_temp4 ; display leading zeros at all? 133 tstfsz cvt_temp4 ; display leading zeros at all?
137 bcf leading_zeros 134 bcf leading_zeros
138 bsf DP_done2 135 bsf DP_done2
139 tstfsz cvt_temp4 136 tstfsz cvt_temp4
140 bcf DP_done2 ; decimal point not yet set 137 bcf DP_done2 ; decimal point not yet set
141 movff lo, lo_temp 138 movff lo,cvt_temp_lo ; copy hi:lo to cvt_temp_hi:cvt_temp_lo
142 movff hi, hi_temp 139 movff hi,cvt_temp_hi ; ...
143 bcf pre_zero_flag ; do not display leading zeros 140 bcf pre_zero_flag ; do not display leading zeros
144 movlw b'00010000' ; 10000s 141 movlw b'00010000' ; 10000s
145 movwf cvt_temp2 142 movwf cvt_temp2
146 movlw b'00100111' 143 movlw b'00100111'
147 movwf cvt_temp3 144 movwf cvt_temp3
233 230
234 DEC2ASCII: 231 DEC2ASCII:
235 clrf cvt_temp1 ; converts into ASCII code 232 clrf cvt_temp1 ; converts into ASCII code
236 DEC2ASCII_2: 233 DEC2ASCII_2:
237 movf cvt_temp3,W 234 movf cvt_temp3,W
238 subwf hi_temp,W 235 subwf cvt_temp_hi,W
239 btfss STATUS,C 236 btfss STATUS,C
240 bra DEC2ASCII_4 237 bra DEC2ASCII_4
241 bnz DEC2ASCII_3 238 bnz DEC2ASCII_3
242 movf cvt_temp2,W 239 movf cvt_temp2,W
243 subwf lo_temp,W 240 subwf cvt_temp_lo,W
244 btfss STATUS,C 241 btfss STATUS,C
245 bra DEC2ASCII_4 242 bra DEC2ASCII_4
246 DEC2ASCII_3: 243 DEC2ASCII_3:
247 movf cvt_temp3,W 244 movf cvt_temp3,W
248 subwf hi_temp,F 245 subwf cvt_temp_hi,F
249 movf cvt_temp2,W 246 movf cvt_temp2,W
250 subwf lo_temp,F 247 subwf cvt_temp_lo,F
251 btfss STATUS,C 248 btfss STATUS,C
252 decf hi_temp,F 249 decf cvt_temp_hi,F
253 incf cvt_temp1,F 250 incf cvt_temp1,F
254 bsf pre_zero_flag 251 bsf pre_zero_flag
255 bra DEC2ASCII_2 252 bra DEC2ASCII_2
256 DEC2ASCII_4: 253 DEC2ASCII_4:
257 decfsz ignore_digits,F 254 decfsz ignore_digits,F