chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Sapphire / csapph / h / string
1 /*
2  * string.h
3  *
4  * [Generated from string, 25 September 1996]
5  */
6
7 #if !defined(__CC_NORCROFT) || !defined(__arm)
8   #error You must use the Norcroft ARM Compiler for Sapphire programs
9 #endif
10
11 #pragma include_only_once
12 #pragma force_top_level
13
14 #ifndef __string_h
15 #define __string_h
16
17 #ifndef __sapphire_h
18   #include "sapphire.h"
19 #endif
20
21 /*----- Overview ----------------------------------------------------------*
22  *
23  * Functions provided:
24  *
25  *  str_cpy
26  *  str_len
27  *  str_cmp
28  *  str_icmp
29  *  str_index
30  *  str_match
31  *  str_subst
32  *  str_error
33  *  str_buffer
34  */
35
36 /* --- str_cpy --- *
37  *
38  * On entry:    R0 == destination string
39  *              R1 == source string
40  *
41  * On exit:     R0 == pointer to terminator of destination
42  *
43  * Use:         Copies a string from one block to another.  It leaves the
44  *              destination pointer at the end of the string so that any
45  *              subsequent copies concatenate other bits on the same string.
46  *              Single characters can of course be appended with
47  *
48  *                      MOV     Rx,#&cc
49  *                      STRB    Rx,[R0],#1
50  */
51
52 extern routine str_cpy;
53
54 /* --- str_len --- *
55  *
56  * On entry:    R0 == pointer to string
57  *
58  * On exit:     R0 == length of the string
59  *
60  * Use:         Calculates the length of a string.
61  */
62
63 extern routine str_len;
64
65 /* --- str_cmp --- *
66  *
67  * On entry:    R0 == pointer to string A
68  *              R1 == pointer to string B
69  *
70  * On exit:     Flags as appropriate
71  *
72  * Use:         Case-sensitively compares two strings.  You can use the
73  *              normal ARM condition codes after the compare, so you can
74  *              treat this fairly much like a normal CMP.
75  */
76
77 extern routine 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
89 extern routine str_icmp;
90
91 /* --- str_index --- *
92  *
93  * On entry:    R0 == pointer to name table
94  *              R1 == index into name table
95  *
96  * On exit:     CS if index good, and
97  *                R0 == address of R0th string in table
98  *              else CC and
99  *                R0 corrupted
100  *
101  * Use:         Finds an indexed string in a table.  The table consists of
102  *              ctrl-terminated strings, with no separation.  The table is
103  *              terminated by a zero-length entry.
104  */
105
106 extern routine str_index;
107
108 /* --- str_find --- *
109  *
110  * On entry:    R0 == pointer to name table
111  *              R1 == string to match in table
112  *
113  * On exit:     CS if match found, and
114  *                R0 == index of string matched
115  *              else CC and
116  *                R0 corrupted
117  *
118  * Use:         Looks up a string in a table.  The table consists of
119  *              ctrl-terminated strings, with no separation.  The table is
120  *              terminated by a zero-length entry.
121  */
122
123 extern routine str_match;
124
125 /* --- str_subst --- *
126  *
127  * On entry:    R0 == Pointer to skeleton
128  *              R1 == Pointer to output buffer
129  *              R2-R11 == Pointer to filler strings (optional)
130  *
131  * On exit:     R0 == Pointer to start of buffer
132  *              R1 == Pointer to terminating null
133  *
134  * Use:         Performs string substitution, filling in a skeleton string
135  *              containing placeholders with `filler' strings.  The
136  *              placeholders are actually rather powerful.  The syntax of
137  *              these is as follows:
138  *
139  *                      `%' [<type>] <digit>
140  *
141  *              (spaces are for clarity -- in fact you must not include
142  *              spaces in the format string.)
143  *
144  *              <digit> is any charater between `0' and `9'.  It refers to
145  *              registers R2-R11 (so `0' means R2, `5' is R7 etc.)  How the
146  *              value is interpreted is determined by <type>.
147  *
148  *              <type> is one of:
149  *
150  *              s       String.  This is the default.  The register is
151  *                      considered to be a pointer to an ASCII string
152  *                      (control terminated).
153  *
154  *              i       Integer.  The (signed) decimal representation is
155  *                      inserted.  Leading zeros are suppressed.
156  *
157  *              x       Hex fullword.  The hexadecimal representation of the
158  *                      register is inserted.  Leading zeros are included.
159  *
160  *              b       Hex byte.  The hexadecimal representation of the
161  *                      least significant byte is inserted.  Leading zeros
162  *                      are included.
163  *
164  *              c       Character.  The ASCII character corresponding to the
165  *                      least significant byte is inserted.
166  */
167
168 extern routine str_subst;
169
170 /* --- str_error --- *
171  *
172  * On entry:    R0 == Pointer to skeleton
173  *              R2-R11 == Pointers to fillin strings
174  *
175  * On exit:     R0 == Pointer to error in buffer
176  *              R1 == Pointer to terminator
177  *
178  * Use:         Fills in an error skeleton (containing a 4 byte error number
179  *              and a control terminated skeleton string as for str_subst)
180  *              and returns the address of the filled in error block.  The
181  *              error block is stored in a buffer obtained from str_buffer.
182  *
183  *              Filler strings may be held in the scratchpad.
184  */
185
186 extern routine str_error;
187
188 /* --- str_buffer --- *
189  *
190  * On entry:    --
191  *
192  * On exit:     R1 == pointer to the next free buffer
193  *
194  * Use:         Returns a pointer to a 256-byte buffer.  There are at present
195  *              2 buffers, which are returned alternately.
196  */
197
198 extern routine str_buffer;
199
200 /*----- That's all, folks -------------------------------------------------*/
201
202 #endif