mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 14:48:06 +11:00
forth: Forth-ify "'" and "[']"
This commit is contained in:
parent
6d8edeec63
commit
77ecbc4918
@ -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. )
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user