mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-24 01: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] , ;
|
: LIT ROUTINE S [LITN] , ;
|
||||||
: LITS LIT SCPY ;
|
: LITS LIT SCPY ;
|
||||||
: LIT< WORD LITS ; IMMEDIATE
|
: 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 ' LITN ['] , , ; IMMEDIATE
|
||||||
: [COMPILE] ' , ; IMMEDIATE
|
: [COMPILE] ' , ; IMMEDIATE
|
||||||
: BEGIN H ; IMMEDIATE
|
: BEGIN H ; IMMEDIATE
|
||||||
@ -15,6 +18,9 @@
|
|||||||
BTW: Forth lines limited to 64 cols because of default
|
BTW: Forth lines limited to 64 cols because of default
|
||||||
input buffer size in Collapse OS
|
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
|
COMPILE: Tough one. Get addr of caller word (example above
|
||||||
(bbr)) and then call LITN on it. )
|
(bbr)) and then call LITN on it. )
|
||||||
|
|
||||||
|
@ -991,43 +991,10 @@ FIND_:
|
|||||||
push de
|
push de
|
||||||
jp next
|
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 )
|
; ( -- c )
|
||||||
.db "KEY"
|
.db "KEY"
|
||||||
.fill 4
|
.fill 4
|
||||||
.dw $-FINDI
|
.dw $-FIND_
|
||||||
.db 0
|
.db 0
|
||||||
KEY:
|
KEY:
|
||||||
.dw nativeWord
|
.dw nativeWord
|
||||||
|
Loading…
Reference in New Issue
Block a user