mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-26 15:38:08 +11:00
Compare commits
No commits in common. "f62376bd0a84c87c27fc63861479ba65756c59ec" and "54929c2aa0d84db7d29a5c504fdfc14d0c203225" have entirely different histories.
f62376bd0a
...
54929c2aa0
@ -15,10 +15,10 @@ $(SLATEST):
|
||||
$(BIN2C):
|
||||
$(MAKE) -C ../tools
|
||||
|
||||
# z80c.bin is not in the prerequisites because it's a bootstrap
|
||||
# binary that should be updated manually through make updatebootstrap.
|
||||
# z80c.bin and boot.bin are not in the prerequisites because they're bootstrap
|
||||
# binaries that should be updated manually through make updatebootstrap.
|
||||
forth/forth0.bin: $(SLATEST)
|
||||
cp forth/z80c.bin $@
|
||||
cat forth/boot.bin 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/z80c.bin forth/core.bin > $@
|
||||
cat forth/boot.bin forth/z80c.bin forth/core.bin > $@
|
||||
$(SLATEST) $@
|
||||
|
||||
forth/forth1-bin.h: forth/forth1.bin $(BIN2C)
|
||||
@ -60,11 +60,10 @@ 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/z80c.bin
|
||||
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
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
|
BIN
emul/forth/boot.bin
Normal file
BIN
emul/forth/boot.bin
Normal file
Binary file not shown.
@ -1,18 +1,11 @@
|
||||
: _
|
||||
['] 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,7 +87,6 @@ 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 )
|
||||
@ -367,3 +366,20 @@ 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,29 +14,18 @@
|
||||
"'" and friends will *not* find words you're about to
|
||||
define. Only (xfind) will.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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 0x02 RAM+ CURRENT* ! ;
|
||||
: XCOFF CURRENT CURRENT* ! ;
|
||||
|
||||
: (xentry) XCON (entry) XCOFF ;
|
||||
|
||||
@ -44,37 +33,15 @@ 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:
|
||||
(xentry)
|
||||
XCON
|
||||
(entry)
|
||||
( 0e == compiledWord )
|
||||
[ 0x0e LITN ] ,
|
||||
BEGIN
|
||||
( DUP is because we need a copy in case it's IMMED )
|
||||
WORD DUP
|
||||
( cross compile CURRENT )
|
||||
XCURRENT @ SWAP ( w xcur w )
|
||||
_find ( w a f )
|
||||
(find) ( w a f )
|
||||
IF
|
||||
( is word )
|
||||
DUP IMMED?
|
||||
@ -82,33 +49,23 @@ VARIABLE XOFF
|
||||
( When encountering IMMEDIATE, we exec the *host*
|
||||
word. )
|
||||
DROP ( w )
|
||||
( system CURRENT )
|
||||
( hardcoded system CURRENT )
|
||||
0x02 RAM+ @ SWAP ( cur w )
|
||||
_find ( a f )
|
||||
NOT IF ABORT THEN ( a )
|
||||
XCON EXECUTE XCOFF
|
||||
EXECUTE
|
||||
ELSE
|
||||
( not an immed. drop backup w and write, with
|
||||
offset. )
|
||||
SWAP DROP ( a )
|
||||
XAPPLY
|
||||
DUP 0x100 > IF XOFF @ - THEN
|
||||
,
|
||||
THEN
|
||||
ELSE ( w a )
|
||||
( 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
|
||||
( maybe number )
|
||||
DROP ( w )
|
||||
(parse*) @ EXECUTE LITN
|
||||
THEN
|
||||
AGAIN
|
||||
XCOFF
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user