Initial revision
[ssr] / StraySrc / Libraries / BAS / src / sh / string
1 ;
2 ; string.sh
3 ;
4 ; String handling routines (control terminated)
5 ;
6 ; © 1994-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's BASIC Assembler Supplement.
12 ;
13 ; BAS is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
16 ; any later version.
17 ;
18 ; BAS is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
22 ;
23 ; You should have received a copy of the GNU General Public License
24 ; along with BAS. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 ;----- Overview -------------------------------------------------------------
28 ;
29 ; Functions provided:
30 ;
31 ; str_cpy
32 ; str_len
33 ; str_cmp
34 ; str_icmp
35 ; str_subst
36 ; str_error
37 ; str_buffer
38
39 ; --- str_cpy ---
40 ;
41 ; On entry: R0 == destination string
42 ; R1 == source string
43 ;
44 ; On exit: R0 == pointer to terminator of destination
45 ;
46 ; Use: Copies a string from one block to another. It leaves the
47 ; destination pointer at the end of the string so that any
48 ; subsequent copies concatenate other bits on the same string.
49 ; Single characters can of course be appended with
50 ;
51 ; MOV Rx,#&cc
52 ; STRB Rx,[R0],#1
53
54 IMPORT str_cpy
55
56 ; --- str_len ---
57 ;
58 ; On entry: R0 == pointer to string
59 ;
60 ; On exit: R0 == length of the string
61 ;
62 ; Use: Calculates the length of a string.
63
64 IMPORT str_len
65
66 ; --- str_cmp ---
67 ;
68 ; On entry: R0 == pointer to string A
69 ; R1 == pointer to string B
70 ;
71 ; On exit: Flags as appropriate
72 ;
73 ; Use: Case-sensitively compares two strings. You can use the
74 ; normal ARM condition codes after the compare, so you can
75 ; treat this fairly much like a normal CMP.
76
77 IMPORT str_cmp
78
79 ; --- str_icmp ---
80 ;
81 ; On entry: R0 == pointer to string A
82 ; R1 == pointer to string B
83 ;
84 ; On exit: Flags as appropriate
85 ;
86 ; Use: As for str_cmp above, but case-insensitive.
87
88 IMPORT str_icmp
89
90 ; --- str_subst ---
91 ;
92 ; On entry: R0 == Pointer to skeleton
93 ; R1 == Pointer to output buffer
94 ; R2-R11 == Pointer to filler strings (optional)
95 ;
96 ; On exit: R0 == Pointer to start of buffer
97 ; R1 == Pointer to terminating null
98 ;
99 ; Use: Performs string substitution, filling in a skeleton string
100 ; containing placeholders with `filler' strings. The
101 ; placeholders are actually rather powerful. The syntax of
102 ; these is as follows:
103 ;
104 ; `%' [<type>] <digit>
105 ;
106 ; (spaces are for clarity -- in fact you must not include
107 ; spaces in the format string.)
108 ;
109 ; <digit> is any charater between `0' and `9'. It refers to
110 ; registers R2-R11 (so `0' means R2, `5' is R7 etc.) How the
111 ; value is interpreted is determined by <type>.
112 ;
113 ; <type> is one of:
114 ;
115 ; s String. This is the default. The register is
116 ; considered to be a pointer to an ASCII string
117 ; (control terminated).
118 ;
119 ; i Integer. The (signed) decimal representation is
120 ; inserted. Leading zeros are suppressed.
121 ;
122 ; x Hex fullword. The hexadecimal representation of the
123 ; register is inserted. Leading zeros are included.
124 ;
125 ; b Hex byte. The hexadecimal representation of the
126 ; least significant byte is inserted. Leading zeros
127 ; are included.
128 ;
129 ; c Character. The ASCII character corresponding to the
130 ; least significant byte is inserted.
131
132 IMPORT str_subst
133
134 ; --- str_error ---
135 ;
136 ; On entry: R0 == Pointer to skeleton
137 ; R2-R11 == Pointers to fillin strings
138 ;
139 ; On exit: R0 == Pointer to error in buffer
140 ; R1 == Pointer to terminator
141 ;
142 ; Use: Fills in an error skeleton (containing a 4 byte error number
143 ; and a control terminated skeleton string as for str_subst)
144 ; and returns the address of the filled in error block. The
145 ; error block is stored in a buffer obtained from str_buffer.
146 ;
147 ; Filler strings may be held in the scratchpad.
148
149 IMPORT str_error
150
151 ; ---- str_buffer ---
152 ;
153 ; On entry: --
154 ;
155 ; On exit: R1 == pointer to the next free buffer
156 ;
157 ; Use: Returns a pointer to a 256-byte buffer. There are at present
158 ; 2 buffers, which are returned alternately.
159
160 IMPORT str_buffer
161
162 ;----- That's all, folks ----------------------------------------------------
163
164 END