comparison code_part1/OSTC_code_asm_part1/strings.asm @ 97:dc349e4264bb

Cleanup CF for bad 15bits value display Cleanup old printf prototype New strings macro
author JeanDo
date Sun, 12 Dec 2010 01:13:48 +0100
parents
children 6a94f96e9cea
comparison
equal deleted inserted replaced
96:25433449bcb5 97:dc349e4264bb
1 ;=============================================================================
2 ;
3 ; File strings.asm
4 ;
5 ; Implementation code various string functions.
6 ;
7 ; This program is free software: you can redistribute it and/or modify
8 ; it under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation, either version 3 of the License, or
10 ; (at your option) any later version.
11 ;
12 ; This program is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ; GNU General Public License for more details.
16 ;
17 ; You should have received a copy of the GNU General Public License
18 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
19 ;
20 ; Copyright (c) 2010, JD Gascuel.
21 ;=============================================================================
22 ; HISTORY
23 ; 2010-12-02 : [jDG] Creation...
24 ;
25 ; See strings.inc for doc and public calling macros.
26
27 VARARGS_BEGIN macro
28 movff TOSL, TBLPTRL
29 movff TOSH, TBLPTRH
30 movff TOSU, TBLPTRU
31 endm
32
33 VARARGS_GET8 macro register
34 tblrd*+
35 movff TABLAT, register
36 endm
37
38 VARARGS_GET16 macro register
39 tblrd*+
40 movff TABLAT, register+0
41 tblrd*+
42 movff TABLAT, register+1
43 endm
44
45 VARARGS_ALIGN macro
46 btfss TBLPTRL,0
47 local no_tblptr_align
48 bra no_tblptr_align
49 incf TBLPTRL
50 movlw 0
51 addwfc TBLPTRH
52 no_tblptr_align:
53 endm
54
55 VARARGS_END macro
56 ; Compute string length (modulo 256):
57 movf TOSL,W
58 subwf TBLPTRL,W
59
60 ; Then 24bit add to return address
61 addwf TOSL,F
62 movlw 0 ; Clear WREG, but keep carry
63 addwfc TOSH,F
64 addwfc TOSU,F
65 endm
66
67 ;=============================================================================
68 ; Variants that call word_processor at the end:
69 strcpy_block_print:
70 lfsr FSR2, letter
71 strcat_block_print:
72 clrf PRODL,A
73 bra strings_common
74
75 ; Variants that do not call word_processor at end:
76 strcpy_block:
77 lfsr FSR2, letter
78 strcat_block:
79 setf PRODL,A
80
81 ; Common part: append the string from PROM return address:
82 strings_common:
83 VARARGS_BEGIN
84
85 strcpy_loop:
86 tblrd*+
87 movf TABLAT,W
88 movwf POSTINC2
89 bnz strcpy_loop
90 movf POSTDEC2,W ; rewind one char in string buffer.
91
92 VARARGS_ALIGN
93 VARARGS_END
94
95 btfsc PRODL,0,A ; Should we print afterward ?
96 return ; NO: then return straight away.
97 goto word_processor ; ELSE: print it...
98
99 ;=============================================================================
100
101 start_small_block:
102 clrf WREG,A
103 movff WREG, win_font ; Need a bank-safe move here !
104 movff WREG, win_invert
105 bra start_common
106
107 start_small_invert_block:
108 clrf WREG,A
109 movff WREG, win_font ; Need a bank-safe move here !
110 setf WREG,A
111 movff WREG, win_invert
112 bra start_common
113
114 start_medium_block:
115 movlw 1
116 movff WREG, win_font ; Need a bank-safe move here !
117 clrf WREG,A
118 movff WREG, win_invert
119 bra start_common
120
121 start_medium_invert_block:
122 movlw 1
123 movff WREG, win_font ; Need a bank-safe move here !
124 movff WREG, win_invert
125 bra start_common
126
127 start_large_block:
128 movlw 2
129 movff WREG, win_font ; Need a bank-safe move here !
130 clrf WREG,A
131 movff WREG, win_invert
132 bra start_common
133
134 start_large_invert_block:
135 movlw 2
136 movff WREG, win_font ; Need a bank-safe move here !
137 movlw 1
138 movff WREG, win_invert
139 bra start_common
140
141 start_common:
142 VARARGS_BEGIN
143 VARARGS_GET8 win_leftx2
144 VARARGS_GET8 win_top
145 VARARGS_END
146 return