Extract EMIT-dependent routines from core

This commit is contained in:
Virgil Dupras 2020-04-04 07:35:07 -04:00
parent d013c572ad
commit 41cefb7460
3 changed files with 31 additions and 27 deletions

View File

@ -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

View File

@ -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" ;

30
forth/print.fs Normal file
View File

@ -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" ;