diff --git a/dictionary.txt b/dictionary.txt index 3c81f3c..d526565 100644 --- a/dictionary.txt +++ b/dictionary.txt @@ -98,6 +98,8 @@ J -- n Copy RS third item to PS C@ a -- c Set c to byte at address a C! c a -- Store byte c in address a CURRENT -- a Set a to wordref of last added entry. +CURRENT* -- a A pointer to active CURRENT*. Useful when we have + multiple active dicts. HERE -- a Push HERE's address H@ -- a HERE @ MOVE a1 a2 u -- Copy u bytes from a1 to a2, starting with a1, going diff --git a/emul/forth/xcomp.fs b/emul/forth/xcomp.fs index 864ed4c..73b3340 100644 --- a/emul/forth/xcomp.fs +++ b/emul/forth/xcomp.fs @@ -4,3 +4,8 @@ CURRENT @ XCURRENT ! H@ ' _bend - 4 + XOFF ! + +( dummy entry for dict hook ) +(xentry) _ +H@ 256 /MOD 2 PC! 2 PC! + diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index 66265d0..8ffdb2e 100644 Binary files a/emul/forth/z80c.bin and b/emul/forth/z80c.bin differ diff --git a/forth/icore.fs b/forth/icore.fs index e445dd1..1b073e3 100644 --- a/forth/icore.fs +++ b/forth/icore.fs @@ -35,7 +35,8 @@ : FLAGS 0x08 RAM+ ; : (parse*) 0x0a RAM+ ; : HERE 0x04 RAM+ ; -: CURRENT 0x02 RAM+ ; +: CURRENT* 0x51 RAM+ ; +: CURRENT CURRENT* @ ; ( w -- a f ) : (find) CURRENT @ SWAP _find ; @@ -185,6 +186,7 @@ ; : BOOT + 0x02 RAM+ CURRENT* ! LIT< (parse) (find) DROP (parse*) ! ( 60 == SYSTEM SCRATCHPAD ) CURRENT @ 0x60 RAM+ ! diff --git a/forth/xcomp.fs b/forth/xcomp.fs index a3f92a8..18cec96 100644 --- a/forth/xcomp.fs +++ b/forth/xcomp.fs @@ -24,40 +24,26 @@ VARIABLE XCURRENT VARIABLE XOFF -: (xentry) - H@ ( h ) - WORD ( h s ) - SCPY ( h ) - ( Adjust HERE -1 because SCPY copies the null ) - H@ 1 - ( h h' ) - DUP HERE ! ( h h' ) - -^ ( sz ) - ( write prev value ) - H@ XCURRENT @ - , - ( write size ) - C, - H@ XCURRENT ! -; +: XCON XCURRENT CURRENT* ! ; +: XCOFF CURRENT CURRENT* ! ; + +: (xentry) XCON (entry) XCOFF ; ( Finds in *both* CURRENT and XCURRENT ) ( w -- a f xa xf ) : (xfind) DUP ( w w ) - CURRENT @ SWAP ( w cur w ) + ( hardcoded system CURRENT ) + 0x02 RAM+ @ SWAP ( w cur w ) _find ( w a f ) ROT ( a f w ) XCURRENT @ SWAP ( a f xcur w ) _find ( a f xa xf ) ; -: XCODE - (xentry) 23 , -; +: XCODE XCON CODE XCOFF ; -: XIMM - XCURRENT @ 1 - - DUP C@ 128 OR SWAP C! -; +: XIMM XCON IMMEDIATE XCOFF ; : X: (xentry) diff --git a/forth/z80c.fs b/forth/z80c.fs index 82dcf86..b178fad 100644 --- a/forth/z80c.fs +++ b/forth/z80c.fs @@ -22,10 +22,6 @@ This unit expects the same conf as boot.fs. ) -( dummy entry for dict hook ) -(xentry) _ -H@ 256 /MOD 2 PC! 2 PC! - ( a b c -- b c a ) CODE ROT HL POPqq, ( C ) diff --git a/notes.txt b/notes.txt index 2d16513..0e71504 100644 --- a/notes.txt +++ b/notes.txt @@ -88,7 +88,8 @@ RAMSTART INITIAL_SP +0e WORDBUF +2e SYSVNXT +4e INTJUMP -+51 RESERVED ++51 CURRENTPTR ++53 RESERVED +60 SYSTEM SCRATCHPAD +80 RAMEND @@ -116,6 +117,11 @@ those slots...) in boot binaries are made to jump to this address. If you use one of those slots for an interrupt, write a jump to the appropriate offset in that RAM location. +CURRENTPTR points to current CURRENT. The Forth CURRENT word doesn't return +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: