diff --git a/blk/077 b/blk/077 index 37a2eb3..17e7a12 100644 --- a/blk/077 +++ b/blk/077 @@ -6,7 +6,7 @@ A dictionary entry has this structure: bigger than input buffer, of course). not null-terminated - 2b prev offset - 1b size + IMMEDIATE flag -- 2b code pointer +- 1b code pointer (always jumps in the <0x100 range) - Parameter field (PF) The prev offset is the number of bytes between the prev field diff --git a/blk/078 b/blk/078 index f7dcc86..5b0f02c 100644 --- a/blk/078 +++ b/blk/078 @@ -1,7 +1,9 @@ (cont.) The code pointer point to "word routines". These routines expect to be called with IY pointing to the PF. They themselves are expected to end by jumping to the address at -(IP). They will usually do so with "jp next". +(IP). They will usually do so with "jp next". They are 1b +because all those routines live in the first 0x100 bytes of +the boot binary. The 0 MSB is assumed. That's for "regular" words (words that are part of the dict chain). There are also "special words", for example NUMBER, diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index 19c0d57..2ca9802 100644 Binary files a/emul/forth/z80c.bin and b/emul/forth/z80c.bin differ diff --git a/forth/boot.fs b/forth/boot.fs index 3081cd8..03c630e 100644 --- a/forth/boot.fs +++ b/forth/boot.fs @@ -315,7 +315,6 @@ PC ORG @ 0x34 + ! ( execute ) H 0 LDrn, ( HL points to code pointer ) IY INCss, - IY INCss, ( IY points to PFA ) JP(HL), @@ -338,7 +337,7 @@ PC ORG @ 0x0f + ! ( compiledWord ) 0x33 JPnn, ( 33 == execute ) PC ORG @ 0x0c + ! ( cellWord ) -( Pushes the PFA directly ) +( Pushes PFA directly ) IY PUSHqq, JPNEXT, diff --git a/forth/core.fs b/forth/core.fs index 174a460..b8cdab3 100644 --- a/forth/core.fs +++ b/forth/core.fs @@ -58,7 +58,7 @@ : CREATE (entry) ( empty header with name ) 11 ( 11 == cellWord ) - , ( write it ) + C, ( write it ) ; ( We run this when we're in an entry creation context. Many @@ -71,11 +71,11 @@ : DOES> ( Overwrite cellWord in CURRENT ) ( 43 == doesWord ) - 43 CURRENT @ ! + 43 CURRENT @ C! ( When we have a DOES>, we forcefully place HERE to 4 bytes after CURRENT. This allows a DOES word to use "," and "C," without messing everything up. ) - CURRENT @ 4 + HERE ! + CURRENT @ 3 + HERE ! ( HERE points to where we should write R> ) R> , ( We're done. Because we've popped RS, we'll exit parent diff --git a/forth/icore.fs b/forth/icore.fs index 3f78412..1f8757f 100644 --- a/forth/icore.fs +++ b/forth/icore.fs @@ -237,7 +237,7 @@ XCURRENT @ ( to PSP ) ( We cannot use LITN as IMMEDIATE because of bootstrapping issues. Same thing for ",". 32 == NUMBER 14 == compiledWord ) - [ 32 H@ ! 2 ALLOT 14 H@ ! 2 ALLOT ] , + [ 32 H@ ! 2 ALLOT 14 H@ ! 2 ALLOT ] C, BEGIN WORD (find) diff --git a/forth/link.fs b/forth/link.fs index 6188626..f869fb3 100644 --- a/forth/link.fs +++ b/forth/link.fs @@ -82,7 +82,7 @@ ) ( ol o a1 a2 -- ) : RLWORD - SWAP DUP @ ( ol o a2 a1 n ) + SWAP DUP C@ ( ol o a2 a1 n ) ( 0e == compiledWord, 2b == doesWord ) DUP <>{ 0x0e &= 0x2b |= <>} NOT IF ( unwind all args ) @@ -95,7 +95,7 @@ ( ol o a2 a1 n ) 0x2b = IF 2 + THEN ( ol o a2 a1 ) - 2 + ( ol o a2 a1+2 ) + 1 + ( ol o a2 a1+1 ) BEGIN ( ol o a2 a1 ) 2OVER ( ol o a2 a1 ol o ) SWAP ( ol o a2 a1 o ol ) diff --git a/forth/xcomp.fs b/forth/xcomp.fs index 76cfc6f..310ec7d 100644 --- a/forth/xcomp.fs +++ b/forth/xcomp.fs @@ -34,7 +34,7 @@ VARIABLE XOFF : X: (xentry) ( 0e == compiledWord ) - [ 0x0e LITN ] , + [ 0x0e LITN ] C, BEGIN WORD ( cross compile CURRENT ) diff --git a/forth/z80a.fs b/forth/z80a.fs index e095fc2..a9a4328 100644 --- a/forth/z80a.fs +++ b/forth/z80a.fs @@ -324,7 +324,7 @@ ( same as CREATE, but with native word ) (entry) ( 23 == nativeWord ) - 23 , + 23 C, ; : ;CODE JPNEXT, ;