1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-25 04:48:06 +11:00

z80: move boot code around

Bring native words together, make the next/exec/does/compiled
cluster be at the beginning.

Next step: bring find code into _find word.
This commit is contained in:
Virgil Dupras 2020-07-05 22:23:40 -04:00
parent 3ea221d0eb
commit b9fb6a6226
12 changed files with 62 additions and 60 deletions

29
blk/284
View File

@ -1,15 +1,14 @@
H@ 4 + XCURRENT ! ( make next CODE have 0 prev field )
CODE (br) ( TODO: move with other native words )
L1 BSET ( used in ?br and loop )
PC ORG @ 0x3d + ! ( stable ABI JP )
E 0 IY+ LDrIXY, D 1 IY+ LDrIXY,
DE ADDIYd,
;CODE
CODE (?br)
PC ORG @ 0x41 + ! ( stable ABI JP )
HL POP,
HLZ,
JRZ, L1 BWR ( br + 1. False, branch )
( True, skip next 2 bytes and don't branch )
IY INCd, IY INCd,
;CODE
PC ORG @ 1 + ! ( main )
( STACK OVERFLOW PROTECTION: See B76 )
SP PS_ADDR LDdn, IX RS_ADDR LDdn,
( LATEST is a label to the latest entry of the dict. It is
written at offset 0x08 by the process or person building
Forth. )
BIN( @ 0x08 + LDHL(n),
SYSVARS 0x02 ( CURRENT ) + LD(n)HL,
HERESTART [IF]
HL HERESTART LDdn,
[THEN]
SYSVARS 0x04 + LD(n)HL, ( RAM+04 == HERE )
DE BIN( @ 0x04 ( BOOT ) + LDdd(n),
JR, L1 FWR ( execute, B287 )

13
blk/285
View File

@ -1,10 +1,3 @@
CODE (loop)
PC ORG @ 0x45 + ! ( stable ABI JP )
0 IX+ INC(IXY+), IFZ, 1 IX+ INC(IXY+), THEN, ( I++ )
( Jump if I <> I' )
A 0 IX+ LDrIXY, 2 IX- CP(IXY+), JRNZ, L1 BWR ( branch )
A 1 IX+ LDrIXY, 1 IX- CP(IXY+), JRNZ, L1 BWR ( branch )
( don't branch )
IX DECd, IX DECd, IX DECd, IX DECd,
IY INCd, IY INCd,
;CODE
lblofl BSET ( abortUnderflow )
DE BIN( @ 0x06 ( uflw ) + LDdd(n),
JR, L2 FWR ( execute, B287 )

View File

@ -5,11 +5,11 @@ lblnext BSET PC ORG @ 0x1b + ! ( next )
( Before we continue: are stacks within bounds? )
( PS ) HL PS_ADDR LDdn,
SP SUBHLd,
JRC, lblofl BWR ( abortUnderflow-B298 )
JRC, lblofl BWR ( abortUnderflow-B285 )
( RS ) IX PUSH, HL POP,
DE RS_ADDR LDdn,
DE SUBHLd,
JRC, lblofl BWR ( IX < RS_ADDR? abortUnderflow-B298 )
JRC, lblofl BWR ( IX < RS_ADDR? abortUnderflow-B285 )
E 0 IY+ LDrIXY,
D 1 IY+ LDrIXY,
IY INCd, IY INCd,

13
blk/287
View File

@ -0,0 +1,13 @@
lblexec BSET L1 FSET ( B284 ) L2 FSET ( B285 )
( DE -> wordref )
( When we have a BIN( offset, we need to adjust stable
ABI offsets. )
BIN( @ [IF]
A XORr, D ORr, IFZ, D BIN( @ 256 / LDri, THEN,
[THEN]
LDA(DE), DE INCd,
A ORr, IFZ, EXDEHL, JP(HL), THEN,
A DECr, JRZ, L1 FWR ( compiled B289 )
( cell or does. push PFA ) DE PUSH,
A DECr, JRZ, lblnext BWR ( cell )
( continue to does )

View File

View File

@ -11,4 +11,4 @@
LDDE(HL),
HL INCd,
HL PUSH, IY POP, ( --> IP )
JR, lblexec BWR ( execute-B301 )
JR, lblexec BWR ( execute-B287 )

View File

16
blk/297 Normal file
View File

@ -0,0 +1,16 @@
( Native words )
H@ 4 + XCURRENT ! ( make next CODE have 0 prev field )
CODE (br) ( TODO: move with other native words )
L1 BSET ( used in ?br and loop )
PC ORG @ 0x3d + ! ( stable ABI JP )
E 0 IY+ LDrIXY, D 1 IY+ LDrIXY,
DE ADDIYd,
;CODE
CODE (?br)
PC ORG @ 0x41 + ! ( stable ABI JP )
HL POP,
HLZ,
JRZ, L1 BWR ( br + 1. False, branch )
( True, skip next 2 bytes and don't branch )
IY INCd, IY INCd,
;CODE

15
blk/298
View File

@ -1,3 +1,12 @@
lblofl BSET ( abortUnderflow )
DE BIN( @ 0x06 ( uflw ) + LDdd(n),
JR, L2 FWR ( execute, B301 )
CODE (loop)
PC ORG @ 0x45 + ! ( stable ABI JP )
0 IX+ INC(IXY+), IFZ, 1 IX+ INC(IXY+), THEN, ( I++ )
( Jump if I <> I' )
A 0 IX+ LDrIXY, 2 IX- CP(IXY+), JRNZ, L1 BWR ( branch )
A 1 IX+ LDrIXY, 1 IX- CP(IXY+), JRNZ, L1 BWR ( branch )
( don't branch )
IX DECd, IX DECd, IX DECd, IX DECd,
IY INCd, IY INCd,
;CODE

14
blk/299
View File

@ -1,14 +0,0 @@
PC ORG @ 1 + ! ( main )
( STACK OVERFLOW PROTECTION: See B76 )
SP PS_ADDR LDdn, IX RS_ADDR LDdn,
( LATEST is a label to the latest entry of the dict. It is
written at offset 0x08 by the process or person building
Forth. )
BIN( @ 0x08 + LDHL(n),
SYSVARS 0x02 ( CURRENT ) + LD(n)HL,
HERESTART [IF]
HL HERESTART LDdn,
[THEN]
SYSVARS 0x04 + LD(n)HL, ( RAM+04 == HERE )
DE BIN( @ 0x04 ( BOOT ) + LDdd(n),
JR, L1 FWR ( execute, B301 )

13
blk/301
View File

@ -1,13 +0,0 @@
lblexec BSET L1 FSET ( B299 ) L2 FSET ( B298 )
( DE -> wordref )
( We don't apply BIN( reliably on stable ABI stuff, we
might need to adjust addr. Ugly, but well... )
BIN( @ [IF]
A XORr, D ORr, IFZ, D BIN( @ 256 / LDri, THEN,
[THEN]
LDA(DE), DE INCd,
A ORr, IFZ, EXDEHL, JP(HL), THEN,
A DECr, JRZ, L1 FWR ( compiled B303 )
( cell or does. push PFA ) DE PUSH,
A DECr, JRZ, lblnext BWR ( cell )
( continue to does, B302 )

View File

@ -1,8 +1,7 @@
( Native words )
CODE EXECUTE
DE POP,
chkPS,
JR, lblexec BWR ( execute-B301 )
lblexec @ JP,
CODE EXIT
PC ORG @ 0x0d + ! ( stable ABI JP )