mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 16:28:05 +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.
12 lines
368 B
Plaintext
12 lines
368 B
Plaintext
: _ ( a+1 len -- n f )
|
|
OVER C@ ( a len c )
|
|
'-' = IF
|
|
1- SWAP 1+ SWAP ( a+1 len-1 ) _ 0 ROT ( f 0 n )
|
|
- SWAP EXIT ( 0-n f )
|
|
THEN ( a len )
|
|
0 SWAP ( len ) 0 DO ( a r )
|
|
OVER I + C@ ( a r c ) _pdacc ( a r f )
|
|
IF DROP 1- 0 UNLOOP EXIT THEN LOOP ( a r )
|
|
NIP 1 ;
|
|
: (parsed) ( a -- n f ) C@+ ( a+1 l ) _ ;
|