mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-26 17:58:05 +11:00
Compare commits
No commits in common. "7a0e63746f2d7c138e8ea1d7533b2b65c4bae4c0" and "446ce574cdd40949e0e6e8f73bbd17d6a752507f" have entirely different histories.
7a0e63746f
...
446ce574cd
2
blk/001
2
blk/001
@ -2,7 +2,7 @@ MASTER INDEX
|
|||||||
|
|
||||||
3 Usage 30 Dictionary
|
3 Usage 30 Dictionary
|
||||||
70 Implementation notes 100 Block editor
|
70 Implementation notes 100 Block editor
|
||||||
200 Z80 assembler 260 Cross compilation
|
200 Z80 assembler
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
2
blk/058
2
blk/058
@ -7,7 +7,7 @@ LIT< x -- Read following word and write to HERE as a
|
|||||||
LITS a -- Write word at addr a as a atring literal.
|
LITS a -- Write word at addr a as a atring literal.
|
||||||
S= a1 a2 -- f Returns whether string a1 == a2.
|
S= a1 a2 -- f Returns whether string a1 == a2.
|
||||||
SCPY a -- Copy string at addr a into HERE.
|
SCPY a -- Copy string at addr a into HERE.
|
||||||
|
SLEN a -- n Push length of str at a.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
16
blk/260
16
blk/260
@ -1,16 +0,0 @@
|
|||||||
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.)
|
|
6
blk/261
6
blk/261
@ -1,6 +0,0 @@
|
|||||||
(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.
|
|
||||||
|
|
11
blk/263
11
blk/263
@ -1,11 +0,0 @@
|
|||||||
VARIABLE XCURRENT
|
|
||||||
VARIABLE XOFF
|
|
||||||
|
|
||||||
: XCON XCURRENT CURRENT* ! ;
|
|
||||||
: XCOFF 0x02 RAM+ CURRENT* ! ;
|
|
||||||
|
|
||||||
: (xentry) XCON (entry) XCOFF ;
|
|
||||||
|
|
||||||
: XCODE XCON CODE XCOFF ;
|
|
||||||
|
|
||||||
: XIMM XCON IMMEDIATE XCOFF ;
|
|
14
blk/264
14
blk/264
@ -1,14 +0,0 @@
|
|||||||
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.
|
|
14
blk/265
14
blk/265
@ -1,14 +0,0 @@
|
|||||||
: 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
|
|
||||||
;
|
|
@ -1,12 +1,13 @@
|
|||||||
TARGETS = forth/forth
|
TARGETS = forth/forth
|
||||||
# Those Forth source files are in a particular order
|
# Those Forth source files are in a particular order
|
||||||
BOOTSRCS = ./forth/conf.fs \
|
BOOTSRCS = ./forth/conf.fs \
|
||||||
|
../forth/xcomp.fs \
|
||||||
./forth/xcomp.fs \
|
./forth/xcomp.fs \
|
||||||
../forth/boot.z80 \
|
../forth/boot.z80 \
|
||||||
../forth/icore.fs \
|
../forth/icore.fs \
|
||||||
./forth/xstop.fs
|
./forth/xstop.fs
|
||||||
|
|
||||||
FORTHSRCS = core.fs cmp.fs print.fs parse.fs readln.fs fmt.fs blk.fs
|
FORTHSRCS = core.fs cmp.fs print.fs str.fs parse.fs readln.fs fmt.fs blk.fs
|
||||||
FORTHSRC_PATHS = ${FORTHSRCS:%=../forth/%} forth/run.fs
|
FORTHSRC_PATHS = ${FORTHSRCS:%=../forth/%} forth/run.fs
|
||||||
OBJS = emul.o libz80/libz80.o
|
OBJS = emul.o libz80/libz80.o
|
||||||
SLATEST = ../tools/slatest
|
SLATEST = ../tools/slatest
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
262 LOAD
|
|
||||||
: CODE XCODE ;
|
: CODE XCODE ;
|
||||||
: IMMEDIATE XIMM ;
|
: IMMEDIATE XIMM ;
|
||||||
: : [ ' X: , ] ;
|
: : [ ' X: , ] ;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
expected to have been loaded prior to icore and redefines
|
expected to have been loaded prior to icore and redefines
|
||||||
":" and other defining words. So, in other words, when
|
":" and other defining words. So, in other words, when
|
||||||
compiling icore, ":" doesn't means what you think it means,
|
compiling icore, ":" doesn't means what you think it means,
|
||||||
go look in B260.
|
go look in xcomp.
|
||||||
)
|
)
|
||||||
|
|
||||||
: RAM+
|
: RAM+
|
||||||
|
@ -29,6 +29,10 @@
|
|||||||
DUP @ 30768 = NOT IF 0 EXIT THEN ( a 0 )
|
DUP @ 30768 = NOT IF 0 EXIT THEN ( a 0 )
|
||||||
( We have "0x" prefix )
|
( We have "0x" prefix )
|
||||||
2+
|
2+
|
||||||
|
( validate slen )
|
||||||
|
DUP SLEN ( a l )
|
||||||
|
DUP NOT IF DROP 0 EXIT THEN ( a 0 )
|
||||||
|
4 > IF DROP 0 EXIT THEN ( a 0 )
|
||||||
0 ( a r )
|
0 ( a r )
|
||||||
BEGIN
|
BEGIN
|
||||||
SWAP C@+ ( r a+1 c )
|
SWAP C@+ ( r a+1 c )
|
||||||
@ -54,6 +58,10 @@
|
|||||||
DUP @ 25136 = NOT IF 0 EXIT THEN ( a 0 )
|
DUP @ 25136 = NOT IF 0 EXIT THEN ( a 0 )
|
||||||
( We have "0b" prefix )
|
( We have "0b" prefix )
|
||||||
2+
|
2+
|
||||||
|
( validate slen )
|
||||||
|
DUP SLEN ( a l )
|
||||||
|
DUP 0 = IF DROP 0 EXIT THEN ( a 0 )
|
||||||
|
16 > IF DROP 0 EXIT THEN ( a 0 )
|
||||||
0 ( a r )
|
0 ( a r )
|
||||||
BEGIN
|
BEGIN
|
||||||
SWAP C@+ ( r a+1 c )
|
SWAP C@+ ( r a+1 c )
|
||||||
|
5
forth/str.fs
Normal file
5
forth/str.fs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
: SLEN ( a -- n )
|
||||||
|
DUP ( astart aend )
|
||||||
|
BEGIN C@+ NOT UNTIL
|
||||||
|
1- -^
|
||||||
|
;
|
67
forth/xcomp.fs
Normal file
67
forth/xcomp.fs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
( 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
|
||||||
|
;
|
@ -5,6 +5,7 @@ EDIR = $(BASEDIR)/emul/forth
|
|||||||
STAGE2 = $(EDIR)/stage2
|
STAGE2 = $(EDIR)/stage2
|
||||||
EMUL = $(BASEDIR)/emul/hw/rc2014/classic
|
EMUL = $(BASEDIR)/emul/hw/rc2014/classic
|
||||||
BOOTSRCS = conf.fs \
|
BOOTSRCS = conf.fs \
|
||||||
|
$(FDIR)/xcomp.fs \
|
||||||
$(EDIR)/xcomp.fs \
|
$(EDIR)/xcomp.fs \
|
||||||
$(FDIR)/boot.z80 \
|
$(FDIR)/boot.z80 \
|
||||||
$(BASEDIR)/drv/acia.z80 \
|
$(BASEDIR)/drv/acia.z80 \
|
||||||
@ -15,6 +16,7 @@ BOOTSRCS = conf.fs \
|
|||||||
PATHS = \
|
PATHS = \
|
||||||
$(FDIR)/core.fs \
|
$(FDIR)/core.fs \
|
||||||
$(FDIR)/cmp.fs \
|
$(FDIR)/cmp.fs \
|
||||||
|
$(FDIR)/str.fs \
|
||||||
$(FDIR)/parse.fs \
|
$(FDIR)/parse.fs \
|
||||||
$(BASEDIR)/drv/acia.fs \
|
$(BASEDIR)/drv/acia.fs \
|
||||||
$(FDIR)/print.fs \
|
$(FDIR)/print.fs \
|
||||||
|
Loading…
Reference in New Issue
Block a user