skoolkit icon indicating copy to clipboard operation
skoolkit copied to clipboard

Add support for undocumented Z80 instructions

Open morozov opened this issue 1 year ago • 2 comments

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.

morozov avatar May 05 '24 20:05 morozov

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

pobtastic avatar May 05 '24 22:05 pobtastic

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 avatar May 06 '24 11:05 skoolkid

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.

skoolkid avatar May 22 '24 20:05 skoolkid

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.

morozov avatar May 28 '24 22:05 morozov