Compare commits
3 Commits
54929c2aa0
...
f62376bd0a
Author | SHA1 | Date | |
---|---|---|---|
|
f62376bd0a | ||
|
7aa1be070b | ||
|
c8c337fd58 |
@ -15,10 +15,10 @@ $(SLATEST):
|
||||
$(BIN2C):
|
||||
$(MAKE) -C ../tools
|
||||
|
||||
# z80c.bin and boot.bin are not in the prerequisites because they're bootstrap
|
||||
# binaries that should be updated manually through make updatebootstrap.
|
||||
# z80c.bin is not in the prerequisites because it's a bootstrap
|
||||
# binary that should be updated manually through make updatebootstrap.
|
||||
forth/forth0.bin: $(SLATEST)
|
||||
cat forth/boot.bin forth/z80c.bin > $@
|
||||
cp forth/z80c.bin $@
|
||||
$(SLATEST) $@
|
||||
cat forth/emul.fs >> $@
|
||||
|
||||
@ -37,7 +37,7 @@ forth/core.bin: $(FORTHSRC_PATHS) forth/stage1
|
||||
cat $(FORTHSRC_PATHS) ./forth/stop.fs | $(STRIPFC) | ./forth/stage1 | tee $@ > /dev/null
|
||||
|
||||
forth/forth1.bin: forth/core.bin $(SLATEST)
|
||||
cat forth/boot.bin forth/z80c.bin forth/core.bin > $@
|
||||
cat forth/z80c.bin forth/core.bin > $@
|
||||
$(SLATEST) $@
|
||||
|
||||
forth/forth1-bin.h: forth/forth1.bin $(BIN2C)
|
||||
@ -60,10 +60,11 @@ emul.o: emul.c
|
||||
$(CC) -c -o emul.o emul.c
|
||||
|
||||
|
||||
forth/z80c.bin: forth/stage2
|
||||
cat ./forth/conf.fs ../forth/xcomp.fs ./forth/xcomp.fs ../forth/boot.fs ../forth/z80c.fs ../forth/icore.fs | ./forth/stage2 | tee $@ > /dev/null
|
||||
|
||||
.PHONY: updatebootstrap
|
||||
updatebootstrap: forth/stage2
|
||||
cat ./forth/conf.fs ../forth/boot.fs | ./forth/stage2 | tee forth/boot.bin > /dev/null
|
||||
cat ./forth/conf.fs ../forth/xcomp.fs ./forth/xcomp.fs ../forth/z80c.fs ../forth/icore.fs | ./forth/stage2 | tee forth/z80c.bin > /dev/null
|
||||
updatebootstrap: forth/z80c.bin
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
|
Binary file not shown.
@ -1,11 +1,18 @@
|
||||
: _
|
||||
['] EXIT ,
|
||||
R> DROP ( exit : )
|
||||
XCOFF
|
||||
; IMMEDIATE
|
||||
';' CURRENT @ 4 - C!
|
||||
|
||||
: (find) (xfind) ;
|
||||
: ['] X['] ; IMMEDIATE
|
||||
: COMPILE XCOMPILE ; IMMEDIATE
|
||||
: CODE XCODE ;
|
||||
: IMMEDIATE XIMM ;
|
||||
: : [ ' X: , ] ;
|
||||
|
||||
CURRENT @ XCURRENT !
|
||||
H@ ' _bend - 4 + XOFF !
|
||||
|
||||
( dummy entry for dict hook )
|
||||
(xentry) _
|
||||
H@ 256 /MOD 2 PC! 2 PC!
|
||||
|
||||
H@ XOFF !
|
||||
|
Binary file not shown.
@ -87,6 +87,7 @@ L1 BSET ( CBR )
|
||||
'E' A, 'X' A, 'E' A, 'C' A, 'U' A, 'T' A, 'E' A,
|
||||
PC L1 @ - A,, ( prev )
|
||||
7 A,
|
||||
H@ XCURRENT ! ( set current tip of dict )
|
||||
L2 BSET ( used frequently below )
|
||||
0x17 A,, ( nativeWord )
|
||||
IY POPqq, ( is a wordref )
|
||||
@ -366,20 +367,3 @@ PC ORG @ 0x22 + ! ( litWord )
|
||||
want... )
|
||||
RAMSTART 0x06 + LD(nn)HL, ( RAMSTART+0x06 == IP )
|
||||
JPNEXT,
|
||||
|
||||
( filler )
|
||||
NOP, NOP, NOP, NOP, NOP,
|
||||
|
||||
( DICT HOOK )
|
||||
( This dummy dictionary entry serves two purposes:
|
||||
1. Allow binary grafting. Because each binary dict always
|
||||
end with a dummy entry, we always have a predictable
|
||||
prev offset for the grafter's first entry.
|
||||
2. Tell icore's "_c" routine where the boot binary ends.
|
||||
See comment there.
|
||||
)
|
||||
'_' A, 'b' A, 'e' A, 'n' A, 'd' A,
|
||||
PC L2 @ - A,, ( prev )
|
||||
5 A,
|
||||
|
||||
H@ 256 /MOD 2 PC! 2 PC!
|
||||
|
@ -14,18 +14,29 @@
|
||||
"'" and friends will *not* find words you're about to
|
||||
define. Only (xfind) will.
|
||||
|
||||
Words ":", "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.
|
||||
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
|
||||
|
||||
Note that this cross compilation unit is far from foolproof
|
||||
and cannot cross compile any kind of code. Cross compliation
|
||||
of Forth dicts is *tricky*. This unit is designed to cross
|
||||
compile the core full interpreter, that is, the contents
|
||||
of the "/forth" folder of the project.
|
||||
|
||||
Cross compiling anything else might work, but as soon as
|
||||
you start defining immediates and using them on-the-fly,
|
||||
things get icky.
|
||||
)
|
||||
|
||||
VARIABLE XCURRENT
|
||||
VARIABLE XOFF
|
||||
|
||||
: XCON XCURRENT CURRENT* ! ;
|
||||
: XCOFF CURRENT CURRENT* ! ;
|
||||
: XCOFF 0x02 RAM+ CURRENT* ! ;
|
||||
|
||||
: (xentry) XCON (entry) XCOFF ;
|
||||
|
||||
@ -33,15 +44,37 @@ VARIABLE XOFF
|
||||
|
||||
: XIMM XCON IMMEDIATE XCOFF ;
|
||||
|
||||
: XAPPLY
|
||||
DUP XOFF @ > IF XOFF @ - THEN
|
||||
;
|
||||
|
||||
( Run find in XCURRENT and apply XOFF )
|
||||
: (xfind)
|
||||
XCURRENT @ SWAP ( xcur w )
|
||||
_find ( a f )
|
||||
IF ( a )
|
||||
( apply XOFF )
|
||||
XAPPLY 1
|
||||
ELSE
|
||||
0
|
||||
THEN
|
||||
;
|
||||
|
||||
: X' XCON ' XCOFF XAPPLY ;
|
||||
: X['] X' LITN ;
|
||||
( TODO: am I making the word "," stable here? )
|
||||
: XCOMPILE X' LITN ['] , , ;
|
||||
|
||||
: X:
|
||||
XCON
|
||||
(entry)
|
||||
(xentry)
|
||||
( 0e == compiledWord )
|
||||
[ 0x0e LITN ] ,
|
||||
BEGIN
|
||||
( DUP is because we need a copy in case it's IMMED )
|
||||
WORD DUP
|
||||
(find) ( w a f )
|
||||
( cross compile CURRENT )
|
||||
XCURRENT @ SWAP ( w xcur w )
|
||||
_find ( w a f )
|
||||
IF
|
||||
( is word )
|
||||
DUP IMMED?
|
||||
@ -49,23 +82,33 @@ VARIABLE XOFF
|
||||
( When encountering IMMEDIATE, we exec the *host*
|
||||
word. )
|
||||
DROP ( w )
|
||||
( hardcoded system CURRENT )
|
||||
( system CURRENT )
|
||||
0x02 RAM+ @ SWAP ( cur w )
|
||||
_find ( a f )
|
||||
NOT IF ABORT THEN ( a )
|
||||
EXECUTE
|
||||
XCON EXECUTE XCOFF
|
||||
ELSE
|
||||
( not an immed. drop backup w and write, with
|
||||
offset. )
|
||||
SWAP DROP ( a )
|
||||
DUP 0x100 > IF XOFF @ - THEN
|
||||
XAPPLY
|
||||
,
|
||||
THEN
|
||||
ELSE ( w a )
|
||||
( maybe number )
|
||||
DROP ( w )
|
||||
(parse*) @ EXECUTE LITN
|
||||
( 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. )
|
||||
DROP ( w )
|
||||
( 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
|
||||
XCOFF
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user