skoolkid / skoolkit

A suite of tools for creating disassemblies of ZX Spectrum games.
https://skoolkit.ca
GNU General Public License v3.0
134 stars 15 forks source link

Add support for undocumented Z80 instructions #133

Closed morozov closed 3 months ago

morozov commented 4 months ago

Currently, Skoolkit disassembles the sequence of bytes 0xED70 as DEFB $ED,$70, however, this is an undocumented Z80 instruction IN F,(C) (source). It may not be supported by all Z80 replicas but is supported by at least some emulators (e.g. Fuse).

This instruction is used by Project O.T.L.A. to implement a turbo loader:

pi_LOW  inc a
        in f,(c)
        jp po, pi_LOW

        out (c),e
pi_HIGH inc a
        in f,(c)
        jp pe, pi_HIGH

It would be nice to have these instructions supported in Skoolkit. At least for the sake of completeness.

pobtastic commented 4 months ago

It's probably just something like this: https://github.com/skoolkid/skoolkit/pull/134

skoolkid commented 4 months ago

I'd want to make support for disassembling IN F,(C) (and perhaps OUT (C),0, and all the register-modifying SRO/SET/RES (IX/Y+d),r instructions) optional, not because they might not be supported by an emulator, but because they might not be supported by an assembler - which would be a problem if you're using skool2asm.py. Supporting these instructions also means making sure that skool2bin.py can assemble them.

I'll put this on the TODO list for SkoolKit 9.3. In the meantime you could use @pobtastic's diff for disassembling IN F,(C).

skoolkid commented 3 months ago

In 58a7b67b760d65361e05013c8e62f03d650ba61c I've added the Opcodes configuration parameter to sna2skool.py, with support for disassembling IN F,(C) and OUT (C),0. Example usage:

$ sna2skool.py -I Opcodes=ED70 prog.z80

Support for disassembling other instructions (e.g. the register-modifying DDCB- and FDCB-prefixed instructions, and the NEG, RETN, IM 0, IM 1 and IM 2 variants) may come later.

morozov commented 3 months ago

Thank you for making the changes, @skoolkid. I cannot test them at this moment but there's no reason to believe it won't work. I believe this issue can be closed.