Z80OPS.TXT
----------
"Request For Comments"
Sorry, group, but I am working on a Z-80 problem, and cannot
find my doc! (Maybe I should finally do some house cleaning?)
I need to translate in 8080 a program using the following Z-80
mnemonics:
1) DJNZ label
2) LDIR
3) LDDR
4) CPDR
5) RLC B
6) SBC HL,DE
7) SBC DE,HL
8) LD BC,(label)
9) LD DE,(label)
10) LD (label),DE
The only thing I found so far is a French translation of the
"Z-80 CPU Technical Manual". My favorite books by Alan Miller
are "somewhere" buried in my stuff.
Here is my first draft at solving the problem.
1) DJNZ label
decrement B-reg
jump "label" if not zero
so, this must be:
DCR B
JNZ label
2) LDIR
(DE) <-- (HL) ("symbolic operation" in Z-80 Manual)
DE <-- DE+1
HL <-- HL+1
BC <-- BC-1
Repeat until BC=0
so, this must be:
Loop1:
MOV D,H
MOV E,L
INX D
INX H
DCX B
JNZ Loop1
But when is a byte moved? Something is missing.
3) LDDR
(DE) <-- (HL)
DE <-- DE-1
HL <-- HL-1
BC <-- BC-1
Repeat until BC=0
so, this must be:
Loop1:
MOV D,H
MOV E,L
DCX D
DCX H
DCX B
JNZ Loop1
But, again, I don't see any byte moved. (Normally, in the 8080,
HL is used to "point" to a byte. So, there must be a "MOV A,M"
and "MOV M,A" somewhere. I think that the "(DE) <-- (HL)"
must be replaced by "A <-- (HL)" and "(DE) <-- A". What do
you think? And there is also the problem of the number of bytes
to move...)
4) CPDR
A <-- (HL)
HL <-- HL-1
BC <-- BC-1
Repeat until A = (HL) or BC = 0
so, this must be:
Loop1:
MOV A,M
DCX H
DCX B
???
since BC has just been decremented, we can jump if BC = 0
JZ Loop1
and, to compare A with (HL), we could use:
LXI label
CMP M
JC Loop1
5) RLC B
rotate left circular B-reg
???
6) SBC HL,DE
subtract with Carry
A <-- A-s-CY ("s is any of r,n") ???
7) SBC DE,HL
idem
8) LD BC,(label)
B-reg <-- (label+1) (or "HIGH (label)")
C-reg <-- (label) (or "LOW (label)")
so, this must be:
LXI H,label
MOV C,M
INX H
MOV B,M
9) LD DE,(label)
D-reg <-- (label+1)
E-reg <-- (label)
so, this must be:
LXI H,label
MOV E,M
INX H
MOV D,M
10) LD (label),DE
(label+1) <-- D-reg
(label) <-- E-reg
so, this must be:
LXI H,label
MOV M,E
INX M
MOV M,D
Of course, DJNZ and LDIR are pretty "standards" (in fact, the
BIOS of CP/M Plus has a function providing a
hardware-independent LDIR...), but I am concerned about the
accuracy of translation of the other opcodes.
Relevent comments appreciated.
Yours Sincerely,
"French Luser"
EOF