1

I've been making a GameBoy emulator, and I'm currently running it through the test ROMs located here.

One of the tests in cpu_instrs.zip is as follows:

set_test 5,"POP AF"
ld   bc,$1200
.loop:
push bc
pop  af
push af
pop  de
ld   a,c
and  $F0
cp   e
jp   nz,test_failed
inc  b
inc  c
jr   nz,.loop

From what I understand, it seems like this test will always fail. On the first loop, the zero flag will not be set from inc c and then the code will eventually jump to test_failed since on the second loop, e will equal 1 and a will be 0.

What am I missing here?

  • 2
    It seems like finding another z80 system/emulator with a debugger where you can step through this would probably be informative. – Chris Stratton Apr 12 '14 at 23:58

1 Answers1

7

Turns out that the least significant nibble on the flags register is always zero, and writing a nonzero value to it shouldn't change it.