Is there any way to read current Interrupt Mode in Z80 machine code?

Official Z80 datasheet mentions IMFa/IMFb registers which keep the mode value.all Z80 registers

Thank you

  • No, I don't think it's possible. You can't read those registers. Maybe you can figure out which more you're on by checking if interrupts are called and when? Commented Apr 13 at 17:07

2 Answers 2


The Mirage Microdriver (a snapshot device for the ZX Spectrum) needs to record the current interrupt mode when a snapshot is made. It does this by setting I to 80h and storing the address of an interrupt handler at 80FFh, then waiting for a timer interrupt. If the handler is called then the Z80 is in IM2, otherwise IM1 is assumed. The Multiface 3, another snapshot device, uses a very similar technique.

This method is specific to systems like the Spectrum where regular timer interrupts are issued, assumes that the value on the data bus during an interrupt is 0FFh (which may not be true even on the Spectrum, depending what devices are connected to the bus), and cannot distinguish between IM0 and IM1. However it's clearly the best that can be managed given the inability of the Z80 to report its current interrupt mode directly.


Is there any way to read current Interrupt Mode in Z80 machine code?

By the CPU alone: No.

There is no way to read out the content of the interrupt mode flip-flops.

Also, why should it? Interrupt mode chosen is related to the hardware of a system, nothing that would make sense to set other than defined by the hardware designer.

Looking close the existence of the IM instruction looks like a makeshift solution due not having enough pins free to set either mode by soldering - as the usual way would be for hardware dependent selections.

Of course, with a known system having cyclic interrupts or one able to issue an interrupt by software, it would be possible to change interrupt vectors to detect which is executed if a certain event happens. This can be done for all three modes.

But it's pointless, as to write such software one needs to know the hardware of that system, which in turn also means it's already known what interrupt mode is to be used to utilize that hardware.

  • 10
    It is not "pointless" and was really done as described in @john_e answer.
    – lvd
    Commented Apr 14 at 3:22
  • 2
    Disagree with your last paragraph: Well, yes, of course you need to know your hardware. IM0 is somewhat tied to your choice of peripherals, but on many computers, that still leaves a choice between IM1 and IM2 (See the ZX Spectrum).
    – tofro
    Commented Apr 14 at 11:00
  • 3
    The ZX Spectrum has never been "designed with peripherals to support M2". Still it can use it. Zilog were assuming you select your preferred interrupt mode when designing the hardware. Along these lines I can follow your argumentation. But Zilog didn't assume there would be people using IM2 on a machine that was designed for IM1 - well, how could they? Then why would they provide an instruction to retrieve information you constructed into the hardware? I get that as well. But still IM2 works on the Speccy and it works fine, and thus you might probably want to re-think your last paragraph.
    – tofro
    Commented Apr 15 at 6:59
  • 3
    Being able to read the complete CPU status is not 'hacking', it is just a feature that might become useful in some circumstances.
    – lvd
    Commented Apr 15 at 9:34
  • 6
    @raffzahn a false scottsman is not a true scottsman (google it). You argument basically works by declaring that supporting snapshot functionality is somehow not true "functionality" that the Z80 should support, but that is an obvious logical fallacy. It is functionality that you probably don't like somehow, but it's of course functionality. Commented Apr 16 at 3:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .