kosarev / z80

Fast and flexible Z80/i8080 emulator with C++ and Python APIs
MIT License
63 stars 10 forks source link

Fixed undocumented BIT instructions #21

Closed simonowen closed 3 years ago

simonowen commented 3 years ago

They should be BIT b,(ix+d) but were being treated as BIT b,r.

kosarev commented 3 years ago

Oh, I completely forgot about these. Thanks a lot for catching this! I will need to look into it deeper, as it seems it's not just BIT but the whole bunch of undocumented DD/FD CB instructions, some of which have their own special semantics, e.g, SET 0,(IX+10h),B (DDCB10C0), meaning we would need to figure out how to extend the API and disassembler to represent all that.

simonowen commented 3 years ago

I think the other instructions might already be covered, from what I remember. The BIT instructions are an exception since they don't modify anything and there's no result to write back, so there's no ,r behaviour.

kosarev commented 3 years ago

Right, the undocumented instructions are semantically undistinguishable from their official versions, but the convention for this implementation is that we disassemble all instructions in a way that makes clear their specific encodings -- that's including all and any undocumented instructions.

I will revisit other bits related to all the DD/FD CB instructions and am adding tests for all existing encodings along with resolving some long-standing problems. For now, let's just submit this change and then update things as necessary.

Thanks once again for the fix!