forth: Forth-ify "'" and "[']"

This commit is contained in:
Virgil Dupras 2020-03-25 20:06:06 -04:00
parent 6d8edeec63
commit 77ecbc4918
2 changed files with 7 additions and 34 deletions

View File

@ -4,6 +4,9 @@
: LIT ROUTINE S [LITN] , ;
: LITS LIT SCPY ;
: LIT< WORD LITS ; IMMEDIATE
: _err LIT< word-not-found (print) ABORT ;
: ' WORD (find) SKIP? _err ;
: ['] WORD (find) SKIP? _err LITN ; IMMEDIATE
: COMPILE ' LITN ['] , , ; IMMEDIATE
: [COMPILE] ' , ; IMMEDIATE
: BEGIN H ; IMMEDIATE
@ -15,6 +18,9 @@
BTW: Forth lines limited to 64 cols because of default
input buffer size in Collapse OS
"_": words starting with "_" are meant to be "private",
that is, only used by their immediate surrondings.
COMPILE: Tough one. Get addr of caller word (example above
(bbr)) and then call LITN on it. )

View File

@ -991,43 +991,10 @@ FIND_:
push de
jp next
.db "'"
.fill 6
.dw $-FIND_
.db 0
FIND:
.dw compiledWord
.dw WORD
.dw FIND_
.dw CSKIP
.dw FINDERR
.dw EXIT
.db "[']"
.fill 4
.dw $-FIND
.db 0b01 ; IMMEDIATE
FINDI:
.dw compiledWord
.dw WORD
.dw FIND_
.dw CSKIP
.dw FINDERR
.dw LITN
.dw EXIT
FINDERR:
.dw compiledWord
.dw DROP ; Drop str addr, we don't use it
.dw LIT
.db "word not found", 0
.dw PRINT
.dw ABORT
; ( -- c )
.db "KEY"
.fill 4
.dw $-FINDI
.dw $-FIND_
.db 0
KEY:
.dw nativeWord