; ; string.sh ; ; String handling routines (control terminated) ; ; © 1994-1998 Straylight ; ;----- Licensing note ------------------------------------------------------- ; ; This file is part of Straylight's Quartz library. ; ; Quartz is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2, or (at your option) ; any later version. ; ; Quartz is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with Quartz. If not, write to the Free Software Foundation, ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;----- Overview ------------------------------------------------------------- ; ; Functions provided: ; ; str_cpy ; str_len ; str_cmp ; str_icmp ; str_subst ; str_error ; ; Notes: ; ; All strings written by these routines are output as NULL-terminated, ; regardless of the original terminator. ; --- str_cpy --- ; ; On entry: R0 == destination string ; R1 == source string ; ; On exit: R0 == pointer to terminator of destination ; ; Use: Copies a string from one block to another. It leaves the ; destination pointer at the end of the string so that any ; subsequent copies concatenate other bits on the same string. ; Single characters can of course be appended with ; ; MOV Rx,#&cc ; STRB Rx,[R0],#1 IMPORT str_cpy ; --- str_len --- ; ; On entry: R0 == pointer to string ; ; On exit: R0 == length of the string ; ; Use: Calculates the length of a string. IMPORT str_len ; --- str_cmp --- ; ; On entry: R0 == pointer to string A ; R1 == pointer to string B ; ; On exit: Flags as appropriate ; ; Use: Case-sensitively compares two strings. You can use the ; normal ARM conditio codes after the compare, so you can treat ; this as a normal CMP type thing (except the arguments must ; be in R0 and R1, and it mangles R14). IMPORT str_cmp ; --- str_icmp --- ; ; On entry: R0 == pointer to string A ; R1 == pointer to string B ; ; On exit: Flags as appropriate ; ; Use: As for str_cmp above, but case-insensitive. IMPORT str_icmp ; --- str_subst --- ; ; On entry: R0 == Pointer to skeleton ; R1 == Pointer to output buffer ; R2-R11 == Pointer to filler strings (optional) ; ; On exit: R0 == Pointer to start of buffer ; R1 == Pointer to terminating null ; ; Use: Performs string substitution, filling in a skeleton string ; containing placeholders with `filler' strings. The ; placeholders are actually rather powerful. The syntax of ; these is as follows: ; ; `%' [] ; ; (spaces are for clarity -- in fact you must not include ; spaces in the format string.) ; ; is any charater between `0' and `9'. It refers to ; registers R2-R11 (so `0' means R2, `5' is R7 etc.) How the ; value is interpreted is determined by . ; ; is one of: ; ; s String. This is the default. The register is ; considered to be a pointer to an ASCII string ; (control terminated). ; ; i Integer. The (signed) decimal representation is ; inserted. Leading zeros are suppressed. ; ; x Hex fullword. The hexadecimal representation of the ; register is inserted. Leading zeros are included. ; ; b Hex byte. The hexadecimal representation of the ; least significant byte is inserted. Leading zeros ; are included. ; ; c Character. The ASCII character corresponding to the ; least significant byte is inserted. IMPORT str_subst ; --- str_error --- ; ; On entry: R0 == Pointer to skeleton ; R2-R11 == Pointers to fillin strings ; ; On exit: R0 == Pointer to error in buffer ; R1 == Pointer to terminator ; ; Use: Fills in an error skeleton (like a substitution skeleton in ; str_subst above with an error number on the front) and ; returns a pointer to it. The buffer used is found by calling ; str_buffer (see below), so you can safely use the result of ; one call as a filler string for the next. ; ; Filler strings may be held in the scratchpad. IMPORT str_error ; ---- str_buffer --- ; ; On entry: -- ; ; On exit: R1 == pointer to the next free buffer ; ; Use: Returns a pointer to a 256-byte buffer. There are at present ; 2 buffers, which are returned alternately. IMPORT str_buffer ;----- That's all folks ----------------------------------------------------- END