1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-06-08 21:29:30 +00:00

Updated documentation for module string

This commit is contained in:
Curtis F Kaylor 2021-09-04 18:58:29 -04:00
parent a7864da8f9
commit 1fc3f1cde4
2 changed files with 89 additions and 78 deletions

View File

@ -54,6 +54,7 @@ iabs intlib Integer Absolute Return absolute value of integer.
imax intlib Integer Maximum Return greater of two integers.
imin intlib Integer Minimum Return lesser of two integers.
isalnm ctype Is Alphanumeric Return TRUE if character is A-Z, a-z, or 0-9.
isalnu ctype Is Alphanumunder Return TRUE if character is A-Z, a-z, 0-9, or _.
isalph ctype Is Alphabetic Return TRUE if character is A-Z or a-z.
isbdgt ctype Is Binary Digit Return TRUE if character is 0 or 1.
isctrl ctype is Control Return TRUE if ASCII code is 0-31 or 127.
@ -71,7 +72,7 @@ itoa intlib Integer to ASCII Convert Integer to String.
joystk joystk Joystick Read Atari style joystick controller status.
lgtpen lgtpen Light Pen Read light pen status.
maddr memio Memory Address Return address contained in memory file pointer.
max stdlib Maximum Return greater of two byte.
max stdlib Maximum Return greater of two bytes.
mclose memio Memory Close Close memory file.
memdst memory Memory Destination Set destination array for subsequent functions.
memset memory Memory Set File bytes in array with byte.
@ -160,9 +161,9 @@ strcmp string String Compare Compare string contents against destinat
strcpy string String Copy Copy string contents to destination string.
strcsp stringx String Char Span Return length of span in destination not in string.
strcut string String Cut Copy substring to destination string.
strdst string String Destination Set destination string for subsequent functions.
strlen string String Length Calculate length of string.
strpbk stringx String Pointer Break Find first character in destination found in string.
strppd string String Prepend Prepend character to string.
strrch string String Reverse Char Search for character from end of string.
strspn stringx String Span Return length of span in destination found in string.
strstr string String String Search for string in destination string.

View File

