5.7.6 Memory Blocks

A few of these words work on address unit blocks. In that case, you
usually have to insert CHARS before the word when working on
character strings. Most words work on character blocks, and expect a
char-aligned address.

When copying characters between overlapping memory regions, use
chars move or choose carefully between cmove and
cmove>.

movec-from c-to ucount – core “move”

Copy the contents of ucount aus at c-from to
c-to. move works correctly even if the two areas overlap.

eraseaddr u – core-ext “erase”

Clear all bits in u aus starting at addr.

cmovec-from c-to u – string “c-move”

Copy the contents of ucount characters from data space at
c-from to c-to. The copy proceeds char-by-char
from low address to high address; i.e., for overlapping areas it is
safe if c-to=<c-from.

cmove>c-from c-to u – string “c-move-up”

Copy the contents of ucount characters from data space at
c-from to c-to. The copy proceeds char-by-char
from high address to low address; i.e., for overlapping areas it is
safe if c-to>=c-from.

fillc-addr u c – core “fill”

Store c in u chars starting at c-addr.

blankc-addr u – string “blank”

Store the space character into u chars starting at c-addr.

comparec-addr1 u1 c-addr2 u2 – n string “compare”

Compare two strings lexicographically. If they are equal, n is 0; if
the first string is smaller, n is -1; if the first string is larger, n
is 1. Currently this is based on the machine's character
comparison. In the future, this may change to consider the current
locale and its collation order.

str=c-addr1 u1 c-addr2 u2 – f gforth “str=”

str<c-addr1 u1 c-addr2 u2 – f gforth “str<”

string-prefix?c-addr1 u1 c-addr2 u2 – f gforth “string-prefix?”

Is c-addr2 u2 a prefix of c-addr1 u1?

searchc-addr1 u1 c-addr2 u2 – c-addr3 u3 flag string “search”

Search the string specified by c-addr1, u1 for the string
specified by c-addr2, u2. If flag is true: match was found
at c-addr3 with u3 characters remaining. If flag is false:
no match was found; c-addr3, u3 are equal to c-addr1, u1.

-trailingc_addr u1 – c_addr u2 string “dash-trailing”

Adjust the string specified by c-addr, u1 to remove all
trailing spaces. u2 is the length of the modified string.

/stringc-addr1 u1 n – c-addr2 u2 string “slash-string”

Adjust the string specified by c-addr1, u1 to remove n
characters from the start of the string.

boundsaddr u – addr+u addr gforth “bounds”

Given a memory block represented by starting address addr
and length u in aus, produce the end address addr+u and
the start address in the right order for u+do or
?do.

pad– c-addr core-ext “pad”

c-addr is the address of a transient region that can be
used as temporary data storage. At least 84 characters of space
is available.