|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
#include "blitzlib.h"Functions | |
| void | leftstring (void) |
| void | rightstring (void) |
| void | midstring (void) |
| void | midstring2 (void) |
| void | hexstring (void) |
| void | binstring (void) |
| void | chrstring (void) |
| Chr$(Expression) - a string of one character. | |
| void | ascii (void) |
| void | stringstr (void) |
| void | instrstring (void) |
| void | instrstring2 (void) |
| void | replace (void) |
| void | mkistring (void) |
| void | mklstring (void) |
| void | cvistring (void) |
| void | cvlstring (void) |
| void | lenstring (void) |
| Len(String$) - the length of the string. | |
| void | unleftstring (void) |
| void | unrightstring (void) |
| void | striplead (void) |
| void | striptrail (void) |
| void | lsetstring (void) |
| void | rsetstring (void) |
| void | centrestring (void) |
| void | lcasestring (void) |
| void | ucasestring (void) |
| void | casesensestring (void) |
| void | stringfunclib_codeinit (void) |
| void | movestring (void) |
| void | cvichk (void) |
| void | cvlchk (void) |
| void | cvqchk (void) |
| void | instrchk (void) |
| static ULONG | movestr (const UBYTE **src, ULONG len) |
| static ULONG | movelong (const UBYTE *src, ULONG len) |
| BL_ALWAYS_INLINE ULONG | movecut (const UBYTE *src, ULONG len) |
| static UBYTE | upcase (UBYTE c) |
| static ULONG | movestring_c (const UBYTE *src, ULONG len) |
| static ULONG | codeinit_c (void) |
| static void | casesensestring_c (UWORD on) |
| CaseSense On|Off - case sensitive or insensitive Instr and Replace$. | |
| BLITZ_ALIAS (casesensestring, casesensestring_c) | |
| static ULONG | striptrail_c (UBYTE *s, UWORD ch, const ULONG *lens) |
| StripTrail$(String$,Ascii) - the string without the trailing characters Ascii. | |
| BLITZ_ALIAS (striptrail, striptrail_c) | |
| BL_ALWAYS_INLINE ULONG | left (UBYTE *s, LONG n, const ULONG *sp) |
| static ULONG | leftstring_c (UBYTE *s, LONG n, const ULONG *lens) |
| Left$(String$,Length) - the first Length characters. | |
| BLITZ_ALIAS (leftstring, leftstring_c) | |
| static ULONG | unleftstring_c (UBYTE *s, LONG n, const ULONG *lens) |
| UnLeft$(String$,Length) - the string without its last Length characters. | |
| BLITZ_ALIAS (unleftstring, unleftstring_c) | |
| static ULONG | lsetstring_c (UBYTE *s, LONG n, const ULONG *lens) |
| LSet$(String$,Characters) - the string left justified in Characters characters. | |
| BLITZ_ALIAS (lsetstring, lsetstring_c) | |
| static ULONG | rsetstring_c (UBYTE *s, LONG n, const ULONG *lens) |
| RSet$(String$,Characters) - the string right justified in Characters characters. | |
| BLITZ_ALIAS (rsetstring, rsetstring_c) | |
| static ULONG | centrestring_c (UBYTE *s, LONG n, const ULONG *lens) |
| Centre$(String$,Characters) - the string centred in Characters characters. | |
| BLITZ_ALIAS (centrestring, centrestring_c) | |
| static ULONG | lcasestring_c (UBYTE *s, const ULONG *lens) |
| LCase$(String$) - the string in lower case ('A'..'Z' only). | |
| BLITZ_ALIAS (lcasestring, lcasestring_c) | |
| static BLITZ_ENTRYPOINT ULONG | ucasestring_c (UBYTE *s, const ULONG *lens) |
| UCase$(String$) - the string in upper case ('a'..'z' only). | |
| BLITZ_ALIAS_EP (ucasestring, ucasestring_c) | |
| static ULONG | striplead_c (UBYTE *s, UWORD ch, const ULONG *lens) |
| StripLead$(String$,Ascii) - the string without the leading characters Ascii. | |
| BLITZ_ALIAS (striplead, striplead_c) | |
| BL_ALWAYS_INLINE ULONG | right (UBYTE *s, LONG n, const ULONG *sp) |
| static BLITZ_ENTRYPOINT ULONG | rightstring_c (UBYTE *s, LONG n, const ULONG *lens) |
| Right$(String$,Length) - the last Length characters. | |
| BLITZ_ALIAS_EP (rightstring, rightstring_c) | |
| static BLITZ_ENTRYPOINT ULONG | unrightstring_c (UBYTE *s, LONG n, const ULONG *lens) |
| UnRight$(String$,Length) - the string without its first Length characters. | |
| BLITZ_ALIAS_EP (unrightstring, unrightstring_c) | |
| BL_ALWAYS_INLINE ULONG | mid (UBYTE *s, LONG start, LONG n, const ULONG *sp) |
| static BLITZ_ENTRYPOINT ULONG | midstring_c (UBYTE *s, LONG start, LONG n, const ULONG *lens) |
| Mid$(String$,Startchar,Length) - Length characters from Startchar (1 = the first). | |
| BLITZ_ALIAS_EP (midstring, midstring_c) | |
| static BLITZ_ENTRYPOINT ULONG | midstring2_c (UBYTE *s, LONG start, const ULONG *lens) |
| Mid$(String$,Startchar) - the rest of the string from Startchar. | |
| BLITZ_ALIAS_EP (midstring2, midstring2_c) | |
| static BLITZ_ENTRYPOINT ULONG | binstring_c (ULONG v) |
| Bin$(Expression) - the value as 32 binary digits. | |
| BLITZ_ALIAS_EP (binstring, binstring_c) | |
| static BLITZ_ENTRYPOINT ULONG | hexstring_c (ULONG v) |
| Hex$(Expression) - the value as 8 hexadecimal digits. | |
| BLITZ_ALIAS_EP (hexstring, hexstring_c) | |
| static ULONG | stringstr_c (UBYTE *s, LONG count, const ULONG *lens) |
| String$(String$,Repeats) - Repeats copies of the string. | |
| BLITZ_ALIAS (stringstr, stringstr_c) | |
| static ULONG | ascii_c (UBYTE *s, const ULONG *lens) |
| Asc(String$) - the code of the first character. | |
| BLITZ_ALIAS (ascii, ascii_c) | |
| BL_ALWAYS_INLINE ULONG | instr (UBYTE *s, const UBYTE *f, LONG start, const ULONG *sp) |
| static BLITZ_ENTRYPOINT ULONG | instrstring_c (UBYTE *s, const UBYTE *f, const ULONG *lens) |
| Instr(String$,Findstring$) - the position of Findstring$ in String$. | |
| BLITZ_ALIAS_EP (instrstring, instrstring_c) | |
| static BLITZ_ENTRYPOINT ULONG | instrstring2_c (UBYTE *s, const UBYTE *f, LONG start, const ULONG *lens) |
| Instr(String$,Findstring$,Startpos) - the position of Findstring$ in String$, searching from Startpos. | |
| BLITZ_ALIAS_EP (instrstring2, instrstring2_c) | |
| static ULONG | replace_c (UBYTE *s, const UBYTE *f, const UBYTE *r, const ULONG *lens) |
| Replace$(String$,Findstring$,Replacestring$) - String$ with every Findstring$ replaced by Replacestring$. | |
| BLITZ_ALIAS (replace, replace_c) | |
| static ULONG | mkistring_c (ULONG v) |
| Mki$(Integer) - the low word as a 2 byte string (big endian). | |
| BLITZ_ALIAS (mkistring, mkistring_c) | |
| static ULONG | mklstring_c (ULONG v) |
| Mkl$(Long), Mkq$(Quick) - the value as a 4 byte string (big endian). | |
| BLITZ_ALIAS (mklstring, mklstring_c) | |
| BL_ALWAYS_INLINE ULONG | cvbytes (const UBYTE *s, ULONG len, ULONG n, ULONG v) |
| static BLITZ_ENTRYPOINT ULONG | cvistring_c (const UBYTE *s, const ULONG *lens) |
| Cvi(String$) - the first 2 bytes of the string as a word. | |
| BLITZ_ALIAS_EP (cvistring, cvistring_c) | |
| static BLITZ_ENTRYPOINT ULONG | cvlstring_c (const UBYTE *s, const ULONG *lens) |
| Cvl(String$), Cvq(String$) - the first 4 bytes of the string as a long (Cvq: as a Quick). | |
| BLITZ_ALIAS_EP (cvlstring, cvlstring_c) | |
| static void | cvichk_c (const ULONG *lens) |
| static void | cvlchk_c (const ULONG *lens) |
| static void | cvqchk_c (const ULONG *lens) |
| static void | instrchk_c (LONG start) |
Variables | |
| static UWORD | csense |
| void ascii | ( | void | ) |
|
static |
Asc(String$) - the code of the first character.
a3 = d0$; the empty string leaves a3 unchanged.
| s | d0: the string |
| lens | a2: the length stack (the string's length) |
| void binstring | ( | void | ) |
|
static |
Bin$(Expression) - the value as 32 binary digits.
From bit 31 down, written at a3. The original writes a digit per bit (LSL.l #1,d0:ADDX d3,d1, 36 cycles); here a rotate by 4 brings four bits into the low nibble and a table of the 16 groups of four digits (PC relative) gives their characters, copied by bytes (a3 may be odd): the same text.
| v | d0: the value |
| BLITZ_ALIAS | ( | casesensestring | , |
| casesensestring_c | ) |
| BLITZ_ALIAS | ( | centrestring | , |
| centrestring_c | ) |
| BLITZ_ALIAS | ( | lcasestring | , |
| lcasestring_c | ) |
| BLITZ_ALIAS | ( | leftstring | , |
| leftstring_c | ) |
| BLITZ_ALIAS | ( | lsetstring | , |
| lsetstring_c | ) |
| BLITZ_ALIAS | ( | mkistring | , |
| mkistring_c | ) |
| BLITZ_ALIAS | ( | mklstring | , |
| mklstring_c | ) |
| BLITZ_ALIAS | ( | rsetstring | , |
| rsetstring_c | ) |
| BLITZ_ALIAS | ( | stringstr | , |
| stringstr_c | ) |
| BLITZ_ALIAS | ( | striplead | , |
| striplead_c | ) |
| BLITZ_ALIAS | ( | striptrail | , |
| striptrail_c | ) |
| BLITZ_ALIAS | ( | unleftstring | , |
| unleftstring_c | ) |
| BLITZ_ALIAS_EP | ( | binstring | , |
| binstring_c | ) |
| BLITZ_ALIAS_EP | ( | cvistring | , |
| cvistring_c | ) |
| BLITZ_ALIAS_EP | ( | cvlstring | , |
| cvlstring_c | ) |
| BLITZ_ALIAS_EP | ( | hexstring | , |
| hexstring_c | ) |
| BLITZ_ALIAS_EP | ( | instrstring | , |
| instrstring_c | ) |
| BLITZ_ALIAS_EP | ( | instrstring2 | , |
| instrstring2_c | ) |
| BLITZ_ALIAS_EP | ( | midstring | , |
| midstring_c | ) |
| BLITZ_ALIAS_EP | ( | midstring2 | , |
| midstring2_c | ) |
| BLITZ_ALIAS_EP | ( | rightstring | , |
| rightstring_c | ) |
| BLITZ_ALIAS_EP | ( | ucasestring | , |
| ucasestring_c | ) |
| BLITZ_ALIAS_EP | ( | unrightstring | , |
| unrightstring_c | ) |
| void casesensestring | ( | void | ) |
|
static |
CaseSense On|Off - case sensitive or insensitive Instr and Replace$.
MOVE d0,csense:RTS. The init sets On (-1). Keeps all registers.
| on | d0.w: 0 (Off) = 'a'..'z' compare as upper case, else On |
| void centrestring | ( | void | ) |
|
static |
Centre$(String$,Characters) - the string centred in Characters characters.
End of the moved characters: s + d1/2 + len/2 (+1 if both d1 and len are odd: the LSR #1 of d1&len sets the carry, SCS/EXT/SUBA); spaces: (d1-len)/2 in front (written backwards), the rest behind. A longer string keeps the middle d1 characters: s + len/2 - d1/2 (LSR.l). A negative width counts as 0.
| s | d0: the string |
| n | d1: the width |
| lens | a2: the length stack (the string's length) |
| void chrstring | ( | void | ) |
Chr$(Expression) - a string of one character.
Inline code (copied into the program): MOVE.b d0,(a3)+:MOVEQ #1,d0. Parameter d0.w: the character code (low byte). Result d0: 1, the length; a3 behind the character.
|
static |
| BL_ALWAYS_INLINE ULONG cvbytes | ( | const UBYTE * | s, |
| ULONG | len, | ||
| ULONG | n, | ||
| ULONG | v ) |
| void cvichk | ( | void | ) |
|
static |
| void cvistring | ( | void | ) |
|
static |
Cvi(String$) - the first 2 bytes of the string as a word.
a3 = d0$. Cvi leaves the upper word of the string address in the upper word of d0 (MOVE.b/LSL #8 on the low word only; Cvi is a word function). DIFF: the original does not pop the length (a2 unchanged, unlike the other string functions); the C version is BLITZ_ENTRYPOINT and may change a2, as the other entrypoints (the compiler does not read a2 after the call; same result).
Fixed (#288): only the string's own bytes are read, the missing ones of a shorter string are 0 (the original read 2 bytes whatever the length: the terminating 0 and the bytes behind it). Errors (debugger, cvichk): "Cvi needs a String of at least 2 Characters" (#288: the original had no check).
| s | d0: the string |
| lens | a2: the length stack (the string's length) |
| void cvlchk | ( | void | ) |
|
static |
| void cvlstring | ( | void | ) |
|
static |
Cvl(String$), Cvq(String$) - the first 4 bytes of the string as a long (Cvq: as a Quick).
a3 = d0$. DIFF: the length is not popped, as in Cvi.
Fixed (#288): only the string's own bytes are read, the missing ones of a shorter string are 0 (the original read 4 bytes whatever the length). Errors (debugger, cvlchk/cvqchk): "Cvl needs a String of at least 4 Characters", "Cvq needs ..." (#288: the original had no check).
| s | d0: the string |
| lens | a2: the length stack (the string's length) |
| void cvqchk | ( | void | ) |
|
static |
| void hexstring | ( | void | ) |
|
static |
Hex$(Expression) - the value as 8 hexadecimal digits.
Upper case, written at a3. The original takes each digit with four LSL.l/ROXL.w pairs and adds "0" (and 7 above "9"); here a rotate by 4 brings it into the low nibble and a table of the 16 digits (PC relative) gives the character: the same text.
| v | d0: the value |
| BL_ALWAYS_INLINE ULONG instr | ( | UBYTE * | s, |
| const UBYTE * | f, | ||
| LONG | start, | ||
| const ULONG * | sp ) |
| void instrchk | ( | void | ) |
|
static |
| void instrstring | ( | void | ) |
| void instrstring2 | ( | void | ) |
|
static |
Instr(String$,Findstring$,Startpos) - the position of Findstring$ in String$, searching from Startpos.
d4 = Startpos-2 in the original; CaseSense Off compares 'a'..'z' as upper case. a3 = String$.
Fixed (#287): Startpos <= 0 counts as 1, the first character (the original compared before the string: Instr(s$,"",0) = 0, Instr(s$,"",-5) = -5). Errors (debugger, instrchk): "Instr Startpos MUST be greater than zero" (#287: the original had no check).
| s | d0: the string to search in |
| f | d1: the string to find |
| start | d2: the 1-based start position |
| lens | a2: the length stack (String$'s length on top, then Findstring$'s) |
|
static |
Instr(String$,Findstring$) - the position of Findstring$ in String$.
Searches from the first character (d4 = -1 in the original); CaseSense Off compares 'a'..'z' as upper case. a3 = String$.
| s | d0: the string to search in |
| f | d1: the string to find |
| lens | a2: the length stack (String$'s length on top, then Findstring$'s) |
| void lcasestring | ( | void | ) |
|
static |
LCase$(String$) - the string in lower case ('A'..'Z' only).
In place. An empty string leaves a3 at its entry value (MOVE.l -(a2),d1:BEQ 'done before MOVE.l d0,a3).
| s | d0: the string |
| lens | a2: the length stack (the string's length) |
| BL_ALWAYS_INLINE ULONG left | ( | UBYTE * | s, |
| LONG | n, | ||
| const ULONG * | sp ) |
| void leftstring | ( | void | ) |
|
static |
Left$(String$,Length) - the first Length characters.
In place. A negative length counts as 0 ("simon was here"); a length beyond the string gives the whole string.
| s | d0: the string |
| n | d1: the length |
| lens | a2: the length stack (the string's length) |
| void lenstring | ( | void | ) |
Len(String$) - the length of the string.
Inline code (copied into the program): MOVE.l d0,a3:MOVE.l -(a2),d0 - pops the length (a2 changes, unlike the C routines). Parameter d0: the string; a2: the length stack. Result d0: the length; a3 = the string.
| void lsetstring | ( | void | ) |
|
static |
LSet$(String$,Characters) - the string left justified in Characters characters.
Pads with spaces from the end of the argument (-1(a3)) or cuts. The length is d1 (negative: 0). For d1 = Len(d0$) a3 is left at its entry value - 1 (not a bug: the compiler always leaves a3 one past the argument's 0, so that is the right end).
| s | d0: the string |
| n | d1: the width |
| lens | a2: the length stack (the string's length) |
| BL_ALWAYS_INLINE ULONG mid | ( | UBYTE * | s, |
| LONG | start, | ||
| LONG | n, | ||
| const ULONG * | sp ) |
| void midstring | ( | void | ) |
| void midstring2 | ( | void | ) |
|
static |
Mid$(String$,Startchar) - the rest of the string from Startchar.
Mid$ with the length Len(d0$)-d1+1 (read from -4(a2)).
Fixed (#286): see Mid$ with three arguments.
| s | d0: the string |
| start | d1: the first character (1-based) |
| lens | a2: the length stack (the string's length) |
|
static |
Mid$(String$,Startchar,Length) - Length characters from Startchar (1 = the first).
First position = 0 after SUBQ.l #1,d1, then negative start/length count as 0. Start beyond the end: empty; the length is cut at the end.
Fixed (#286): the length is cut at the end also when start-1+length exceeds $7FFFFFFF (the original compared the sum signed and copied length bytes).
| s | d0: the string |
| start | d1: the first character (1-based) |
| n | d2: the length |
| lens | a2: the length stack (the string's length) |
| void mkistring | ( | void | ) |
|
static |
Mki$(Integer) - the low word as a 2 byte string (big endian).
| v | d0: the value |
| void mklstring | ( | void | ) |
|
static |
Mkl$(Long), Mkq$(Quick) - the value as a 4 byte string (big endian).
| v | d0: the value |
| BL_ALWAYS_INLINE ULONG movecut | ( | const UBYTE * | src, |
| ULONG | len ) |
|
static |
|
inlinestatic |
| void movestring | ( | void | ) |
|
static |
| void replace | ( | void | ) |
|
static |
Replace$(String$,Findstring$,Replacestring$) - String$ with every Findstring$ replaced by Replacestring$.
The result is built at a3 (behind the arguments), then moved to d0$. End test: a0+Len(f$) > address of f$ (BHI) - the find string is expected right behind s$ in the work area. CaseSense Off compares 'a'..'z' as upper case. DIFF: with an empty find string the original pops only two lengths (two MOVE.l -(a2) before BEQ 'skip), otherwise three (SUBQ #4,a2), so a2 is left at different positions; the C version leaves a2 unchanged.
Fixed (#424): an empty find string returns s$ unchanged with a3 on its terminating 0; the original left a3 at its entry value, behind all three arguments.
| s | d0: the string |
| f | d1: the string to find |
| r | d2: the replacement |
| lens | a2: the length stack (the three lengths, String$'s on top) |
| BL_ALWAYS_INLINE ULONG right | ( | UBYTE * | s, |
| LONG | n, | ||
| const ULONG * | sp ) |
| void rightstring | ( | void | ) |
|
static |
Right$(String$,Length) - the last Length characters.
Moved to the start of the argument (movestring). A negative length counts as 0; a length beyond the string gives the whole string.
Fixed (#285): the offset Len-Length is a long (the original took it as a word: for Len-Length >= 32768 the characters before the string).
| s | d0: the string |
| n | d1: the length |
| lens | a2: the length stack (the string's length) |
| void rsetstring | ( | void | ) |
|
static |
RSet$(String$,Characters) - the string right justified in Characters characters.
The characters are moved to the end of d1 characters (backwards from -1(a3)), spaces in front; a longer string keeps its last d1 characters (movestring). A negative width counts as 0.
| s | d0: the string |
| n | d1: the width |
| lens | a2: the length stack (the string's length) |
| void stringfunclib_codeinit | ( | void | ) |
| void stringstr | ( | void | ) |
|
static |
String$(String$,Repeats) - Repeats copies of the string.
movestring copies the argument behind itself (from -1(a3) on) with a0 trailing by one length, then the whole block is moved to the start. A count <= 0 gives the empty string. DIFF: for a count <= 0 the original returns the empty string without popping the argument's length (MOVE.l d1,d3:BLE 'skip comes first), so a2 is left at another position than for count > 0; the C version leaves a2 unchanged in both cases (same results).
| s | d0: the string |
| count | d1: the number of copies |
| lens | a2: the length stack (the string's length) |
| void striplead | ( | void | ) |
|
static |
StripLead$(String$,Ascii) - the string without the leading characters Ascii.
Strips the leading characters d1.b; the rest is moved to the start (movestring); all stripped: d0 = 0, a3 = d0$.
| s | d0: the string |
| ch | d1.w: the character to strip (low byte) |
| lens | a2: the length stack (the string's length) |
| void striptrail | ( | void | ) |
|
static |
StripTrail$(String$,Ascii) - the string without the trailing characters Ascii.
In place: a3 is moved back over the trailing characters d1.b.
| s | d0: the string |
| ch | d1.w: the character to strip (low byte) |
| lens | a2: the length stack (the string's length) |
| void ucasestring | ( | void | ) |
|
static |
UCase$(String$) - the string in upper case ('a'..'z' only).
In place. An empty string leaves a3 at its entry value, as LCase$.
| s | d0: the string |
| lens | a2: the length stack (the string's length) |
| void unleftstring | ( | void | ) |
|
static |
UnLeft$(String$,Length) - the string without its last Length characters.
Left$(d0$,Len(d0$)-d1); the length is read with -4(a2).
| s | d0: the string |
| n | d1: the number of characters to remove |
| lens | a2: the length stack (the string's length) |
| void unrightstring | ( | void | ) |
|
static |
UnRight$(String$,Length) - the string without its first Length characters.
Right$(d0$,Len(d0$)-d1); the length is read with -4(a2).
Fixed (#285): as Right$, a long offset into the string.
| s | d0: the string |
| n | d1: the number of characters to remove |
| lens | a2: the length stack (the string's length) |
|
inlinestatic |
|
static |