Digest #225 2023-06-15
Contributions
Usage Example:
10 constant N
variable counts N allot
counts N erase
counts N dump
Replies
You say There are Forth words that handle 64-bit values, 32-bit values, 8-bit values but not 16-bit values.
. I'm curious - what words do you have in mind.
2! and 2@ work on cell pairs
and the size of a cell is system dependent. In my [WebForth] for example in the ESP8266 you set #define CELLL 4
to work on 32 bit cells, in which case 2@ fetches 64 bits but in Arduino you set #define CELLL 2
to work on 16 bit cells in which case 2@ fetches 32 bits.
For system programing it would be dangerous to use @ ! 2@ and 2! unless you knew for sure how this mapped to the underlying system architecture.
Common practice for reading and writing 16-bit values is w@
( addr -- u ) and w!
( x addr -- ). We have been discussing standardizing these and related words for many years, maybe we will get around to it at some point.