annotate src/convert.asm @ 639:0ff82370991d

minor
author heinrichsweikamp
date Mon, 10 Aug 2020 15:34:38 +0200
parents 4050675965ea
children 75e90cd0c2c3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
3 ; File convert.asm combined next generation V3.09.4l
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Converts register values to string
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, Matthias Heinrichs, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2007-10-07 : [MH] Creation for OSTC sources
heinrichsweikamp
parents:
diff changeset
11 ; 2010-12-10 : [jDG] Optimize macro size
heinrichsweikamp
parents:
diff changeset
12 ;
heinrichsweikamp
parents:
diff changeset
13
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
14 #include "hwos.inc"
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
15 #include "math.inc"
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
16 #include "strings.inc"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
17
0
heinrichsweikamp
parents:
diff changeset
18
heinrichsweikamp
parents:
diff changeset
19 ;=============================================================================
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
20 convert1 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
21 ;=============================================================================
0
heinrichsweikamp
parents:
diff changeset
22
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
23
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
24 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
25 ; Print last two Digits or double-dots if zero - big Font
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
26 ;
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
27 global output99DD_call
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
28 output99DD_call:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
29 tstfsz lo ; value = 0 ?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
30 bra output99_call ; NO - do normal output
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
31 movlw " " ; YES - print a space
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
32 movwf POSTINC2 ; - ...
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
33 bra print_doubledots ; - continue printing two dots
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
34
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
35
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
36 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
37 ; Print last two Digits or double-dots if zero - small Font
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
38 ;
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
39 global output99dd_call
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
40 output99dd_call:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
41 tstfsz lo ; value = 0 ?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
42 bra output99_call ; NO - do normal output
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
43 bra print_doubledots ; YES - continue printing two dots
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
44
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
45
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
46 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
47 ; Helper Function - Print two Dots
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
48 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
49 print_doubledots:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
50 movlw "." ; load a '.'
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
51 movwf POSTINC2 ; print 1st dot
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
52 movwf POSTINC2 ; print 2nd dot
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
53 bra output_common_finish ; clean-up and return
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
54
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
55
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
56 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
57 ; Print last Digit from a 8 bit Integer (0-9)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
58 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
59 global output9_call
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
60 output9_call:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
61 bsf hide_digit2 ; do not print digit 5, 4, 3 and 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
62 bra output8_common ; continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
63
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
64
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
65 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
66 ; Print only last two Digits from a 8 bit Integer, with leading zero (00-99)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
67 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
68 global output99x_call
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
69 output99x_call:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
70 bsf leading_zeros ; print leading zeros
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
71 ;bra output99_call ; continue with output99_call
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
72
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
73
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
74 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
75 ; Print last two Digits from a 8 bit Integer (0-99)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
76 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
77 global output99_call
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
78 output99_call:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
79 bsf hide_digit3 ; do not print digit 5, 4 and 3
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
80 ;bra output8_common ; continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
81
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
82
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
83 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
84 ; Print 8 bit Integer (0-255)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
85 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
86 global output256_call
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
87 output256_call:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
88 ;bra output8_common ; continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
89
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
90
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
91 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
92 ; Helper Function - common Part for Printing 8 Bit Integers
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
93 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
94 output8_common:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
95 bcf output_overflow ; clear overflow flag
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
96 movff lo,bin_lo ; copy value to show
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
97 rcall convert_bin8bcd ; compute bcd_hi (1 digit) and bcd_lo (2 digits)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
98 btfsc hide_digit2 ; shall hide digit 2 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
99 bsf hide_digit3 ; YES - hide digit 3 then, too
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
100 bra output_common_d3 ; start printing with digit 3
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
101
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
102
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
103 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
104 ; Print last four Digits from a 16 bit Value (0-9999)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
105 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
106 global output9999_call
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
107 output9999_call:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
108 bsf hide_digit5 ; do not print digit 5
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
109 bra output16_common ; continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
110
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
111
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
112 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
113 ; Print last three Digits from a 16 bit Value (0-999)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
114 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
115 global output999_call
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
116 output999_call:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
117 bsf hide_digit4 ; do not print digit 4 and 5
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
118 ;bra output16_common ; continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
119
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
120
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
121 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
122 ; Print a full 16 bit Value (0-65535)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
123 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
124 global output65535_call
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
125 output65535_call:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
126 ;bra output16_common ; continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
127
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
128
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
129 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
130 ; Helper Function - common Part for Printing 16 Bit Integers
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
131 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
132 output16_common:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
133 bcf output_overflow ; clear overflow flag
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
134 movff lo,bin_lo ; copy value to show
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
135 movff hi,bin_hi ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
136 rcall convert_bin16bcd ; compute bcd_up (1 digit), bcd_hi (2 digits) and bcd_lo (2 digits)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
137 btfsc hide_digit2 ; shall hide digit 2 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
138 bsf hide_digit3 ; YES - hide digit 3 then, too
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
139 btfsc hide_digit3 ; shall hide digit 3 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
140 bsf hide_digit4 ; YES - hide digit 4 then, too
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
141 btfsc hide_digit4 ; shall hide digit 4 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
142 bsf hide_digit5 ; YES - hide digit 5 then, too
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
143 ;bra output_common_d5 ; start printing with digit 5
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
144
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
145
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
146 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
147 ; Helper Function - common Part for Printing 8 and 16 Bit Integers
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
148 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
149 output_common_d5:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
150 ; digit 5
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
151 btfss hide_digit5 ; shall hide digit 5 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
152 bra output_common_d5p ; NO - print digit 5
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
153 movf bcd_up,W ; YES - get lower nibble (digit 5) into WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
154 andlw 0x0F ; - is it zero?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
155 bnz print_9999 ; NO - print '9999'
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
156 bra output_common_d4 ; YES - continue with digit 4
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
157 output_common_d5p:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
158 movf bcd_up,W ; copy 5th digit to lower nibble of WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
159 rcall print_digit ; print the digit
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
160
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
161 output_common_d4:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
162 ; between digit 5 and 4
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
163 btfsc decimal_digit3 ; shall print a decimal point in front of digit 3 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
164 bsf leading_zeros ; YES - allow printing of zeros now
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
165
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
166 ; digit 4
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
167 btfss hide_digit4 ; shall hide digit 4 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
168 bra output_common_d4p ; NO - print digit 4
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
169 swapf bcd_hi,W ; YES - get upper nibble (digit 4) into WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
170 andlw 0x0F ; - is it zero?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
171 bnz print_999 ; NO - print '999'
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
172 bra output_common_d3 ; YES - continue with digit 3
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
173 output_common_d4p:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
174 swapf bcd_hi,W ; copy 4th digit to lower nibble of WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
175 rcall print_digit ; print the digit
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
176
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
177 output_common_d3:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
178 ; between digit 4 and 3
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
179 btfsc decimal_digit3 ; shall print a decimal point in front of digit 3 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
180 rcall print_decimal ; YES - print a decimal pint now
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
181 btfsc decimal_digit2 ; shall print a decimal point in front of digit 2 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
182 bsf leading_zeros ; YES - allow printing of zeros now
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
183 btfsc omit_digit_2 ; shall omit digits 2 and 1 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
184 bsf leading_zeros ; YES - allow printing of zeros now
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
185
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
186 ; digit 3
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
187 btfss hide_digit3 ; shall hide digit 3 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
188 bra output_common_d3p ; NO - print digit 3
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
189 movf bcd_hi,W ; YES - get lower nibble (digit 3) into WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
190 andlw 0x0F ; - is it zero?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
191 bnz print_99 ; NO - print '99'
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
192 bra output_common_d2 ; YES - continue with digit 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
193 output_common_d3p:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
194 movf bcd_hi,W ; copy 3rd digit to lower nibble of WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
195 rcall print_digit ; print the digit
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
196
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
197 output_common_d2:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
198 ; between digit 3 and 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
199 btfsc decimal_digit2 ; shall print a decimal point in front of digit 2 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
200 rcall print_decimal ; YES - print a decimal pint now
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
201 btfsc decimal_digit1 ; shall print a decimal point in front of digit 1 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
202 bsf leading_zeros ; YES - allow printing of zeros now
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
203 btfsc omit_digit_1 ; shall omit digit 1 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
204 bsf leading_zeros ; YES - allow printing of zeros now
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
205
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
206 ; digit 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
207 btfss hide_digit2 ; shall hide digit 2 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
208 bra output_common_d2p ; NO - print digit 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
209 swapf bcd_lo,W ; YES - get upper nibble (digit 2) into WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
210 andlw 0x0F ; - is it zero?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
211 bnz print_9 ; NO - print '9'
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
212 bra output_common_d1 ; YES - continue with digit 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
213 output_common_d2p:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
214 btfsc omit_digit_2 ; shall omit digit 2 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
215 bra output_common_finish ; YES - finish output
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
216 swapf bcd_lo,W ; NO - copy 2nd digit to lower nibble of WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
217 rcall print_digit ; - print the digit
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
218
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
219 output_common_d1:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
220 ; between digit 2 and 1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
221 btfsc decimal_digit1 ; shall print a decimal point in front of digit 1 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
222 rcall print_decimal ; YES - print a decimal pint now
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
223 bsf leading_zeros ; allow printing of zeros now
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
224
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
225 ; digit 1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
226 btfsc omit_digit_1 ; shall omit digit 1 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
227 bra output_common_finish ; YES - finish output
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
228 movf bcd_lo,W ; NO - copy 1st digit to lower nibble of WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
229 rcall print_digit ; - print the digit
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
230
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
231 output_common_finish:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
232 clrf INDF2 ; place a terminator at the current buffer position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
233 clrf CVT_flags1 ; clear output format command flags
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
234 clrf CVT_flags2 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
235 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
236
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
237
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
238 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
239 ; Helper Function - print a Digit or a decimal Point
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
240 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
241 ; Input: lower nibble of WREG BCD code of digit
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
242 ; leading_zeros =1: print (leading) zeros
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
243 ; leftbind =1: do not print leading spaces
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
244 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
245 print_digit:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
246 andlw 0x0F ; keep only the lower nibble, is it zero?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
247 bnz print_digit_digit ; NO - print in any case
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
248 btfsc leading_zeros ; YES - printing of zeros allowed?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
249 bra print_digit_digit ; YES - print a zero
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
250 btfsc leftbind ; NO - shall print left-aligned?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
251 return ; YES - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
252 movlw ' ' ; NO - load ASCII code of a space char
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
253 bra print_digit_print ; - print it
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
254 print_digit_digit:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
255 bsf leading_zeros ; allow printing of zeros now
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
256 addlw '0' ; add ASCII code of '0' to BCD code to get final ASCII code
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
257 print_digit_print:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
258 movwf POSTINC2 ; print the digit or char
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
259 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
260
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
261 print_decimal:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
262 movlw '.' ; load ASCII code of a dot
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
263 bra print_digit_print ; print it
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
264
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
265
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
266 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
267 ; Helper Function - print '9999' or '999' or '99' or '9'
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
268 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
269 print_9999:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
270 movlw '9' ; load a '9' digit
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
271 movwf POSTINC2 ; print digit 4
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
272 print_999:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
273 movlw '9' ; load a '9' digit (for those embarked lately)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
274 movwf POSTINC2 ; print digit 3
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
275 print_99:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
276 movlw '9' ; load a '9' digit (for those embarked lately)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
277 movwf POSTINC2 ; print digit 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
278 print_9:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
279 movlw '9' ; load a '9' digit (for those embarked lately)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
280 movwf POSTINC2 ; print digit 1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
281 clrf INDF2 ; place a terminator at the current buffer position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
282 clrf CVT_flags1 ; clear output format command flags
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
283 clrf CVT_flags2 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
284 bsf output_overflow ; set overflow flag
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
285 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
286
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
287
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
288 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
289 ; Convert an 8 Bit Integer to BCD
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
290 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
291 ; Input: bin_lo 8 bit integer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
292 ; Output: bcd_hi,bcd_lo 3 BCD digits
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
293 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
294 convert_bin8bcd:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
295 clrf bcd_lo ; clear result variables
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
296 clrf bcd_hi ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
297 bsf bcd_hi,0 ; set loop counter to 8
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
298 convert_bin8bcd_loop:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
299 ; get MSB bit from binary
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
300 rlcf bin_lo,F ; shift-out MSB to CARRY
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
301 ; lower two BCDs
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
302 movf bcd_lo,W ; get lower BCDs to WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
303 addwfc bcd_lo,W ; WREG = 2 * WREG + CARRY
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
304 daw ; decimal-adjust BCDs in WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
305 movwf bcd_lo ; copy back WREG to lower BCDs
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
306 ; higher one BCD
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
307 rlcf bcd_hi ; higher BCD = 2*(higher BCD) + CARRY (special version for 1 BCD only)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
308 ; loop control
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
309 bnc convert_bin8bcd_loop ; all 8 bits done? NO -> loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
310 return ; YES -> done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
311
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
312
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
313 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
314 ; Convert a 16 Bit Integer to BCD
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
315 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
316 ; Input: bin_hi,bin_lo 16 bit integer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
317 ; Output: bcd_up,bcd_hi,bcd_lo 5 BCD digits
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
318 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
319 convert_bin16bcd:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
320 clrf bcd_lo ; clear result variables
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
321 clrf bcd_hi ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
322 clrf bcd_up ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
323 movlw .16 ; 16 bits to do
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
324 movwf math_loop ; load loop counter
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
325 convert_bin16bcd_loop:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
326 ; get MSB bit from binary
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
327 rlcf bin_lo,F ; shift-out MSB to CARRY
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
328 rlcf bin_hi,F ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
329 ; lower two BCDs
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
330 movf bcd_lo,W ; get lower BCDs to WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
331 addwfc bcd_lo,W ; WREG = 2 * WREG + CARRY
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
332 daw ; decimal-adjust BCDs in WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
333 movwf bcd_lo ; copy back WREG to lower BCDs
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
334 ; higher two BCDs
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
335 movf bcd_hi,W ; repeat for higher BCDs
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
336 addwfc bcd_hi,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
337 daw ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
338 movwf bcd_hi ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
339 ; upper one BCD
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
340 ; movf bcd_up,W ; repeat for upper BCD
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
341 ; addwfc bcd_up,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
342 ; daw ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
343 ; movwf bcd_up ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
344 rlcf bcd_up ; upper BCD = 2*(upper BCD) + CARRY (special version for 1 BCD only)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
345 ; loop control
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
346 decfsz math_loop ; decrement bit counter, all done?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
347 bra convert_bin16bcd_loop ; NO - loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
348 return ; YES - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
349
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
350
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
351 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
352 convert2 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
353 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
354
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
355
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
356 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
357 ; Print Value in WREG as hex Number (00-FF)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
358 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
359 global outputHEX_call
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
360 outputHEX_call:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
361 movwf bin_lo ; make a backup
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
362 swapf WREG,W ; swap nibbles to process upper nibble first
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
363 rcall outputHEX_nibble ; print nibble as ASCII
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
364 movf bin_lo,W ; recall backup
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
365 outputHEX_nibble:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
366 andlw 0x0F ; isolate lower nibble
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
367 addlw +0x36 ; add 0x36 so that numbers >= decimal 10 will become >= 0x40
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
368 btfss WREG,6 ; WREG >= 0x40 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
369 addlw -0x07 ; NO - number is < 10, move back by offset between ASCII codes for 'A' and '9'
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
370 addlw +0x01 ; make final common move forward to align with ASCII code
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
371 movwf POSTINC2 ; write ASCII code to output buffer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
372 clrf INDF2 ; place a terminator at the current buffer position
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
373 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
374
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
375
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
376 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
377 convert3 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
378 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
379
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
380
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
381 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
382 ; Convert signed 16 Bit to unsigned 16 Bit and put a '-' into the buffer if negative
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
383 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
384 ; Input / Output: mpr:2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
385 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
386 global convert_signed_16bit
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
387 convert_signed_16bit:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
388 bcf neg_flag ; clear flag for negative number by default
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
389 btfss hi,7 ; negative number?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
390 return ; NO - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
391 bsf neg_flag ; YES - set flag for negative number
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
392 comf hi ; - complement hi:lo
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
393 negf lo ; - ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
394 btfsc STATUS,C ; - ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
395 incf hi ; - ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
396 movlw '-' ; - print a minus sign
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
397 movwf POSTINC2 ; - ...
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
398 return ; - done
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
399
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
400
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
401 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
402 convert4 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
403 ;=============================================================================
0
heinrichsweikamp
parents:
diff changeset
404
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
405
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
406 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
407 ; Convert Pressure in [mbar] to Depth in [cm]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
408 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
409 ; Input: mpr:2 pressure [mbar]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
410 ; Output: mpr:2 depth [cm]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
411 ; Destroys: up
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
412 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
413 global convert_pres_to_depth
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
414 convert_pres_to_depth:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
415 btfsc sensor_override_active ; in pressure sensor override (simulator) mode?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
416 return ; YES - convert with factor 1.0, i.e. make [mbar] = [cm]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
417
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
418 movff opt_salinity,WREG ; get salinity setting (0 - 4 %, see option_table.asm)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
419 addlw d'100' ; add density of fresh water (1.00 kg/l)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
420 movwf up ; store salinity factor in up
0
heinrichsweikamp
parents:
diff changeset
421
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
422 movlw .101+salinity_max ; load (upper limit + 1)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
423 cpfslt up ; current setting > upper limit?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
424 bra convert_fix_salinity ; YES - fix salinity setting
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
425
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
426 movlw .99+salinity_min ; load (lower limit - 1)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
427 cpfsgt up ; current setting > lower limit?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
428 bra convert_fix_salinity ; YES - fix salinity setting
0
heinrichsweikamp
parents:
diff changeset
429
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
430 convert_pres_to_depth_1:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
431 MOVII mpr, xA ; get pressure in [mbar]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
432 MOVLI .102,xB ; conversion factor x 100 for fresh water (1.02 cm per each 1 mbar)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
433 call mult16x16 ; xC:4 = xA:2 * xB:2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
434 movff up,xB+0 ; get salinity in [%]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
435 clrf xB+1 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
436 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
437 MOVII xC,mpr ; copy back result as depth in [cm]
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
438 return
0
heinrichsweikamp
parents:
diff changeset
439
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
440 convert_fix_salinity:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
441 movlw .100 ; reset to 100%, i.e. set salinity to 0%
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
442 movwf up ; fix value in up
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
443 bra convert_pres_to_depth_1 ; continue
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
444
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
445
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
446 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
447 convert5 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
448 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
449
0
heinrichsweikamp
parents:
diff changeset
450
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
451 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
452 ; Convert Depth in [cm] to Depth in [feet]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
453 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
454 ; Input: mpr:2 depth in [cm]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
455 ; Output: mpr:2 depth in [ft]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
456 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
457 global convert_cm_to_feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
458 convert_cm_to_feet:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
459 MOVII mpr, xA ; depth in [cm]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
460 btfsc sensor_override_active ; in pressure sensor override (simulator) mode?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
461 bra convert_meter_to_feet_1 ; YES - convert with 334feet/100m
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
462 MOVLI .328,xB ; NO - convert with 328feet/100m
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
463 bra convert_common_to_feet ; - continue with common part
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
464
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
465
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
466 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
467 ; Convert Depth in [m] to Depth in [feet]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
468 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
469 ; Input: lo depth in [m]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
470 ; Output: mpr:2 depth in [ft]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
471 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
472 global convert_meter_to_feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
473 convert_meter_to_feet:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
474 movf lo,W ; depth in [m]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
475 mullw .100 ; factor to convert [m] to [cm]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
476 MOVII PRODL,xA ; copy depth in [cm] to xA
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
477 convert_meter_to_feet_1:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
478 MOVLI .334, xB ; convert with 334feet/100m to have 10ft, 20ft, 30ft, ... for stop depths
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
479 ;bra convert_common_to_feet ; continue with common part
0
heinrichsweikamp
parents:
diff changeset
480
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
481
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
482 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
483 ; Helper Function to convert_cm_to_feet and convert_meter_to_feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
484 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
485 convert_common_to_feet:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
486 call mult16x16 ; xC = xA * xB = depth in [cm] * 334 feet/100 m = depth in 0.0001 feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
487 MOVLI .10000,xB ; divide by 10000 to turn into full feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
488 call div32x16 ; xC = xC / xB with xA as remainder
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
489 MOVII xC,mpr ; store result
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
490 return ; done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
491
0
heinrichsweikamp
parents:
diff changeset
492
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
493 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
494 convert6 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
495 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
496
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
497
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
498 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
499 ; Convert Temperature in Celsius to Fahrenheit
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
500 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
501 ; Input: mpr:2 temperature in [0.1 °C]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
502 ; Output: mpr:2 temperature in [0.1 °F]
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
503 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
504 global convert_celsius_to_fahrenheit
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
505 convert_celsius_to_fahrenheit:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
506 MOVII mpr,xA ; temperature in 1/10 of °C
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
507 ADDLI .1000,xA ; add offset of 1000 to get out of any negative numbers
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
508 ; adjust scaling: 1°C = 1.8°F:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
509 MOVLI .18,xB ; multiply with 18:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
510 call mult16x16 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
511 MOVLI .10,xB ; divide by 10
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
512 call div32x16 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
513 SUBLI .1480,xC ; subtract above offset (1000 * 1.8 = 1800) and add Fahrenheit-Offset (32 * 10 = 320) => subtract 1480
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
514 MOVII xC,mpr ; store result in mpr:2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
515 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
516
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
517
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
518 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
519 convert7 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
520 ;=============================================================================
300
5ad479f2a868 Merged Screen layout mod #1 into Screen layout work #3
Janos Kovacs <kovjanos@gmail.com>
parents: 275
diff changeset
521
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
522
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
523 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
524 ; Convert Minutes to Hours and Minutes / Seconds to Minutes and Seconds
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
525 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
526 ; Input: hi:lo minutes / seconds
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
527 ; Output: up:hi hours / minutes
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
528 ; lo minutes / seconds
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
529 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
530 ; trashes xA, xB, xC
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
531 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
532 global convert_time
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
533 convert_time:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
534 movff lo,xA+0 ; copy hi:lo to xA
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
535 movff hi,xA+1 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
536 movlw d'60' ; set divisor to 60
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
537 movwf xB+0 ; write 60 to xB
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
538 clrf xB+1 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
539 call div16x16 ; xC = xA / xB with xA as remainder
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
540 movff xC+1,up ; result is hours / minutes, copy to up (high byte)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
541 movff xC+0,hi ; result is hours / minutes, copy to hi (low byte)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
542 movff xA+0,lo ; remainder is minutes / seconds, copy to lo
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
543 return ; done
0
heinrichsweikamp
parents:
diff changeset
544
heinrichsweikamp
parents:
diff changeset
545
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
546 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
547 convert8 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
548 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
549
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
550
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
551 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
552 ; Print full Date
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
553 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
554 ; Input: lo year
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
555 ; hi month
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
556 ; up day
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
557 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
558 ; Output format depends on value of option opt_dateformat:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
559 ; 0: MM.DD.YY
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
560 ; 1: DD.MM.YY
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
561 ; 2: YY.MM.DD
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
562 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
563 ; Destroyed: hy
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
564 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
565 global output_date
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
566 output_date:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
567 movff opt_dateformat,EEDATA ; get format (EEDATA used as temp here)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
568 tstfsz EEDATA ; shall use format 0 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
569 bra TFT_convert_date_1 ; NO - check for format 1 or 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
570 ; YES - use format 0: MM.DD.YY
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
571 movff lo,hy ; - backup year to hy
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
572 movff hi,lo ; - copy month to lo
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
573 movff up,hi ; - copy day to hi
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
574 movff hy,up ; - copy year to up
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
575 bra TFT_convert_date_common ; - start output
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
576 TFT_convert_date_1:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
577 decfsz EEDATA,F ; shall use format 1 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
578 bra TFT_convert_date_common ; NO - use format 2: YY.MM.DD - can print directly
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
579 ; YES - use format 1: DD.MM.YY
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
580 movff lo,hy ; - backup year to hy
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
581 movff up,lo ; - copy day to lo
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
582 movff hy,up ; - copy year to up
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
583
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
584 TFT_convert_date_common:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
585 call output99x_call ; print lo (00-99)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
586 PUTC '.' ; print spacing dot
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
587 movff hi,lo ; print hi (00-99)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
588 call output99x_call ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
589 PUTC '.' ; print spacing dot
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
590 movff up,lo ; print up (00-99)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
591 call output99x_call ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
592 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
593
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
594
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
595 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
596 convert9 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
597 ;=============================================================================
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
598
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
599
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
600 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
601 ; Print Date by Month & Day
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
602 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
603 ; Input: hi month
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
604 ; up day
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
605 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
606 ; Output format depends on value of option opt_dateformat:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
607 ; 0: MM.DD
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
608 ; 1: DD.MM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
609 ; 2: MM.DD
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
610 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
611 ; Destroyed: lo
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
612 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
613 global output_date_short
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
614 output_date_short:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
615 movff opt_dateformat,EEDATA ; get format (EEDATA used as temp here)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
616 tstfsz EEDATA ; shall use format 0 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
617 bra TFT_convert_date_short2 ; NO - check for format 1 or 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
618 TFT_convert_date_short1: ; YES - use format 0: MMDD
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
619 movff hi,lo ; - copy month to lo
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
620 movff up,hi ; - copy day to hi
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
621 bra TFT_convert_date_short3 ; - start output
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
622 TFT_convert_date_short2:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
623 decfsz EEDATA,F ; format 1 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
624 bra TFT_convert_date_short1 ; NO - use format 2: MMDD (here its like format 0)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
625 ; YES - use format 1: DDMM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
626 movff up,lo ; - copy day to lo,
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
627 ; - month is already in hi
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
628 TFT_convert_date_short3:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
629 call output99x_call ; print lo (00-99)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
630 PUTC '.' ; print spacing dot
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
631 movff hi,lo ; print hi (00-99)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
632 call output99x_call ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
633 return ; done
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
634
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
635
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
636 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
637 convert10 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
638 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
639
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
640
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
641 global output_secs_as_days_hours
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
642 output_secs_as_days_hours:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
643 MOVLI .3600,xB ; one hour = 3600s
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
644 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder -> xC+1:xC+0 holds full hours
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
645 MOVII xC, xA ; transfer result to xA
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
646 MOVLI .24,xB ; one day = 24 hours
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
647 call div16x16 ; xC:2 = xA:2 / xB:2 with xA as remainder -> xC+1:xC+0 holds full days, xA holds full hours
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
648 MOVII xC,mpr ; copy full days into hi:lo
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
649 call output99_call ; print days (0-99)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
650 PUTC "d" ; append unit
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
651 movff xA+0,lo ; get full hours
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
652 call output99x_call ; print full hours (00-99)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
653 PUTC "h" ; append unit
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
654 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
655
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
656
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
657 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 628
diff changeset
658
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 418
diff changeset
659 END