1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-02 12:10:54 +11:00

Compare commits

..

No commits in common. "f62376bd0a84c87c27fc63861479ba65756c59ec" and "54929c2aa0d84db7d29a5c504fdfc14d0c203225" have entirely different histories.

6 changed files with 42 additions and 77 deletions

View File

@ -15,10 +15,10 @@ $(SLATEST):
$(BIN2C): $(BIN2C):
$(MAKE) -C ../tools $(MAKE) -C ../tools
# z80c.bin is not in the prerequisites because it's a bootstrap # z80c.bin and boot.bin are not in the prerequisites because they're bootstrap
# binary that should be updated manually through make updatebootstrap. # binaries that should be updated manually through make updatebootstrap.
forth/forth0.bin: $(SLATEST) forth/forth0.bin: $(SLATEST)
cp forth/z80c.bin $@ cat forth/boot.bin forth/z80c.bin > $@
$(SLATEST) $@ $(SLATEST) $@
cat forth/emul.fs >> $@ 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 cat $(FORTHSRC_PATHS) ./forth/stop.fs | $(STRIPFC) | ./forth/stage1 | tee $@ > /dev/null
forth/forth1.bin: forth/core.bin $(SLATEST) 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) $@ $(SLATEST) $@
forth/forth1-bin.h: forth/forth1.bin $(BIN2C) forth/forth1-bin.h: forth/forth1.bin $(BIN2C)
@ -60,11 +60,10 @@ emul.o: emul.c
$(CC) -c -o 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 .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 .PHONY: clean
clean: clean:

BIN
emul/forth/boot.bin Normal file

Binary file not shown.

View File

@ -1,18 +1,11 @@
: _
['] EXIT ,
R> DROP ( exit : )
XCOFF
; IMMEDIATE
';' CURRENT @ 4 - C!
: (find) (xfind) ;
: ['] X['] ; IMMEDIATE
: COMPILE XCOMPILE ; IMMEDIATE
: CODE XCODE ; : CODE XCODE ;
: IMMEDIATE XIMM ; : IMMEDIATE XIMM ;
: : [ ' X: , ] ; : : [ ' X: , ] ;
CURRENT @ XCURRENT ! CURRENT @ XCURRENT !
H@ ' _bend - 4 + XOFF !
( dummy entry for dict hook )
(xentry) _
H@ 256 /MOD 2 PC! 2 PC! H@ 256 /MOD 2 PC! 2 PC!
H@ XOFF !

Binary file not shown.

View File

@ -87,7 +87,6 @@ L1 BSET ( CBR )
'E' A, 'X' A, 'E' A, 'C' A, 'U' A, 'T' A, 'E' A, 'E' A, 'X' A, 'E' A, 'C' A, 'U' A, 'T' A, 'E' A,
PC L1 @ - A,, ( prev ) PC L1 @ - A,, ( prev )
7 A, 7 A,
H@ XCURRENT ! ( set current tip of dict )
L2 BSET ( used frequently below ) L2 BSET ( used frequently below )
0x17 A,, ( nativeWord ) 0x17 A,, ( nativeWord )
IY POPqq, ( is a wordref ) IY POPqq, ( is a wordref )
@ -367,3 +366,20 @@ PC ORG @ 0x22 + ! ( litWord )
want... ) want... )
RAMSTART 0x06 + LD(nn)HL, ( RAMSTART+0x06 == IP ) RAMSTART 0x06 + LD(nn)HL, ( RAMSTART+0x06 == IP )
JPNEXT, 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!

View File

@ -14,29 +14,18 @@
"'" and friends will *not* find words you're about to "'" and friends will *not* find words you're about to
define. Only (xfind) will. define. Only (xfind) will.
Words overrides like ":", "IMMEDIATE" and "CODE" are not Words ":", "IMMEDIATE" and "CODE" are not automatically
automatically shadowed to allow the harmless inclusion of shadowed to allow the harmless inclusion of this unit. This
this unit. This shadowing has to take place in your xcomp shadowing has to take place in your xcomp configuration.
configuration.
See example in /emul/forth/xcomp.fs 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 XCURRENT
VARIABLE XOFF VARIABLE XOFF
: XCON XCURRENT CURRENT* ! ; : XCON XCURRENT CURRENT* ! ;
: XCOFF 0x02 RAM+ CURRENT* ! ; : XCOFF CURRENT CURRENT* ! ;
: (xentry) XCON (entry) XCOFF ; : (xentry) XCON (entry) XCOFF ;
@ -44,37 +33,15 @@ VARIABLE XOFF
: XIMM XCON IMMEDIATE XCOFF ; : 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: : X:
(xentry) XCON
(entry)
( 0e == compiledWord ) ( 0e == compiledWord )
[ 0x0e LITN ] , [ 0x0e LITN ] ,
BEGIN BEGIN
( DUP is because we need a copy in case it's IMMED ) ( DUP is because we need a copy in case it's IMMED )
WORD DUP WORD DUP
( cross compile CURRENT ) (find) ( w a f )
XCURRENT @ SWAP ( w xcur w )
_find ( w a f )
IF IF
( is word ) ( is word )
DUP IMMED? DUP IMMED?
@ -82,33 +49,23 @@ VARIABLE XOFF
( When encountering IMMEDIATE, we exec the *host* ( When encountering IMMEDIATE, we exec the *host*
word. ) word. )
DROP ( w ) DROP ( w )
( system CURRENT ) ( hardcoded system CURRENT )
0x02 RAM+ @ SWAP ( cur w ) 0x02 RAM+ @ SWAP ( cur w )
_find ( a f ) _find ( a f )
NOT IF ABORT THEN ( a ) NOT IF ABORT THEN ( a )
XCON EXECUTE XCOFF EXECUTE
ELSE ELSE
( not an immed. drop backup w and write, with ( not an immed. drop backup w and write, with
offset. ) offset. )
SWAP DROP ( a ) SWAP DROP ( a )
XAPPLY DUP 0x100 > IF XOFF @ - THEN
, ,
THEN THEN
ELSE ( w a ) ELSE ( w a )
( not found? it might be an immediate that isn't yet defined in our ( maybe number )
cross-compiled dict. It's alright, we can find-and-execute it. ) DROP ( w )
DROP ( w ) (parse*) @ EXECUTE LITN
( 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 THEN
AGAIN AGAIN
XCOFF
; ;