z80: Use BC as IP register instead of IY
It's a bit more inconvenient in terms of register protection (BC is much more generally useful than IY), but it makes tight spots such as next and execute much faster, so I think it's worth it.
This commit is contained in:
parent
a7dcb522c2
commit
e4a4a9800d
4
blk/280
4
blk/280
@ -4,8 +4,8 @@ This assembles the boot binary. It requires the Z80 assembler
|
||||
(B200) and cross compilation setup (B260). It requires some
|
||||
constants to be set. See B420 for details.
|
||||
|
||||
RESERVED REGISTERS: At all times, IX points to RSP TOS and IY
|
||||
is IP. SP points to PSP TOS, but you can still use the stack\
|
||||
RESERVED REGISTERS: At all times, IX points to RSP TOS and BC
|
||||
is IP. SP points to PSP TOS, but you can still use the stack
|
||||
in native code. you just have to make sure you've restored it
|
||||
before "next".
|
||||
|
||||
|
5
blk/286
5
blk/286
@ -10,7 +10,6 @@ lblnext BSET PC ORG @ 0x1b + ! ( next )
|
||||
DE RS_ADDR LDdn,
|
||||
DE SUBHLd,
|
||||
JRC, lblofl BWR ( IX < RS_ADDR? abortUnderflow-B285 )
|
||||
E 0 IY+ LDrIXY,
|
||||
D 1 IY+ LDrIXY,
|
||||
IY INCd, IY INCd,
|
||||
LDA(BC), E A LDrr, BC INCd,
|
||||
LDA(BC), D A LDrr, BC INCd,
|
||||
( continue to execute )
|
||||
|
7
blk/289
7
blk/289
@ -2,13 +2,12 @@
|
||||
( 1. Push current IP to RS
|
||||
2. Set new IP to the second atom of the list
|
||||
3. Execute the first atom of the list. )
|
||||
IY PUSH, HL POP, ( <-- IP )
|
||||
IX INCd, IX INCd,
|
||||
0 IX+ L LDIXYr,
|
||||
1 IX+ H LDIXYr,
|
||||
0 IX+ C LDIXYr,
|
||||
1 IX+ B LDIXYr,
|
||||
EXDEHL, ( HL points to PFA )
|
||||
( While we inc, dereference into DE for execute call later. )
|
||||
LDDE(HL),
|
||||
HL INCd,
|
||||
HL PUSH, IY POP, ( --> IP )
|
||||
B H LDrr, C L LDrr, ( --> IP )
|
||||
JR, lblexec BWR ( execute-B287 )
|
||||
|
8
blk/297
8
blk/297
@ -1,9 +1,9 @@
|
||||
CODE (br)
|
||||
L1 BSET ( used in ?br and loop )
|
||||
PC ORG @ 0x3d + ! ( stable ABI JP )
|
||||
E 0 IY+ LDrIXY, D 0 LDri,
|
||||
7 E BIT, IFNZ, D DECr, THEN,
|
||||
DE ADDIYd,
|
||||
LDA(BC), H 0 LDri, L A LDrr,
|
||||
RLA, IFC, H DECr, THEN,
|
||||
BC ADDHLd, B H LDrr, C L LDrr,
|
||||
;CODE
|
||||
CODE (?br)
|
||||
PC ORG @ 0x41 + ! ( stable ABI JP )
|
||||
@ -11,5 +11,5 @@ PC ORG @ 0x41 + ! ( stable ABI JP )
|
||||
HLZ,
|
||||
JRZ, L1 BWR ( br + 1. False, branch )
|
||||
( True, skip next byte and don't branch )
|
||||
IY INCd,
|
||||
BC INCd,
|
||||
;CODE
|
||||
|
2
blk/298
2
blk/298
@ -6,7 +6,7 @@ PC ORG @ 0x45 + ! ( stable ABI JP )
|
||||
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,
|
||||
BC INCd,
|
||||
;CODE
|
||||
|
||||
|
||||
|
5
blk/305
5
blk/305
@ -5,8 +5,7 @@ CODE EXECUTE
|
||||
|
||||
CODE EXIT
|
||||
PC ORG @ 0x0d + ! ( stable ABI JP )
|
||||
L 0 IX+ LDrIXY,
|
||||
H 1 IX+ LDrIXY,
|
||||
C 0 IX+ LDrIXY,
|
||||
B 1 IX+ LDrIXY,
|
||||
IX DECd, IX DECd,
|
||||
HL PUSH, IY POP, ( --> IP )
|
||||
JPNEXT,
|
||||
|
7
blk/306
7
blk/306
@ -3,8 +3,7 @@ PC ORG @ 0x25 + ! ( stable ABI JP )
|
||||
( Literal value to push to stack is next to (n) reference
|
||||
in the atom list. That is where IP is currently pointing.
|
||||
Read, push, then advance IP. )
|
||||
E 0 IY+ LDrIXY,
|
||||
D 1 IY+ LDrIXY,
|
||||
IY INCd, IY INCd,
|
||||
DE PUSH,
|
||||
LDA(BC), L A LDrr, BC INCd,
|
||||
LDA(BC), H A LDrr, BC INCd,
|
||||
HL PUSH,
|
||||
;CODE
|
||||
|
10
blk/307
10
blk/307
@ -3,9 +3,9 @@ PC ORG @ 0x2d + ! ( stable ABI JP )
|
||||
( Like (n) but instead of being followed by a 2 bytes
|
||||
number, it's followed by a string. When called, puts the
|
||||
string's address on PS )
|
||||
IY PUSH, HL POP, ( <-- IP )
|
||||
E (HL) LDrr, D 0 LDri,
|
||||
DE INCd,
|
||||
DE ADDIYd,
|
||||
HL PUSH,
|
||||
BC PUSH,
|
||||
LDA(BC), C ADDr,
|
||||
IFC, B INCr, THEN,
|
||||
C A LDrr,
|
||||
BC INCd,
|
||||
;CODE
|
||||
|
4
blk/308
4
blk/308
@ -1,6 +1,6 @@
|
||||
CODE ROT ( a b c -- b c a )
|
||||
HL POP, ( C ) DE POP, ( B ) BC POP, ( A ) chkPS,
|
||||
DE PUSH, ( B ) HL PUSH, ( C ) BC PUSH, ( A )
|
||||
HL POP, ( C ) DE POP, ( B ) IY POP, ( A ) chkPS,
|
||||
DE PUSH, ( B ) HL PUSH, ( C ) IY PUSH, ( A )
|
||||
;CODE
|
||||
CODE DUP ( a -- a a )
|
||||
HL POP, chkPS,
|
||||
|
4
blk/328
4
blk/328
@ -1,4 +1,4 @@
|
||||
CODE S=
|
||||
CODE S= EXX, ( protect BC )
|
||||
DE POP, HL POP, chkPS,
|
||||
LDA(DE),
|
||||
(HL) CPr,
|
||||
@ -12,4 +12,4 @@ CODE S=
|
||||
DJNZ, AGAIN,
|
||||
THEN,
|
||||
PUSHZ,
|
||||
;CODE
|
||||
EXX, ( unprotect BC ) ;CODE
|
||||
|
4
blk/603
4
blk/603
@ -1,5 +1,5 @@
|
||||
( Computes n into crc c with polynomial 0x1021 )
|
||||
CODE _crc16 ( c n -- c )
|
||||
CODE _crc16 ( c n -- c ) EXX, ( protect BC )
|
||||
HL POP, ( n ) DE POP, ( c )
|
||||
A L LDrr, D XORr, D A LDrr,
|
||||
B 8 LDri,
|
||||
@ -11,4 +11,4 @@ CODE _crc16 ( c n -- c )
|
||||
THEN,
|
||||
DJNZ, AGAIN,
|
||||
DE PUSH,
|
||||
;CODE
|
||||
EXX, ( unprotect BC ) ;CODE
|
||||
|
Loading…
Reference in New Issue
Block a user