clueless_engineer (Brett)
Experienced Member
Hello,
I'm trying to back-convert, if that's the word, the original Sargon Z80 code to 8080 as a way to learn assembly. There's lot of 8080 -> Z80 but not so much the other way.
I know it has been done (March-April 1979 issue of Recreational Computing alludes to it, using macros to replace Z80-specific mnemonics) but I've not seen any source code.
In particular, I'm curious how to convert instructions that use the Z80 index registers IX and IY that don't exist on the 8080.
I'm using the Z80 source here rather than the TDL code in the book.
This example, in which we initialise the 10x12 board (120 bytes), is where I'm stuck at the moment. I'm assuming we're going to have to do a bit more manipulation than since {LD IX} instructions.
INITBD: LD b,120 ; Pre-fill board with -1's
LD hl,BOARDA
back01: LD (hl),-1
INC hl
DJNZ back01
LD b,8
LD ix,BOARDA
IB2: LD a,(ix-8) ; Fill non-border squares
LD (ix+21),a ; White pieces
SET 7,a ; Change to black
LD (ix+91),a ; Black pieces
LD (ix+31),PAWN ; White Pawns
LD (ix+81),BPAWN ; Black Pawns
LD (ix+41),0 ; Empty squares
etc.
I'm trying to back-convert, if that's the word, the original Sargon Z80 code to 8080 as a way to learn assembly. There's lot of 8080 -> Z80 but not so much the other way.
I know it has been done (March-April 1979 issue of Recreational Computing alludes to it, using macros to replace Z80-specific mnemonics) but I've not seen any source code.
In particular, I'm curious how to convert instructions that use the Z80 index registers IX and IY that don't exist on the 8080.
I'm using the Z80 source here rather than the TDL code in the book.
This example, in which we initialise the 10x12 board (120 bytes), is where I'm stuck at the moment. I'm assuming we're going to have to do a bit more manipulation than since {LD IX} instructions.
INITBD: LD b,120 ; Pre-fill board with -1's
LD hl,BOARDA
back01: LD (hl),-1
INC hl
DJNZ back01
LD b,8
LD ix,BOARDA
IB2: LD a,(ix-8) ; Fill non-border squares
LD (ix+21),a ; White pieces
SET 7,a ; Change to black
LD (ix+91),a ; Black pieces
LD (ix+31),PAWN ; White Pawns
LD (ix+81),BPAWN ; Black Pawns
LD (ix+41),0 ; Empty squares
etc.