2020-04-11 11:38:45 -04:00
|
|
|
( Allow cross-compilation of z80c and icore.
|
2020-04-09 08:23:53 -04:00
|
|
|
Include this file right before your cross compilation, then
|
2020-04-11 11:38:45 -04:00
|
|
|
set XCURRENT to CURRENT and XOFF to H@.
|
2020-04-09 08:23:53 -04:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2020-04-10 07:53:41 -04:00
|
|
|
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.
|
2020-04-09 09:43:48 -04:00
|
|
|
|
2020-04-09 08:23:53 -04:00
|
|
|
See example in /emul/forth/xcomp.fs
|
2020-04-10 07:53:41 -04:00
|
|
|
|
2020-04-11 11:38:45 -04:00
|
|
|
Why limit ourselves to icore? Oh, I've tried cross-compiling
|
|
|
|
the whole shebang. I tried. And failed. Too dynamic.
|
2020-04-09 08:23:53 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
VARIABLE XCURRENT
|
|
|
|
VARIABLE XOFF
|
|
|
|
|
2020-04-09 12:01:08 -04:00
|
|
|
: XCON XCURRENT CURRENT* ! ;
|
2020-04-10 07:53:41 -04:00
|
|
|
: XCOFF 0x02 RAM+ CURRENT* ! ;
|
2020-04-09 12:01:08 -04:00
|
|
|
|
|
|
|
: (xentry) XCON (entry) XCOFF ;
|
2020-04-09 08:23:53 -04:00
|
|
|
|
2020-04-09 12:01:08 -04:00
|
|
|
: XCODE XCON CODE XCOFF ;
|
2020-04-09 08:23:53 -04:00
|
|
|
|
2020-04-09 12:01:08 -04:00
|
|
|
: XIMM XCON IMMEDIATE XCOFF ;
|
2020-04-09 08:23:53 -04:00
|
|
|
|
2020-04-09 09:43:48 -04:00
|
|
|
: X:
|
2020-04-10 07:53:41 -04:00
|
|
|
(xentry)
|
2020-04-09 08:23:53 -04:00
|
|
|
( 0e == compiledWord )
|
2020-04-15 15:15:31 -04:00
|
|
|
[ 0x0e LITN ] C,
|
2020-04-09 08:23:53 -04:00
|
|
|
BEGIN
|
2020-04-11 11:38:45 -04:00
|
|
|
WORD
|
2020-04-10 07:53:41 -04:00
|
|
|
( cross compile CURRENT )
|
|
|
|
XCURRENT @ SWAP ( w xcur w )
|
|
|
|
_find ( w a f )
|
2020-04-09 12:02:56 -04:00
|
|
|
IF
|
2020-04-09 08:23:53 -04:00
|
|
|
( is word )
|
2020-04-11 11:38:45 -04:00
|
|
|
( 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 )
|
2020-04-10 09:55:58 -04:00
|
|
|
( 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
|
2020-04-09 08:23:53 -04:00
|
|
|
THEN
|
|
|
|
AGAIN
|
2020-04-09 09:27:51 -04:00
|
|
|
;
|