mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-30 21:18:07 +11:00
2d17b4e8ec
I'm not sure why I chose null-terminated initially. Probably because the z80asm version had null-terminated strings. Length-prefixes strings are the traditional form of strings in Forth and it's a bit easier to work with them with traditional forth words when they're under this form.
14 lines
356 B
Plaintext
14 lines
356 B
Plaintext
( Read word from C<, copy to WORDBUF, null-terminate, and
|
|
return WORDBUF. )
|
|
: _wb 0x0e RAM+ ;
|
|
: _eot 0x0401 _wb ! _wb ;
|
|
: WORD
|
|
_wb 1+ TOWORD ( a c )
|
|
DUP EOT? IF 2DROP _eot EXIT THEN
|
|
BEGIN
|
|
OVER C! 1+ C< ( a c )
|
|
OVER 0x2e RAM+ = OVER WS? OR
|
|
UNTIL ( a c )
|
|
SWAP _wb - 1- ( ws len ) _wb C!
|
|
EOT? IF _eot ELSE _wb THEN ;
|