Search code examples
forth

In Forth is the top parameter to ERASE a number of cells or a number of bytes?


As the title suggests, in Forth:

Does:

1024 4 ERASE

Zero out 4 bytes begining at address 1024, or 4 cells (4x4=16 bytes in a 32-bit Forth) ?

I can't find any documentation that is entirely clear.

Thanks,

Tom


Solution

  • In the word ERASE ( addr u -- ) the topmost argument u is the number of address units.

    It's due to the the specification for this word:

    clear all bits in each of u consecutive address units of memory beginning at addr.

    Usually the address unit size is one octet (byte).

    So the phrase 1024 4 ERASE will erase 4 bytes in a byte-addressed machine. To erase 4 cells beginning at the address 1024 you have to say 1024 4 cells erase.