mirror of
https://github.com/hsoft/collapseos.git
synced 2025-04-04 02:58:39 +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 )
|
PC ORG @ 1 + ! ( main )
|
||||||
CODE (br) ( TODO: move with other native words )
|
( STACK OVERFLOW PROTECTION: See B76 )
|
||||||
L1 BSET ( used in ?br and loop )
|
SP PS_ADDR LDdn, IX RS_ADDR LDdn,
|
||||||
PC ORG @ 0x3d + ! ( stable ABI JP )
|
( LATEST is a label to the latest entry of the dict. It is
|
||||||
E 0 IY+ LDrIXY, D 1 IY+ LDrIXY,
|
written at offset 0x08 by the process or person building
|
||||||
DE ADDIYd,
|
Forth. )
|
||||||
;CODE
|
BIN( @ 0x08 + LDHL(n),
|
||||||
CODE (?br)
|
SYSVARS 0x02 ( CURRENT ) + LD(n)HL,
|
||||||
PC ORG @ 0x41 + ! ( stable ABI JP )
|
HERESTART [IF]
|
||||||
HL POP,
|
HL HERESTART LDdn,
|
||||||
HLZ,
|
[THEN]
|
||||||
JRZ, L1 BWR ( br + 1. False, branch )
|
SYSVARS 0x04 + LD(n)HL, ( RAM+04 == HERE )
|
||||||
( True, skip next 2 bytes and don't branch )
|
DE BIN( @ 0x04 ( BOOT ) + LDdd(n),
|
||||||
IY INCd, IY INCd,
|
JR, L1 FWR ( execute, B287 )
|
||||||
;CODE
|
|
||||||
|
13
blk/285
13
blk/285
@ -1,10 +1,3 @@
|
|||||||
CODE (loop)
|
lblofl BSET ( abortUnderflow )
|
||||||
PC ORG @ 0x45 + ! ( stable ABI JP )
|
DE BIN( @ 0x06 ( uflw ) + LDdd(n),
|
||||||
0 IX+ INC(IXY+), IFZ, 1 IX+ INC(IXY+), THEN, ( I++ )
|
JR, L2 FWR ( execute, B287 )
|
||||||
( 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
|
|
||||||
|
@ -5,11 +5,11 @@ lblnext BSET PC ORG @ 0x1b + ! ( next )
|
|||||||
( Before we continue: are stacks within bounds? )
|
( Before we continue: are stacks within bounds? )
|
||||||
( PS ) HL PS_ADDR LDdn,
|
( PS ) HL PS_ADDR LDdn,
|
||||||
SP SUBHLd,
|
SP SUBHLd,
|
||||||
JRC, lblofl BWR ( abortUnderflow-B298 )
|
JRC, lblofl BWR ( abortUnderflow-B285 )
|
||||||
( RS ) IX PUSH, HL POP,
|
( RS ) IX PUSH, HL POP,
|
||||||
DE RS_ADDR LDdn,
|
DE RS_ADDR LDdn,
|
||||||
DE SUBHLd,
|
DE SUBHLd,
|
||||||
JRC, lblofl BWR ( IX < RS_ADDR? abortUnderflow-B298 )
|
JRC, lblofl BWR ( IX < RS_ADDR? abortUnderflow-B285 )
|
||||||
E 0 IY+ LDrIXY,
|
E 0 IY+ LDrIXY,
|
||||||
D 1 IY+ LDrIXY,
|
D 1 IY+ LDrIXY,
|
||||||
IY INCd, IY INCd,
|
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),
|
LDDE(HL),
|
||||||
HL INCd,
|
HL INCd,
|
||||||
HL PUSH, IY POP, ( --> IP )
|
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 )
|
CODE (loop)
|
||||||
DE BIN( @ 0x06 ( uflw ) + LDdd(n),
|
PC ORG @ 0x45 + ! ( stable ABI JP )
|
||||||
JR, L2 FWR ( execute, B301 )
|
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