From c2d8fc845d88631f1e25d38b369d796c40930803 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 25 Mar 2020 20:39:07 -0400 Subject: [PATCH] forth: bring ." and ABORT" down to core.fs level --- emul/Makefile | 2 +- forth/core.fs | 13 +++++++++++++ forth/forth.asm | 11 +++++++---- forth/high.fs | 14 -------------- forth/readln.fs | 4 ++-- 5 files changed, 23 insertions(+), 21 deletions(-) delete mode 100644 forth/high.fs diff --git a/emul/Makefile b/emul/Makefile index 17e6991..a228eb8 100644 --- a/emul/Makefile +++ b/emul/Makefile @@ -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 diff --git a/forth/core.fs b/forth/core.fs index 8da35c4..b525791 100644 --- a/forth/core.fs +++ b/forth/core.fs @@ -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 diff --git a/forth/forth.asm b/forth/forth.asm index c6765e2..4cf14ea 100644 --- a/forth/forth.asm +++ b/forth/forth.asm @@ -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 diff --git a/forth/high.fs b/forth/high.fs deleted file mode 100644 index 765ddc9..0000000 --- a/forth/high.fs +++ /dev/null @@ -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 diff --git a/forth/readln.fs b/forth/readln.fs index c9de600..6cbb46f 100644 --- a/forth/readln.fs +++ b/forth/readln.fs @@ -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 )