From 41cefb7460ce5b75f008810d8fffe6c580300ce6 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sat, 4 Apr 2020 07:35:07 -0400 Subject: [PATCH] Extract EMIT-dependent routines from core --- emul/Makefile | 2 +- forth/core.fs | 26 -------------------------- forth/print.fs | 30 ++++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 27 deletions(-) create mode 100644 forth/print.fs diff --git a/emul/Makefile b/emul/Makefile index 3b2e0ac..0479fa6 100644 --- a/emul/Makefile +++ b/emul/Makefile @@ -1,6 +1,6 @@ TARGETS = runbin/runbin forth/forth # Those Forth source files are in a particular order -FORTHSRCS = core.fs str.fs parse.fs readln.fs fmt.fs z80a.fs +FORTHSRCS = core.fs print.fs str.fs parse.fs readln.fs fmt.fs z80a.fs FORTHSRC_PATHS = ${FORTHSRCS:%=../forth/%} forth/run.fs OBJS = emul.o libz80/libz80.o SLATEST = ../tools/slatest diff --git a/forth/core.fs b/forth/core.fs index 67d3f2e..ba726e6 100644 --- a/forth/core.fs +++ b/forth/core.fs @@ -118,29 +118,3 @@ ( Set up initial SYSVNXT value, which is 2 bytes after its own address ) 46 RAM+ DUP 2 + SWAP ! - -: (print) - BEGIN - DUP C@ ( a c ) - ( exit if null ) - DUP NOT IF 2DROP EXIT THEN - EMIT ( a ) - 1 + ( a+1 ) - AGAIN -; - -: ." - 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 - -: (uflw) ABORT" stack underflow" ; -: (wnf) ABORT" word not found" ; diff --git a/forth/print.fs b/forth/print.fs new file mode 100644 index 0000000..d1db462 --- /dev/null +++ b/forth/print.fs @@ -0,0 +1,30 @@ +( Words allowing printing strings. Require core ) +( This used to be in core, but some drivers providing EMIT + are much much easier to write with access to core words, + and these words below need EMIT... ) + +: (print) + BEGIN + DUP C@ ( a c ) + ( exit if null ) + DUP NOT IF 2DROP EXIT THEN + EMIT ( a ) + 1 + ( a+1 ) + AGAIN +; + +: ." + 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 + +: (uflw) ABORT" stack underflow" ; +: (wnf) ABORT" word not found" ;