annotate src/strings.asm @ 580:1ab93aca7fa9

2.97 work...
author heinrichsweikamp
date Wed, 21 Feb 2018 19:30:28 +0100
parents b7eb98dbd800
children ca4556fb60b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
3 ; File strings.asm Version 2.92 = 2.26
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Implementation code various string functions.
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2010-12-02 : [jDG] Creation...
heinrichsweikamp
parents:
diff changeset
11 ;
heinrichsweikamp
parents:
diff changeset
12 ; See strings.inc for doc and public calling macros.
heinrichsweikamp
parents:
diff changeset
13
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 251
diff changeset
14 #include "hwos.inc"
0
heinrichsweikamp
parents:
diff changeset
15 #include "varargs.inc"
heinrichsweikamp
parents:
diff changeset
16
heinrichsweikamp
parents:
diff changeset
17 extern aa_wordprocessor
heinrichsweikamp
parents:
diff changeset
18
heinrichsweikamp
parents:
diff changeset
19 basic CODE
heinrichsweikamp
parents:
diff changeset
20 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
21 ; Variants that call word_processor at the end:
heinrichsweikamp
parents:
diff changeset
22 global strcpy_block_print
heinrichsweikamp
parents:
diff changeset
23 strcpy_block_print:
heinrichsweikamp
parents:
diff changeset
24 lfsr FSR2, buffer
heinrichsweikamp
parents:
diff changeset
25 global strcat_block_print
heinrichsweikamp
parents:
diff changeset
26 strcat_block_print:
heinrichsweikamp
parents:
diff changeset
27 clrf PRODL,A
heinrichsweikamp
parents:
diff changeset
28 bra strings_common
heinrichsweikamp
parents:
diff changeset
29
heinrichsweikamp
parents:
diff changeset
30 ; Variants that do not call word_processor at end:
heinrichsweikamp
parents:
diff changeset
31 global strcpy_block
heinrichsweikamp
parents:
diff changeset
32 strcpy_block:
heinrichsweikamp
parents:
diff changeset
33 lfsr FSR2, buffer
heinrichsweikamp
parents:
diff changeset
34 global strcat_block
heinrichsweikamp
parents:
diff changeset
35 strcat_block:
heinrichsweikamp
parents:
diff changeset
36 setf PRODL,A
heinrichsweikamp
parents:
diff changeset
37
heinrichsweikamp
parents:
diff changeset
38 ; Common part: append the string from PROM return address:
heinrichsweikamp
parents:
diff changeset
39 strings_common:
heinrichsweikamp
parents:
diff changeset
40 VARARGS_BEGIN
heinrichsweikamp
parents:
diff changeset
41
heinrichsweikamp
parents:
diff changeset
42 rcall strcat_prom
heinrichsweikamp
parents:
diff changeset
43
heinrichsweikamp
parents:
diff changeset
44 VARARGS_ALIGN
heinrichsweikamp
parents:
diff changeset
45 VARARGS_END
heinrichsweikamp
parents:
diff changeset
46
heinrichsweikamp
parents:
diff changeset
47 btfsc PRODL,0,A ; Should we print afterward ?
heinrichsweikamp
parents:
diff changeset
48 return ; NO: then return straight away.
heinrichsweikamp
parents:
diff changeset
49 goto aa_wordprocessor ; ELSE: print it...
heinrichsweikamp
parents:
diff changeset
50
heinrichsweikamp
parents:
diff changeset
51 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
52 ; Copy multi-lingual text from FSR1 12bit pointers, to buffer.
heinrichsweikamp
parents:
diff changeset
53 ;
heinrichsweikamp
parents:
diff changeset
54 ; Input: FSR1 = 12bit pointer to multi-lingual text.
heinrichsweikamp
parents:
diff changeset
55 ; Output: FSR2 points to closing null byte in buffer.
heinrichsweikamp
parents:
diff changeset
56 ; Trashed: TBLPTR, TABLAT.
heinrichsweikamp
parents:
diff changeset
57 global strcpy_text
heinrichsweikamp
parents:
diff changeset
58 strcpy_text:
heinrichsweikamp
parents:
diff changeset
59 rcall text_get_tblptr
heinrichsweikamp
parents:
diff changeset
60 bra strcpy_prom
heinrichsweikamp
parents:
diff changeset
61
heinrichsweikamp
parents:
diff changeset
62 ; Copy then print multi-lingual text from FSR1 12bit pointers, to buffer.
heinrichsweikamp
parents:
diff changeset
63 ;
heinrichsweikamp
parents:
diff changeset
64 ; Input: FSR1 = 12bit pointer to multi-lingual text.
heinrichsweikamp
parents:
diff changeset
65 ; Output: FSR2 points to closing null byte in buffer.
heinrichsweikamp
parents:
diff changeset
66 ; Trashed: TBLPTR, TABLAT.
heinrichsweikamp
parents:
diff changeset
67 global strcpy_text_print
heinrichsweikamp
parents:
diff changeset
68 strcpy_text_print:
heinrichsweikamp
parents:
diff changeset
69 rcall text_get_tblptr
heinrichsweikamp
parents:
diff changeset
70 bra strcpy_prom_print
heinrichsweikamp
parents:
diff changeset
71
heinrichsweikamp
parents:
diff changeset
72 ; Append multi-lingual text from FSR1 12bit pointers, to buffer at FRS2.
heinrichsweikamp
parents:
diff changeset
73 ;
heinrichsweikamp
parents:
diff changeset
74 ; Input: FSR1 = 12bit pointer to multi-lingual text.
heinrichsweikamp
parents:
diff changeset
75 ; FSR2 = Current position in buffer.
heinrichsweikamp
parents:
diff changeset
76 ; Output: FSR2 points to closing null byte in buffer.
heinrichsweikamp
parents:
diff changeset
77 ; Trashed: TBLPTR, TABLAT.
heinrichsweikamp
parents:
diff changeset
78 global strcat_text
heinrichsweikamp
parents:
diff changeset
79 strcat_text:
heinrichsweikamp
parents:
diff changeset
80 rcall text_get_tblptr
heinrichsweikamp
parents:
diff changeset
81 bra strcat_prom
heinrichsweikamp
parents:
diff changeset
82
heinrichsweikamp
parents:
diff changeset
83 ; Append then print multi-lingual text from FSR1 12bit pointers, to buffer at FRS2.
heinrichsweikamp
parents:
diff changeset
84 ;
heinrichsweikamp
parents:
diff changeset
85 ; Input: FSR1 = 12bit pointer to multi-lingual text.
heinrichsweikamp
parents:
diff changeset
86 ; FSR2 = Current position in buffer.
heinrichsweikamp
parents:
diff changeset
87 ; Output: FSR2 points to closing null byte in buffer.
heinrichsweikamp
parents:
diff changeset
88 ; Trashed: TBLPTR, TABLAT.
heinrichsweikamp
parents:
diff changeset
89 global strcat_text_print
heinrichsweikamp
parents:
diff changeset
90 strcat_text_print:
heinrichsweikamp
parents:
diff changeset
91 rcall text_get_tblptr
heinrichsweikamp
parents:
diff changeset
92 bra strcat_prom_print
heinrichsweikamp
parents:
diff changeset
93
heinrichsweikamp
parents:
diff changeset
94 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
95 ; Get pointer to multilingual texl in TBLPTR
heinrichsweikamp
parents:
diff changeset
96 ;
heinrichsweikamp
parents:
diff changeset
97 ; Input: FSR1 = 12bits of text handle.
heinrichsweikamp
parents:
diff changeset
98 ; opt_language = current language.
heinrichsweikamp
parents:
diff changeset
99 ; Output: TBLPTR = 24bits of PROM address.
heinrichsweikamp
parents:
diff changeset
100 ;
heinrichsweikamp
parents:
diff changeset
101 global text_get_tblptr
heinrichsweikamp
parents:
diff changeset
102 text_get_tblptr:
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
103 extern text_1_base
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
104 movlw UPPER(text_1_base) ; Complete 12bits to 24bits address.
0
heinrichsweikamp
parents:
diff changeset
105 movwf TBLPTRU
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
106 movlw HIGH(text_1_base)
0
heinrichsweikamp
parents:
diff changeset
107 andlw 0xF0
heinrichsweikamp
parents:
diff changeset
108 iorwf FSR1H,W
heinrichsweikamp
parents:
diff changeset
109 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
110 movff FSR1L,TBLPTRL
heinrichsweikamp
parents:
diff changeset
111
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
112
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
113 movff opt_language,WREG ; Get lang
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
114 bz text_get_lang1 ; 0 == English
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
115 dcfsnz WREG ; 1 == German
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
116 bra text_get_lang2
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
117 ; Other ??? Keep language 1
0
heinrichsweikamp
parents:
diff changeset
118
heinrichsweikamp
parents:
diff changeset
119 ; Read 2-byte pointer to string
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
120 text_get_lang1:
0
heinrichsweikamp
parents:
diff changeset
121 tblrd*+
heinrichsweikamp
parents:
diff changeset
122 movff TABLAT,WREG
heinrichsweikamp
parents:
diff changeset
123 tblrd*+
heinrichsweikamp
parents:
diff changeset
124 movff WREG,TBLPTRL
heinrichsweikamp
parents:
diff changeset
125 movff TABLAT,TBLPTRH
heinrichsweikamp
parents:
diff changeset
126 return
heinrichsweikamp
parents:
diff changeset
127
heinrichsweikamp
parents:
diff changeset
128 ; Add correction for German table:
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
129 text_get_lang2:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
130 extern text_2_base
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
131 movlw LOW(text_2_base)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
132 addwf TBLPTRL
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
133 movlw HIGH(text_2_base)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
134 addwfc TBLPTRH
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
135 movlw UPPER(text_2_base)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
136 addwfc TBLPTRU
0
heinrichsweikamp
parents:
diff changeset
137
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
138 movlw LOW(text_1_base)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
139 subwf TBLPTRL
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
140 movlw HIGH(text_1_base)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
141 subwfb TBLPTRH
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
142 movlw UPPER(text_1_base)
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
143 subwfb TBLPTRU
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
144 bra text_get_lang1
0
heinrichsweikamp
parents:
diff changeset
145
heinrichsweikamp
parents:
diff changeset
146 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
147 ; Copy a null-terminated string from TBLPTR to buffer.
heinrichsweikamp
parents:
diff changeset
148 ;
heinrichsweikamp
parents:
diff changeset
149 ; Input: TBLPTR : string pointer into PROM.
heinrichsweikamp
parents:
diff changeset
150 ; Output: string in buffer, FSR2 pointer on the closing null byte.
heinrichsweikamp
parents:
diff changeset
151 ;
heinrichsweikamp
parents:
diff changeset
152 global strcpy_prom
heinrichsweikamp
parents:
diff changeset
153 strcpy_prom:
heinrichsweikamp
parents:
diff changeset
154 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
155
heinrichsweikamp
parents:
diff changeset
156 ; Append a null-terminated string from TBLPTR to buffer.
heinrichsweikamp
parents:
diff changeset
157 ;
heinrichsweikamp
parents:
diff changeset
158 ; Input: TBLPTR : string pointer into PROM.
heinrichsweikamp
parents:
diff changeset
159 ; FRS2 : current character position.
heinrichsweikamp
parents:
diff changeset
160 ; Output: string in buffer, FSR2 pointer on the closing null byte.
heinrichsweikamp
parents:
diff changeset
161 ;
heinrichsweikamp
parents:
diff changeset
162 global strcat_prom
heinrichsweikamp
parents:
diff changeset
163 strcat_prom:
heinrichsweikamp
parents:
diff changeset
164 tblrd*+
heinrichsweikamp
parents:
diff changeset
165 movf TABLAT,W
heinrichsweikamp
parents:
diff changeset
166 movwf POSTINC2
heinrichsweikamp
parents:
diff changeset
167 bnz strcat_prom
heinrichsweikamp
parents:
diff changeset
168 movf POSTDEC2,W ; rewind one char in string buffer.
heinrichsweikamp
parents:
diff changeset
169 return
heinrichsweikamp
parents:
diff changeset
170
heinrichsweikamp
parents:
diff changeset
171 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
172 ; Variant that calls word processor right-away...
heinrichsweikamp
parents:
diff changeset
173 global strcpy_prom_print
heinrichsweikamp
parents:
diff changeset
174 global strcat_prom_print
heinrichsweikamp
parents:
diff changeset
175
heinrichsweikamp
parents:
diff changeset
176 strcpy_prom_print:
heinrichsweikamp
parents:
diff changeset
177 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
178 strcat_prom_print:
heinrichsweikamp
parents:
diff changeset
179 rcall strcat_prom
heinrichsweikamp
parents:
diff changeset
180 goto aa_wordprocessor
heinrichsweikamp
parents:
diff changeset
181
heinrichsweikamp
parents:
diff changeset
182 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
183
heinrichsweikamp
parents:
diff changeset
184 global start_tiny_block
heinrichsweikamp
parents:
diff changeset
185 start_tiny_block:
heinrichsweikamp
parents:
diff changeset
186 clrf WREG
heinrichsweikamp
parents:
diff changeset
187 bra start_common
heinrichsweikamp
parents:
diff changeset
188
heinrichsweikamp
parents:
diff changeset
189 global start_small_block
heinrichsweikamp
parents:
diff changeset
190 start_small_block:
heinrichsweikamp
parents:
diff changeset
191 movlw 1
heinrichsweikamp
parents:
diff changeset
192 bra start_common
heinrichsweikamp
parents:
diff changeset
193
heinrichsweikamp
parents:
diff changeset
194 global start_std_block
heinrichsweikamp
parents:
diff changeset
195 start_std_block:
heinrichsweikamp
parents:
diff changeset
196 movlw 2
heinrichsweikamp
parents:
diff changeset
197 bra start_common
heinrichsweikamp
parents:
diff changeset
198
heinrichsweikamp
parents:
diff changeset
199 global start_medium_block
heinrichsweikamp
parents:
diff changeset
200 start_medium_block:
heinrichsweikamp
parents:
diff changeset
201 movlw 3
heinrichsweikamp
parents:
diff changeset
202 bra start_common
heinrichsweikamp
parents:
diff changeset
203
heinrichsweikamp
parents:
diff changeset
204 global start_large_block
heinrichsweikamp
parents:
diff changeset
205 start_large_block:
heinrichsweikamp
parents:
diff changeset
206 movlw 4
189
e79bc535ef9e ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents: 124
diff changeset
207 ; bra start_common
0
heinrichsweikamp
parents:
diff changeset
208 start_common:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 448
diff changeset
209 movff WREG, win_font ; Need a bank-safe move here !
0
heinrichsweikamp
parents:
diff changeset
210 VARARGS_BEGIN
heinrichsweikamp
parents:
diff changeset
211 VARARGS_GET8 win_leftx2
heinrichsweikamp
parents:
diff changeset
212 VARARGS_GET8 win_top
heinrichsweikamp
parents:
diff changeset
213 VARARGS_END
124
40ff64d60054 cleanup
heinrichsweikamp
parents: 0
diff changeset
214 lfsr FSR2,buffer ; point to buffer here
0
heinrichsweikamp
parents:
diff changeset
215 return
heinrichsweikamp
parents:
diff changeset
216
heinrichsweikamp
parents:
diff changeset
217 END