diff --git a/blk/001 b/blk/001 index b87d80d..ab3a24a 100644 --- a/blk/001 +++ b/blk/001 @@ -2,7 +2,7 @@ MASTER INDEX 3 Usage 30 Dictionary 70 Implementation notes 100 Block editor -200 Z80 assembler +200 Z80 assembler 260 Cross compilation diff --git a/blk/260 b/blk/260 new file mode 100644 index 0000000..b48149b --- /dev/null +++ b/blk/260 @@ -0,0 +1,16 @@ +Cross compilation program + +This programs allows cross compilation of boot binary and +icore. Run "262 LOAD" right before your cross compilation and +then set XCURRENT to CURRENT and XCOFF to H@. + +This redefines defining words to achieve cross compilation. +The goal is two-fold: + +1. Add an offset to all word references in definitions. +2. Don't shadow important words we need right now. + +Words overrides like ":", "IMMEDIATE" and "CODE" are not +automatically shadowed to allow the harmless inclusion of +this unit. This shadowing has to take place in your xcomp +configuration. (cont.) diff --git a/blk/261 b/blk/261 new file mode 100644 index 0000000..11eebe6 --- /dev/null +++ b/blk/261 @@ -0,0 +1,6 @@ +(cont.) +See example in /emul/forth/xcomp.fs + +Why limit ourselves to icore? Oh, I've tried cross-compiling +the whole shebang. I tried. And failed. Too dynamic. + diff --git a/blk/262 b/blk/262 new file mode 100644 index 0000000..4003147 --- /dev/null +++ b/blk/262 @@ -0,0 +1 @@ +263 LOAD 265 LOAD diff --git a/blk/263 b/blk/263 new file mode 100644 index 0000000..5e1ec75 --- /dev/null +++ b/blk/263 @@ -0,0 +1,11 @@ +VARIABLE XCURRENT +VARIABLE XOFF + +: XCON XCURRENT CURRENT* ! ; +: XCOFF 0x02 RAM+ CURRENT* ! ; + +: (xentry) XCON (entry) XCOFF ; + +: XCODE XCON CODE XCOFF ; + +: XIMM XCON IMMEDIATE XCOFF ; diff --git a/blk/264 b/blk/264 new file mode 100644 index 0000000..db5ee2d --- /dev/null +++ b/blk/264 @@ -0,0 +1,14 @@ +The "X:" word + +Because the ";" word goes back only one level in RSP and +this limits our ability to separate X: in sub words and this +means a rather cramped B265. This means no inline comments, +hence this block here. + +0x0e is compiledWord. first _find is on xdict. If found, we +compile it with offsets. We abort on IMMED? because we're +never supposed to encounter an immediate at this point. + +If not found, we try the same word on system dict (RAM+02). +If found and is immediate, execute. If founf and not immediate, +error. If not found, try number. diff --git a/blk/265 b/blk/265 new file mode 100644 index 0000000..d43278b --- /dev/null +++ b/blk/265 @@ -0,0 +1,14 @@ +: X: + (xentry) [ 0x0e LITN ] C, + BEGIN WORD + XCURRENT @ SWAP ( xcur w ) _find ( a f ) + IF ( a ) + DUP IMMED? IF ABORT THEN + DUP XOFF @ > IF XOFF @ - THEN , + ELSE ( w ) + 0x02 RAM+ @ SWAP ( cur w ) _find ( a f ) + IF DUP IMMED? NOT IF ABORT THEN EXECUTE + ELSE (parse*) @ EXECUTE LITN THEN + THEN + AGAIN +; diff --git a/emul/Makefile b/emul/Makefile index 493d02a..19a7985 100644 --- a/emul/Makefile +++ b/emul/Makefile @@ -1,7 +1,6 @@ TARGETS = forth/forth # Those Forth source files are in a particular order BOOTSRCS = ./forth/conf.fs \ - ../forth/xcomp.fs \ ./forth/xcomp.fs \ ../forth/boot.z80 \ ../forth/icore.fs \ diff --git a/emul/forth/xcomp.fs b/emul/forth/xcomp.fs index aafd773..8c8c678 100644 --- a/emul/forth/xcomp.fs +++ b/emul/forth/xcomp.fs @@ -1,3 +1,4 @@ +262 LOAD : CODE XCODE ; : IMMEDIATE XIMM ; : : [ ' X: , ] ; diff --git a/forth/icore.fs b/forth/icore.fs index e898ba8..1c06877 100644 --- a/forth/icore.fs +++ b/forth/icore.fs @@ -25,7 +25,7 @@ expected to have been loaded prior to icore and redefines ":" and other defining words. So, in other words, when compiling icore, ":" doesn't means what you think it means, - go look in xcomp. + go look in B260. ) : RAM+ diff --git a/forth/xcomp.fs b/forth/xcomp.fs deleted file mode 100644 index 310ec7d..0000000 --- a/forth/xcomp.fs +++ /dev/null @@ -1,67 +0,0 @@ -( Allow cross-compilation of z80c and icore. - Include this file right before your cross compilation, then - set XCURRENT to CURRENT and XOFF to H@. - - This redefines defining words to achieve cross compilation. - The goal is two-fold: - - 1. Add an offset to all word references in definitions. - 2. Don't shadow important words we need right now. - - Words overrides like ":", "IMMEDIATE" and "CODE" are not - automatically shadowed to allow the harmless inclusion of - this unit. This shadowing has to take place in your xcomp - configuration. - - See example in /emul/forth/xcomp.fs - - Why limit ourselves to icore? Oh, I've tried cross-compiling - the whole shebang. I tried. And failed. Too dynamic. -) - -VARIABLE XCURRENT -VARIABLE XOFF - -: XCON XCURRENT CURRENT* ! ; -: XCOFF 0x02 RAM+ CURRENT* ! ; - -: (xentry) XCON (entry) XCOFF ; - -: XCODE XCON CODE XCOFF ; - -: XIMM XCON IMMEDIATE XCOFF ; - -: X: - (xentry) - ( 0e == compiledWord ) - [ 0x0e LITN ] C, - BEGIN - WORD - ( cross compile CURRENT ) - XCURRENT @ SWAP ( w xcur w ) - _find ( w a f ) - IF - ( is word ) - ( never supposed to encounter an IMMEDIATE in xdict ) - DUP IMMED? IF ABORT THEN - ( not an immed. drop backup w and write, with - offset. ) - DUP XOFF @ > IF XOFF @ - THEN - , - ELSE ( w ) - ( not found? it might be an immediate that isn't yet defined in our - cross-compiled dict. It's alright, we can find-and-execute it. ) - ( system CURRENT ) - 0x02 RAM+ @ SWAP ( cur w ) - _find ( a f ) - IF - ( found. It *must* be an IMMED ) - DUP IMMED? NOT IF ABORT THEN - EXECUTE - ELSE - ( not found. maybe number ) - (parse*) @ EXECUTE LITN - THEN - THEN - AGAIN -; diff --git a/recipes/rc2014/Makefile b/recipes/rc2014/Makefile index ccb4a4c..a59366b 100644 --- a/recipes/rc2014/Makefile +++ b/recipes/rc2014/Makefile @@ -5,7 +5,6 @@ EDIR = $(BASEDIR)/emul/forth STAGE2 = $(EDIR)/stage2 EMUL = $(BASEDIR)/emul/hw/rc2014/classic BOOTSRCS = conf.fs \ - $(FDIR)/xcomp.fs \ $(EDIR)/xcomp.fs \ $(FDIR)/boot.z80 \ $(BASEDIR)/drv/acia.z80 \