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

forth: Forth-ify "C<"

This commit is contained in:
Virgil Dupras 2020-03-30 08:37:33 -04:00
parent f6cba4b1cf
commit 395eb04fac
3 changed files with 14 additions and 33 deletions

Binary file not shown.

View File

@ -126,6 +126,7 @@ LIT:
; 35 ; 35
jp strcmp jp strcmp
.dw RS_ADDR .dw RS_ADDR
.dw CINPTR
; *** Code *** ; *** Code ***
forthMain: forthMain:
@ -149,16 +150,6 @@ forthMain:
ld hl, .parseName ld hl, .parseName
call find call find
ld (PARSEPTR), de ld (PARSEPTR), de
; Set up CINPTR
; do we have a (c<) impl?
ld hl, .cinName
call find
jr z, .skip
; no? then use KEY
ld hl, .keyName
call find
.skip:
ld (CINPTR), de
; Set up SYSVNXT ; Set up SYSVNXT
ld hl, SYSVBUF ld hl, SYSVBUF
ld (SYSVNXT), hl ld (SYSVNXT), hl
@ -169,14 +160,10 @@ forthMain:
.parseName: .parseName:
.db "(parse)", 0 .db "(parse)", 0
.cinName:
.db "(c<)", 0
.keyName:
.db "KEY", 0
.bootName: .bootName:
.db "BOOT", 0 .db "BOOT", 0
.fill 68 .fill 93
; STABLE ABI ; STABLE ABI
; Offset: 00cd ; Offset: 00cd
@ -764,24 +751,10 @@ FIND_:
push de push de
jp next jp next
; This is an indirect word that can be redirected through "CINPTR" .fill 41
; code: it is replaced in readln.fs.
.db "C<"
.dw $-FIND_
.db 2
CIN:
.dw compiledWord
.dw NUMBER
.dw CINPTR
.dw FETCH
.dw EXECUTE
.dw EXIT
.fill 24
.db "NOT" .db "NOT"
.dw $-CIN .dw $-FIND_
.db 3 .db 3
NOT: NOT:
.dw nativeWord .dw nativeWord

View File

@ -75,6 +75,11 @@
LIT< stack-underflow _c (print) _c ABORT LIT< stack-underflow _c (print) _c ABORT
; ;
: C<
( JTBL+40 == CINPTR )
[ JTBL 40 + @ LITN ] @ EXECUTE
;
: C, : C,
HERE @ _c C! HERE @ _c C!
HERE @ 1 _c + HERE ! HERE @ 1 _c + HERE !
@ -87,7 +92,7 @@
: TOWORD : TOWORD
BEGIN BEGIN
C< _c DUP _c WS? NOT IF EXIT THEN DROP _c C< _c DUP _c WS? NOT IF EXIT THEN DROP
AGAIN AGAIN
; ;
@ -102,7 +107,7 @@
always zero to pre-write our null-termination ) always zero to pre-write our null-termination )
_c OVER ! ( a ) _c OVER ! ( a )
1 _c + ( a+1 ) 1 _c + ( a+1 )
C< ( a c ) _c C< ( a c )
_c DUP _c WS? _c DUP _c WS?
UNTIL UNTIL
( a this point, PS is: a WS ) ( a this point, PS is: a WS )
@ -147,6 +152,9 @@
; ;
: BOOT : BOOT
LIT< (c<) (find) NOT IF LIT< KEY (find) DROP THEN
( JTBL+40 == CINPTR )
[ JTBL 40 + @ LITN ] !
LIT< (c<$) (find) IF EXECUTE ELSE DROP THEN LIT< (c<$) (find) IF EXECUTE ELSE DROP THEN
_c INTERPRET _c INTERPRET
; ;