Z-80 code question about a loop that depends on the contents of the refresh register
ethan.dicks at gmail.com
Tue Dec 13 16:49:47 CST 2016
I'm disassembling a vintage program and ran across this bit of code
that is causing emulators to hang...
JP M, MYSUB
JR Z, MYSUB
LD A, 0x32
I know plenty of 8-bit assembler (mostly 6502, 1802, and a couple
others), but I'm by no means expert on the Z-80. It appears that this
subroutine is spinning on the value of the refresh register if it's
zero or negative, then if it's below 0x65, return the former contents
of the refresh register and if not, return 0x32?
If it helps, this is from a CP/M game. I'm wondering if this is some
sort of randomizer or delay routine.
So far, this loop hangs on all three emulators I've tried - simh's
altairz80, simcpm010 for AmigaDOS, and EMUZ80 for Raspberry Pi. I'm
guessing none of these environments emulate specific behavior of the
Does anyone have any comments or insights about what this is really
doing and what the right thing to do for emulators is? I can patch
this if that's what's needed, but I'd like to understand it first.
More information about the cctalk