1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-30 20:58:05 +11:00

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 SHELLAPPS = zasm ed
SHELLTGTS = ${SHELLAPPS:%=cfsin/%} SHELLTGTS = ${SHELLAPPS:%=cfsin/%}
# Those Forth source files are in a particular order # 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/%} FORTHSRC_PATHS = ${FORTHSRCS:%=../forth/%}
CFSIN_CONTENTS = $(SHELLTGTS) cfsin/user.h CFSIN_CONTENTS = $(SHELLTGTS) cfsin/user.h
OBJS = emul.o libz80/libz80.o OBJS = emul.o libz80/libz80.o

View File

@ -90,3 +90,16 @@
SYSVNXT @ , SYSVNXT @ ,
2 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 call find
ld (PARSEPTR), de ld (PARSEPTR), de
; Set up CINPTR ; Set up CINPTR
; do we have a C< impl? ; do we have a (c<) impl?
ld hl, .cinName ld hl, .cinName
call find call find
jr z, .skip jr z, .skip
@ -150,7 +150,7 @@ forthMain:
jp EXECUTE+2 jp EXECUTE+2
.cinName: .cinName:
.db "C<", 0 .db "(c<)", 0
BEGIN: BEGIN:
.dw compiledWord .dw compiledWord
@ -1005,8 +1005,11 @@ KEY:
jp next jp next
; This is an indirect word that can be redirected through "CINPTR" ; 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. ; code: it is replaced in readln.fs.
.db "C<"
.fill 5
.dw $-KEY
.db 0
CIN: CIN:
.dw compiledWord .dw compiledWord
.dw NUMBER .dw NUMBER
@ -1023,7 +1026,7 @@ CIN:
; 32 CMP 1 - ; 32 CMP 1 -
.db "WS?" .db "WS?"
.fill 4 .fill 4
.dw $-KEY .dw $-CIN
.db 0 .db 0
ISWS: ISWS:
.dw compiledWord .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> ! IN( @ IN> !
; ;
( And finally, implement a replacement for the C< routine ) ( And finally, implement a replacement for the (c<) routine )
: C< : (c<)
IN> @ C@ ( c ) IN> @ C@ ( c )
( not EOL? good, inc and return ) ( not EOL? good, inc and return )
DUP IF 1 IN> +! EXIT THEN ( c ) DUP IF 1 IN> +! EXIT THEN ( c )