From 6368cc3bacb3942181961ce55d1240dd6f223b34 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Fri, 10 Apr 2020 14:57:00 -0400 Subject: [PATCH] Remove (sysv) Replace its usages with direct RAM+ offsets. The (sysv) mechanism was incompatible with cross-compilation of a full interpreter. --- emul/forth/z80c.bin | Bin 2169 -> 2169 bytes forth/core.fs | 20 -------------------- forth/icore.fs | 10 +++++----- forth/readln.fs | 6 +++--- forth/z80a.fs | 14 +++++++------- notes.txt | 29 ++++++++++++++++++++--------- recipes/rc2014/conf.fs | 2 +- 7 files changed, 36 insertions(+), 45 deletions(-) diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index ae61f4a964cffdd8360667ec8c6135651ed855b8..de2db0cf91c52f753d4c4e85e549135a2cb37193 100644 GIT binary patch delta 39 vcmew<@Kazz3%jTuLm!Jf^99CC=J$*W42%q?m=qZFCeLIyV$_>_hJ7sn@P-R~ delta 39 vcmew<@Kazz3%h6nLm!Jf^99CC=J$*W42%q?m=qWiCeLIyVoaEPhJ7sn`LqlY diff --git a/forth/core.fs b/forth/core.fs index f2910ba..6d1947a 100644 --- a/forth/core.fs +++ b/forth/core.fs @@ -103,26 +103,6 @@ COMPILE R> COMPILE DROP COMPILE R> COMPILE DROP ; IMMEDIATE -( WARNING: there are no limit checks. We must be cautious, in - core code, not to create more than SYSV_BUFSIZE/2 sys vars. - Also: SYSV shouldn't be used during runtime: SYSVNXT won't - point at the right place. It should only be used during - stage1 compilation. This is why this word is not documented - in dictionary.txt ) - -: (sysv) - ( Get new sysv addr ) - ( RAM+46 (2e) == SYSVNXT ) - 46 RAM+ @ - CONSTANT - ( increase current sysv counter ) - 2 46 RAM+ +! -; - -( Set up initial SYSVNXT value, which is 2 bytes after its - own address ) -46 RAM+ DUP 2 + SWAP ! - ( a1 a2 u -- ) : MOVE ( u ) 0 DO diff --git a/forth/icore.fs b/forth/icore.fs index ab5f615..7880a4d 100644 --- a/forth/icore.fs +++ b/forth/icore.fs @@ -178,18 +178,18 @@ ( system c< simply reads source from binary, starting at LATEST. Convenient way to bootstrap a new system. ) : (c<) - ( 60 == SYSTEM SCRATCHPAD ) - 0x60 RAM+ @ ( a ) + ( 2e == BOOT C< PTR ) + 0x2e RAM+ @ ( a ) DUP C@ ( a c ) SWAP 1 + ( c a+1 ) - 0x60 RAM+ ! ( c ) + 0x2e RAM+ ! ( c ) ; : BOOT 0x02 RAM+ CURRENT* ! LIT< (parse) (find) DROP (parse*) ! - ( 60 == SYSTEM SCRATCHPAD ) - CURRENT @ 0x60 RAM+ ! + ( 2e == SYSTEM SCRATCHPAD ) + CURRENT @ 0x2e RAM+ ! ( 0c == CINPTR ) LIT< (c<) (find) DROP 0x0c RAM+ ! LIT< INIT (find) diff --git a/forth/readln.fs b/forth/readln.fs index 3561a65..53ae78e 100644 --- a/forth/readln.fs +++ b/forth/readln.fs @@ -9,11 +9,11 @@ 64 CONSTANT INBUFSZ ( points to INBUF ) -(sysv) IN( +: IN( 0x53 RAM+ ; ( points to INBUF's end ) -(sysv) IN) +: IN) 0x55 RAM+ ; ( current position in INBUF ) -(sysv) IN> +: IN> 0x57 RAM+ ; ( flush input buffer ) ( set IN> to IN( and set IN> @ to null ) diff --git a/forth/z80a.fs b/forth/z80a.fs index 63372fa..48d617f 100644 --- a/forth/z80a.fs +++ b/forth/z80a.fs @@ -9,7 +9,7 @@ ( H@ offset at which we consider our PC 0. Used to compute PC. To have a proper PC, call "H@ ORG !" at the beginning of your assembly process. ) -(sysv) ORG +: ORG 0x59 RAM+ ; : PC H@ ORG @ - ; ( A, spits an assembled byte, A,, spits an assembled word @@ -28,12 +28,12 @@ pre-declare label variables here, which means we have a limited number of it. For now, 6 ought to be enough. ) -(sysv) L1 -(sysv) L2 -(sysv) L3 -(sysv) L4 -(sysv) L5 -(sysv) L6 +: L1 0x5b RAM+ ; +: L2 0x5d RAM+ ; +: L3 0x5f RAM+ ; +: L4 0x61 RAM+ ; +: L5 0x63 RAM+ ; +: L6 0x65 RAM+ ; ( There are 2 label types: backward and forward. For each type, there are two actions: set and write. Setting a label diff --git a/notes.txt b/notes.txt index 0e71504..7ba2cf6 100644 --- a/notes.txt +++ b/notes.txt @@ -86,11 +86,21 @@ RAMSTART INITIAL_SP +0a PARSEPTR +0c CINPTR +0e WORDBUF -+2e SYSVNXT ++2e BOOT C< PTR +4e INTJUMP +51 CURRENTPTR -+53 RESERVED -+60 SYSTEM SCRATCHPAD ++53 readln's IN( ++55 readln's IN) ++57 readln's IN> ++59 z80a's ORG ++5b z80a's L1 ++5d z80a's L2 ++5f z80a's L3 ++61 z80a's L4 ++63 z80a's L5 ++65 z80a's L6 ++67 FUTURE USES ++70 DRIVERS +80 RAMEND INITIAL_SP holds the initial Stack Pointer value so that we know where to reset @@ -110,7 +120,8 @@ CINPTR holds routine address called on C< WORDBUF is the buffer used by WORD -SYSVNXT is the buffer+tracker used by (sysv) +BOOT C< PTR is used when Forth boots from in-memory source. See "Initialization +sequence" below. INTJUMP All RST offsets (well, not *all* at this moment, I still have to free those slots...) in boot binaries are made to jump to this address. If you use @@ -122,12 +133,12 @@ RAM+2 directly, but rather the value at this address. Most of the time, it points to RAM+2, but sometimes, when maintaining alternative dicts (during cross compilation for example), it can point elsewhere. -SYSTEM SCRATCHPAD is reserved for temporary system storage or can be reserved -by low-level drivers. These are the current usages of this space throughout the -project: +FUTURE USES section is unused for now. -* 0x60-0x62: (c<) pointer during in-memory initialization (see below) -* 0x62-0x6a: ACIA buffer pointers in RC2014 recipes. +DRIVERS section is reserved for recipe-specific drivers. Here is a list of +known usages: + +* 0x70-0x78: ACIA buffer pointers in RC2014 recipes. *** Initialization sequence diff --git a/recipes/rc2014/conf.fs b/recipes/rc2014/conf.fs index e78eb9f..123526b 100644 --- a/recipes/rc2014/conf.fs +++ b/recipes/rc2014/conf.fs @@ -2,5 +2,5 @@ 0xf000 CONSTANT RS_ADDR 0x80 CONSTANT ACIA_CTL 0x81 CONSTANT ACIA_IO -RAMSTART 0x62 + CONSTANT ACIA_MEM +RAMSTART 0x70 + CONSTANT ACIA_MEM