1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 21:28:05 +11:00

forth: make "'" push 0 when not finding a word

This commit is contained in:
Virgil Dupras 2020-03-17 15:54:17 -04:00
parent 3a70dff53d
commit d91af99fde
2 changed files with 10 additions and 13 deletions

View File

@ -453,25 +453,22 @@ LITS:
.fill 6 .fill 6
.dw LITS .dw LITS
.db 0 .db 0
APOS: FIND:
.dw nativeWord .dw nativeWord
call readword call readword
call find call find
jr nz, .notfound jr z, .found
; not found
ld de, 0
.found:
push de push de
jp next jp next
.notfound:
ld hl, .msg
call printstr
jp abort
.msg:
.db "word not found", 0
.db "[']" .db "[']"
.fill 4 .fill 4
.dw APOS .dw FIND
.db 0b01 ; IMMEDIATE .db 0b01 ; IMMEDIATE
APOSI: FINDI:
.dw nativeWord .dw nativeWord
call readword call readword
call find call find
@ -494,7 +491,7 @@ APOSI:
; ( -- c ) ; ( -- c )
.db "KEY" .db "KEY"
.fill 4 .fill 4
.dw APOSI .dw FINDI
.db 0 .db 0
KEY: KEY:
.dw nativeWord .dw nativeWord

View File

@ -35,9 +35,9 @@ directly, but as part of another word.
: x ... -- Define a new word : x ... -- Define a new word
; R:I -- Exit a colon definition ; R:I -- Exit a colon definition
, n -- Write n in HERE and advance it. , n -- Write n in HERE and advance it.
' x -- a Push addr of word x to a. ' x -- a Push addr of word x to a. If not found, push 0
['] x -- *I* Like "'", but spits the addr as a number ['] x -- *I* Like "'", but spits the addr as a number
literal. literal. If not found, aborts.
( -- *I* Comment. Ignore rest of line until ")" is read. ( -- *I* Comment. Ignore rest of line until ")" is read.
ALLOT n -- Move HERE by n bytes ALLOT n -- Move HERE by n bytes
C, b -- Write byte b in HERE and advance it. C, b -- Write byte b in HERE and advance it.