@ -7,10 +7,14 @@ The first character in a string is at position 0, and the last character
is at position length minus 1.
Since all of the routines stop processing at the 128th character, a 128
character string does not require a zero terminator.
character string does not require a zero terminator, and any character
array with length[128] will not overflow.
Due to the limitations of parameter passing in C02, the argument lists of
most of these functions do not match those in standard C and C++.
most of these functions do not match those in standard C and C++.
For functions that operate on two string, one of the strings is specified
using the setdst() function from the stddef module.
Usage: at the beginning of the program use the directives
@ -19,52 +23,34 @@ Usage: at the beginning of the program use the directives
The following functions are defined:
p = strapd(c, &s); Append character c to string s.
Returns length of new string.
If the string length exceeds 127 prior to the
append, no action is taken and the existing
length is returned.
This function is not part of the standard C and
C++ string libraries. It is included because it
is more efficient than the equivalent C02 code.
p = strchr(c, &s); Searches string s for character c.
n = strlen(s); Returns length of string.
Note: Leaves address of s in srcptr.
p = strchr(c, s); Searches string s for character c.
Returns position of first occurance of character
in string, or 255 if character was not found.
n = strlen(&s); Determines length of string s.
Returns length of string.
p = strrch(c, &s); Searches end of string s for character c.
Note: Leaves address of s in srcptr.
p = strrch(c, s); Searches end of string s for character c.
Returns position of last occurance of character
in string, or 255 if character was not found.
strdst(&d); Sets string d as the destination string for subsequent
strcat(). strcmp(), strcpy(), and strstr() calls.
This function is not part of the standard C and
C++ string libraries. It is needed because of the
parameter passing limitations of C02.
Note: Aliased to the setdst() routine which sets
variables dstlo and dsthi as a pointer to the string.
n = strcat(&s); Concatenates source string s onto the end of
destination string set by prior strdst() call.
Note: Leaves address of s in srcptr.
n = strcat(s); Concatenates source string s onto the end of
destination string set by prior setdst() call.
Returns total length of concatenated string.
Note: dstlo and dsthi are left pointing to the
destination string.
Note: leaves the address of destination string
in dstptr.
c = strcmp(&s); Compares source string s against destination
string set by prior strdst() call.
c = strcmp(s); Compares source string s against destination
string set by prior setdst() call.
Returns 255 if destination < source, 0 if
destination = source, and 1 if destination > source.
@ -72,65 +58,89 @@ The following functions are defined:
These results can be evaluated using the C02
unary comparator ! or the test-operators :+ or :-.
Note: dstlo and dsthi are left pointing to the
destination string.
Note: leaves the address of s in srcptr and
the address of the destination string in dstptr.
n = strcpy(&s); Copies wource string s into destination string set
by prior strdst() call, replacing previous contents.
n = strcpy(s); Copies wource string s into destination string set
by prior setdst() call, replacing previous contents.
Returns number of characters copied.
Note: dstlo and dsthi are left pointing to the
destination string.
Note: leaves the address of s in srcptr and
the address of the destination string in dstptr.
To copy the first n characters from string s to
string d, the following code can be used:
strdst(&d); strcpy(&s); s[n]=0;
setdst(&d); strcpy(s); s[n]=0;
n = strcut(n, &s); Copies from source string s, starting at position n,
into destination string set by prior strdst() call,
replacing previous contents.
Returns number of characters copied.
This function is not part of the standard C and
C++ string libraries. It is included because
it is faster and more compact tham the equivalent
C02 code.
To copy a substring starting at position n with
length l from string s to string d, the following
code can be used:
strdst(&d); strcut(&s, n); s[l]=0;
Note: calls routine strcat(). leaving dstlo and
dsthi pointing to the destination string, along
with strlo and strhi pointing to the address of
position n in the source string.
p = strstr(&s); Searches for destination string s in source string
set by prior strdst() call.
p = strstr(s); Searches for destination string s in source string
set by prior setdst() call.
Returns position of source string in destination
string, or 255 if character was not found.
Note: calls routine strcmp(), leaving dstlo and
dsthi pointing to the address of the position of
the source string in the destination string (or
the end of the destination string if the source
string was not found).
Note: calls strcmp(), leaving the address of s
in srcptr and the position of the source string in
the destination string (or the end of the destination
string if the source string was not found) in dstptr.
These functions are not part of the standard C and C++ string libraries.
They are included because they are more efficient than equivalent C02 code.
p = strapd(c, s); Append character c to string s.
Returns length of appended string.
If the string length exceeds 127 prior to the
append, no action is taken and the existing
length is returned.
Note: calls strlen(), leaving the address of
s in srcptr.
strppd(c, s); Prepend character c to string s.
Returns length of prepended string.
If the string length exceeds 127 prior to the
prepend, no action is taken and the existing
length is returned.
Note: calls strlen(), leaving the address of
s in srcptr.
strcpb(s) Copies string s to the system buffer (sysbfr).
Note: calls strcpy(), leaving the address of s
in srcptr and the address of the system buffer
in dstptr.
n = strcut(n, s); Copies from source string s, starting at position n,
into destination string set by prior setdst() call,
replacing previous contents.
Returns number of characters copied.
To copy a substring starting at position n with
length i from string s to string d, the following
code can be used:
setdst(&d); strcut(s, n); s[i] = 0;
Note: calls routine strcat(), leaving the address
of the destination string in dstptr and address of
position n in the source string in srcptr.
Note: This library expects the following functions to be defined
setdst(&s); Set destination string pointer
setsrc(&s); Set source string pointer and initialize index
setdst(s); Set destination pointer
setsrc(s); Set source pointer and initialize index
along with the zero page variable pairs
strlo, strhi Source String Pointer
dstlo, dsthi Destination String Pointer
srcptr Source String Pointer
dstptr Destination String Pointer
as well as the transient variables