comparison code_part1/OSTC_code_asm_part1/strings.inc @ 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.inc
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 ; RATIONALS for STRCAT / STRCPY / STRCAT_PRINT / STRCPY_PRINT:
26 ; * Gain PROM space: each time a string operation is done, we have a bunch
27 ; of lines in the style:
28 ; movlw '+'
29 ; movwf POSTINC2
30 ; movlw '/'
31 ; movwf POSTINC2
32 ; movlw '-'
33 ; movwf POSTINC2
34 ; movlw ':'
35 ; movwf POSTINC2
36 ; call word_processor
37 ; which takes 20 bytes of PROM space (eg. 4 + chars/4). Whereas :
38 ; STRCAT_PRINT "+/-:"
39 ; takes just 10 bytes (4 + chars + 1, even rounded up).
40 ;
41 ; Note that the other common sequence :
42 ; OUTPUTTEXT .113
43 ; does compile in (6 bytes per call), plus (1 + chars, even rouded up)
44 ; once it the whole code. Also, it is slower to execute, because it have
45 ; to roll through the string table.
46 ;
47 ; RATIONALS for a formating variant... not yet done...
48 ; * Embeding formatting commands into the string allows even mode compact
49 ; sequence.
50 ; Possible commandes:
51 ; \xF0 output_8 ; arg in hi, and move lo to hi,
52 ; \xF1 output_9 ; so we can have two 8bits concertion
53 ; \xF2 output_99 ; in a single sequence...
54 ; \xF3 output_99x
55 ; \xF4 output_16 ; arg in hi:lo
56 ; \xF5 output_16dp 1
57 ; \xF6 output_16dp 2
58 ; \xF7 output_16dp 3
59 ; ....
60 ; Usage:
61 ; movff apnoe_min, hi
62 ; movff apnoe_sec, lo
63 ; FORMAT_PRINT "Time: \xF3:\xF3"
64 ;
65 ; * Cons: code redeability is poor: reader have to remember exactly what
66 ; each cryptic hexa code is doing...
67 ; No-macro-syntax:
68 ; call format_print_block
69 ; DB "Time: ", FORMAT_99x, ':', FORMAT_99x, 0
70 ; is denitively more secure in that respect...
71
72 ;=============================================================================
73 ; Copy a short embebed string at start of the string buffer (letter)
74 ; Input: (nothing)
75 ; Output: chars are copied into letter, starting at the beginning.
76 ; FSR2 point to the first unused char (the NULL termination).
77 ;
78 ; Trashed: WREG, TBLPTR, TABLAT, PRODL
79 ; Note: This are all bank-safe call.
80 ;
81 STRCPY macro string
82 call strcpy_block
83 DB string, 0
84 endm
85
86 ;=============================================================================
87 ; A variant of STRCPY that appends chars to the current FSR2 pointer.
88 ; Input/Output/Trashed : see STRCPY.
89 STRCAT macro string
90 call strcat_block
91 DB string, 0
92 endm
93
94 ;=============================================================================
95 ; A variant of STRCPY that send the string to the word processor afterwards.
96 ; Input/Output: see STRCPY.
97 ; Trashed: See STRCPY + word_processor. In particular, switch RAM to Bank1
98 ;
99 STRCPY_PRINT macro string
100 call strcpy_block_print
101 DB string, 0
102 endm
103
104 ; Trashed: See STRCPY + word_processor. In particular, switch RAM to Bank1
105 STRCAT_PRINT macro string
106 call strcat_block_print
107 DB string, 0
108 endm
109
110 ;=============================================================================
111 ; A shortcut for the macros WIN_TOP + WIN_LEFT + WIN_FONT + WIN_INVERT.
112 ; The idea is to replace a 4x6=24 bytes sequence by a more compact 6bytes one.
113 ;
114 ; Trashed: TBLPTR, TABLAT, WREG.
115 ; Note: This are all bank-safe call.
116
117 WIN_SMALL macro x, y
118 call start_small_block
119 DB x, y
120 endm
121
122 WIN_SMALL_INVERT macro x, y
123 call start_small_invert_block
124 DB x, y
125 endm
126
127 WIN_MEDIUM macro x, y
128 call start_medium_block
129 DB x, y
130 endm
131
132 WIN_MEDIUM_INVERT macro x, y
133 call start_medium_invert_block
134 DB x, y
135 endm
136
137 WIN_LARGE macro x, y
138 call start_large_block
139 DB x, y
140 endm
141
142 WIN_LARGE_INVERT macro x, y
143 call start_large_invert_block
144 DB x, y
145 endm