mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 09:48:05 +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:
parent
3ea221d0eb
commit
b9fb6a6226
29
blk/284
29
blk/284
@ -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
13
blk/285
@ -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 )
|
||||
|
@ -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
13
blk/287
@ -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 )
|
@ -11,4 +11,4 @@
|
||||
LDDE(HL),
|
||||
HL INCd,
|
||||
HL PUSH, IY POP, ( --> IP )
|
||||
JR, lblexec BWR ( execute-B301 )
|
||||
JR, lblexec BWR ( execute-B287 )
|
16
blk/297
Normal file
16
blk/297
Normal 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
15
blk/298
@ -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
14
blk/299
@ -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
13
blk/301
@ -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 )
|
Loading…
Reference in New Issue
Block a user