forth: bring ." and ABORT" down to core.fs level

This commit is contained in:
Virgil Dupras 2020-03-25 20:39:07 -04:00
parent 3e934a2a3b
commit c2d8fc845d
5 changed files with 23 additions and 21 deletions

View File

@ -7,7 +7,7 @@ AVRABIN = zasm/avra
SHELLAPPS = zasm ed
SHELLTGTS = ${SHELLAPPS:%=cfsin/%}
# Those Forth source files are in a particular order
FORTHSRCS = core.fs str.fs parse.fs readln.fs fmt.fs high.fs z80a.fs dummy.fs
FORTHSRCS = core.fs str.fs parse.fs readln.fs fmt.fs z80a.fs dummy.fs
FORTHSRC_PATHS = ${FORTHSRCS:%=../forth/%}
CFSIN_CONTENTS = $(SHELLTGTS) cfsin/user.h
OBJS = emul.o libz80/libz80.o

View File

@ -90,3 +90,16 @@
SYSVNXT @ ,
2 SYSVNXT +!
;
: ."
LIT
BEGIN
C< DUP ( c c )
( 34 is ASCII for " )
DUP 34 = IF DROP DROP 0 0 THEN
C,
0 = UNTIL
COMPILE (print)
; IMMEDIATE
: ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE

View File

@ -134,7 +134,7 @@ forthMain:
call find
ld (PARSEPTR), de
; Set up CINPTR
; do we have a C< impl?
; do we have a (c<) impl?
ld hl, .cinName
call find
jr z, .skip
@ -150,7 +150,7 @@ forthMain:
jp EXECUTE+2
.cinName:
.db "C<", 0
.db "(c<)", 0
BEGIN:
.dw compiledWord
@ -1005,8 +1005,11 @@ KEY:
jp next
; This is an indirect word that can be redirected through "CINPTR"
; This is not a real word because it's not meant to be referred to in Forth
; code: it is replaced in readln.fs.
.db "C<"
.fill 5
.dw $-KEY
.db 0
CIN:
.dw compiledWord
.dw NUMBER
@ -1023,7 +1026,7 @@ CIN:
; 32 CMP 1 -
.db "WS?"
.fill 4
.dw $-KEY
.dw $-CIN
.db 0
ISWS:
.dw compiledWord

View File

@ -1,14 +0,0 @@
( Higher level stuff that generally requires all core units )
: ."
LIT
BEGIN
C< DUP ( c c )
( 34 is ASCII for " )
DUP 34 = IF DROP DROP 0 0 THEN
C,
0 = UNTIL
COMPILE (print)
; IMMEDIATE
: ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE

View File

@ -69,8 +69,8 @@
IN( @ IN> !
;
( And finally, implement a replacement for the C< routine )
: C<
( And finally, implement a replacement for the (c<) routine )
: (c<)
IN> @ C@ ( c )
( not EOL? good, inc and return )
DUP IF 1 IN> +! EXIT THEN ( c )