annotate src/strings.asm @ 495:2b1239e6ea85

Bugfix: More then one marker shown deleted profile
author heinrichsweikamp
date Sun, 02 Apr 2017 20:21:10 +0200
parents aadfe9f2edaf
children b7eb98dbd800
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File strings.asm
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
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
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
heinrichsweikamp
parents:
diff changeset
112 movff opt_language,WREG ; Get lang
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
113 bz text_get_lang1 ; 0 == English
0
heinrichsweikamp
parents:
diff changeset
114 dcfsnz WREG ; 1 == German
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
115 bra text_get_lang2
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
116 ; Other ??? Keep language 1
0
heinrichsweikamp
parents:
diff changeset
117
heinrichsweikamp
parents:
diff changeset
118 ; Read 2-byte pointer to string
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
119 text_get_lang1:
0
heinrichsweikamp
parents:
diff changeset
120 tblrd*+
heinrichsweikamp
parents:
diff changeset
121 movff TABLAT,WREG
heinrichsweikamp
parents:
diff changeset
122 tblrd*+
heinrichsweikamp
parents:
diff changeset
123 movff WREG,TBLPTRL
heinrichsweikamp
parents:
diff changeset
124 movff TABLAT,TBLPTRH
heinrichsweikamp
parents:
diff changeset
125 return
heinrichsweikamp
parents:
diff changeset
126
heinrichsweikamp
parents:
diff changeset
127 ; Add correction for German table:
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
128 text_get_lang2:
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
129 extern text_2_base
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
130 movlw LOW(text_2_base)
0
heinrichsweikamp
parents:
diff changeset
131 addwf TBLPTRL
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
132 movlw HIGH(text_2_base)
0
heinrichsweikamp
parents:
diff changeset
133 addwfc TBLPTRH
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
134 movlw UPPER(text_2_base)
0
heinrichsweikamp
parents:
diff changeset
135 addwfc TBLPTRU
heinrichsweikamp
parents:
diff changeset
136
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
137 movlw LOW(text_1_base)
0
heinrichsweikamp
parents:
diff changeset
138 subwf TBLPTRL
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
139 movlw HIGH(text_1_base)
0
heinrichsweikamp
parents:
diff changeset
140 subwfb TBLPTRH
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
141 movlw UPPER(text_1_base)
0
heinrichsweikamp
parents:
diff changeset
142 subwfb TBLPTRU
448
aadfe9f2edaf work on new battery options
heinrichsweikamp
parents: 275
diff changeset
143 bra text_get_lang1
0
heinrichsweikamp
parents:
diff changeset
144
heinrichsweikamp
parents:
diff changeset
145 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
146 ; Copy a null-terminated string from TBLPTR to buffer.
heinrichsweikamp
parents:
diff changeset
147 ;
heinrichsweikamp
parents:
diff changeset
148 ; Input: TBLPTR : string pointer into PROM.
heinrichsweikamp
parents:
diff changeset
149 ; Output: string in buffer, FSR2 pointer on the closing null byte.
heinrichsweikamp
parents:
diff changeset
150 ;
heinrichsweikamp
parents:
diff changeset
151 global strcpy_prom
heinrichsweikamp
parents:
diff changeset
152 strcpy_prom:
heinrichsweikamp
parents:
diff changeset
153 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
154
heinrichsweikamp
parents:
diff changeset
155 ; Append a null-terminated string from TBLPTR to buffer.
heinrichsweikamp
parents:
diff changeset
156 ;
heinrichsweikamp
parents:
diff changeset
157 ; Input: TBLPTR : string pointer into PROM.
heinrichsweikamp
parents:
diff changeset
158 ; FRS2 : current character position.
heinrichsweikamp
parents:
diff changeset
159 ; Output: string in buffer, FSR2 pointer on the closing null byte.
heinrichsweikamp
parents:
diff changeset
160 ;
heinrichsweikamp
parents:
diff changeset
161 global strcat_prom
heinrichsweikamp
parents:
diff changeset
162 strcat_prom:
heinrichsweikamp
parents:
diff changeset
163 tblrd*+
heinrichsweikamp
parents:
diff changeset
164 movf TABLAT,W
heinrichsweikamp
parents:
diff changeset
165 movwf POSTINC2
heinrichsweikamp
parents:
diff changeset
166 bnz strcat_prom
heinrichsweikamp
parents:
diff changeset
167 movf POSTDEC2,W ; rewind one char in string buffer.
heinrichsweikamp
parents:
diff changeset
168 return
heinrichsweikamp
parents:
diff changeset
169
heinrichsweikamp
parents:
diff changeset
170 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
171 ; Variant that calls word processor right-away...
heinrichsweikamp
parents:
diff changeset
172 global strcpy_prom_print
heinrichsweikamp
parents:
diff changeset
173 global strcat_prom_print
heinrichsweikamp
parents:
diff changeset
174
heinrichsweikamp
parents:
diff changeset
175 strcpy_prom_print:
heinrichsweikamp
parents:
diff changeset
176 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
177 strcat_prom_print:
heinrichsweikamp
parents:
diff changeset
178 rcall strcat_prom
heinrichsweikamp
parents:
diff changeset
179 goto aa_wordprocessor
heinrichsweikamp
parents:
diff changeset
180
heinrichsweikamp
parents:
diff changeset
181 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
182
heinrichsweikamp
parents:
diff changeset
183 global start_tiny_block
heinrichsweikamp
parents:
diff changeset
184 start_tiny_block:
heinrichsweikamp
parents:
diff changeset
185 clrf WREG
heinrichsweikamp
parents:
diff changeset
186 movff WREG, win_font ; Need a bank-safe move here !
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 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
193 bra start_common
heinrichsweikamp
parents:
diff changeset
194
heinrichsweikamp
parents:
diff changeset
195 global start_std_block
heinrichsweikamp
parents:
diff changeset
196 start_std_block:
heinrichsweikamp
parents:
diff changeset
197 movlw 2
heinrichsweikamp
parents:
diff changeset
198 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
199 bra start_common
heinrichsweikamp
parents:
diff changeset
200
heinrichsweikamp
parents:
diff changeset
201 global start_medium_block
heinrichsweikamp
parents:
diff changeset
202 start_medium_block:
heinrichsweikamp
parents:
diff changeset
203 movlw 3
heinrichsweikamp
parents:
diff changeset
204 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
205 bra start_common
heinrichsweikamp
parents:
diff changeset
206
heinrichsweikamp
parents:
diff changeset
207 global start_large_block
heinrichsweikamp
parents:
diff changeset
208 start_large_block:
heinrichsweikamp
parents:
diff changeset
209 movlw 4
heinrichsweikamp
parents:
diff changeset
210 movff WREG, win_font ; Need a bank-safe move here !
189
e79bc535ef9e ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents: 124
diff changeset
211 ; bra start_common
0
heinrichsweikamp
parents:
diff changeset
212 start_common:
heinrichsweikamp
parents:
diff changeset
213 VARARGS_BEGIN
heinrichsweikamp
parents:
diff changeset
214 VARARGS_GET8 win_leftx2
heinrichsweikamp
parents:
diff changeset
215 VARARGS_GET8 win_top
heinrichsweikamp
parents:
diff changeset
216 VARARGS_END
124
40ff64d60054 cleanup
heinrichsweikamp
parents: 0
diff changeset
217 lfsr FSR2,buffer ; point to buffer here
0
heinrichsweikamp
parents:
diff changeset
218 return
heinrichsweikamp
parents:
diff changeset
219
heinrichsweikamp
parents:
diff changeset
220 END