1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 16:18:05 +11:00

forth: Forth-ify "(find)"

This commit is contained in:
Virgil Dupras 2020-03-30 17:36:15 -04:00
parent de3da19333
commit 5b01f797fc
4 changed files with 29 additions and 31 deletions

Binary file not shown.

View File

@ -107,7 +107,10 @@
; comment indicating what that number refers to.
; We're at 0 here
jp forthMain
.fill 0x08-$
; 3
jp find
.dw 0 ; unused
; 8
jp sysvarWord
jp cellWord
jp compiledWord
@ -721,32 +724,10 @@ SCPY:
jp next
.db "(find)"
.dw $-SCPY
.db 6
; STABLE ABI
; Offset: 047c
.out $
FIND_:
.dw nativeWord
pop hl
call find
jr z, .found
; not found
push hl
ld de, 0
push de
jp next
.found:
push de
ld de, 1
push de
jp next
.fill 427
.fill 460
.db "_bend"
.dw $-FIND_
.dw $-SCPY
.db 5
; Offset: 0647
.out $

View File

@ -77,7 +77,7 @@
: QUIT
0 _c FLAGS _c ! _c (resRS)
LIT< INTERPRET (find) _c DROP EXECUTE
LIT< INTERPRET _c (find) _c DROP EXECUTE
;
: ABORT _c (resSP) _c QUIT ;
@ -163,7 +163,7 @@
: INTERPRET
BEGIN
_c WORD
(find)
_c (find)
IF
1 _c FLAGS _c !
EXECUTE
@ -175,11 +175,12 @@
;
: BOOT
LIT< (parse) (find) _c DROP _c (parse*) _c !
LIT< (c<) (find) _c NOT IF LIT< KEY (find) _c DROP THEN
LIT< (parse) _c (find) _c DROP _c (parse*) _c !
LIT< (c<) _c (find) _c
NOT IF LIT< KEY _c (find) _c DROP THEN
( 48 == CINPTR )
[ 48 @ LITN ] _c !
LIT< (c<$) (find) IF EXECUTE ELSE _c DROP THEN
LIT< (c<$) _c (find) IF EXECUTE ELSE _c DROP THEN
_c INTERPRET
;
@ -201,7 +202,7 @@
[ 32 , 14 , ] ,
BEGIN
_c WORD
(find)
_c (find)
( is word )
IF _c DUP _c IMMED? IF EXECUTE ELSE , THEN
( maybe number )

View File

@ -376,3 +376,19 @@ CODE (parsed)
DE 1 LDddnn,
DE PUSHqq,
;CODE
CODE (find)
HL POPqq,
( 3 == find )
3 CALLnn,
10 JRZe, ( found )
( not found )
HL PUSHqq,
DE 0 LDddnn,
DE PUSHqq,
JPNEXT,
( found )
DE PUSHqq,
DE 1 LDddnn,
DE PUSHqq,
;CODE