forth: Forth-ify "WS?"

This commit is contained in:
Virgil Dupras 2020-03-28 13:18:43 -04:00
parent a17da42021
commit 9fcfebd84c
3 changed files with 9 additions and 21 deletions

Binary file not shown.

View File

@ -830,27 +830,10 @@ CIN:
.dw EXIT
; ( c -- f )
; 33 CMP 1 + NOT
; The NOT is to normalize the negative/positive numbers to 1 or 0.
; Hadn't we wanted to normalize, we'd have written:
; 32 CMP 1 -
.db "WS?"
.dw $-CIN
.db 3
ISWS:
.dw compiledWord
.dw NUMBER
.dw 33
.dw CMP
.dw NUMBER
.dw 1
.dw PLUS
.dw NOT
.dw EXIT
.fill 24
.db "NOT"
.dw $-ISWS
.dw $-CIN
.db 3
NOT:
.dw nativeWord

View File

@ -78,9 +78,14 @@
HERE @ 1 + HERE !
;
( The NOT is to normalize the negative/positive numbers to 1
or 0. Hadn't we wanted to normalize, we'd have written:
32 CMP 1 - )
: WS? 33 CMP 1 + NOT ;
: TOWORD
BEGIN
C< DUP WS? NOT IF EXIT THEN DROP
C< DUP _c WS? NOT IF EXIT THEN DROP
AGAIN
;
@ -96,7 +101,7 @@
OVER ! ( a )
1 + ( a+1 )
C< ( a c )
DUP WS?
DUP _c WS?
UNTIL
( a this point, PS is: a WS )
( null-termination is already written )