anotherlin/z80emu

BIT n,(HL) and XY flags

Closed this issue · 1 comments

Hello, thank you for this emulator.
For the X and Y flags you take bit 3 and 5 from the L register.
According to this document http://www.grimware.org/lib/exe/fetch.php/documentations/devices/z80/z80.memptr.eng.txt it is a little bit more complicated...
Is it luck that your implementation results in correct values with ZEXALL.COM?
Or is that document wrong?

Hi,

Thank you for your interest for my emulator, hope you can find it useful for something.

I wrote the emulator about 10 years ago, but from what I remember. For the undocumented stuff, I just implemented what was described in Sean Young's "The Undocumented Z80 Documented" then tested it with "zexall.com", and it passed.

I've taken a look at your link, and if they're correct, that is X and Y flags taking bit 11 and 13 from MEMPTR (HL). Then it should be bit 3 and 5 from the H and not the L register.

However, I've just taken a look at the source code "zexall.z80" and the CRC computation is done using a 0xff mask flag, so all bits of the flag (in particular X and Y) are checked. See line 267 for the test of BIT n, (HL). So if the CRC values were taken correctly from the actual Z80, that would mean the document is wrong.

That being said, I don't think it would really matter in trying to emulate real programs.

Best regards,