How to get if Z80 is in DI or EI mode from the debugger?

By friguron

Expert (97)

friguron's picture

26-01-2020, 01:58


The title says it all: I can ask for "reg AF" and I get AF value, I ask for "reg IM" and I get interrupt mode...
But I can't find how to ask a live z80 session inside openmsx debugger for its DI/EI status...

Is the "reg" command the one returning this info? What's the proper command? I've looked for it into the documentation with no success.


Login or register to post comments

By wouter_

Champion (422)

wouter_'s picture

26-01-2020, 10:25


You were on the right track: the command to query this is reg IFF. The lower 3 bits (bits 0, 1 and 2) of this result respectively indicate: IFF1, IFF2 (these two are documented in the Z80 manual) and an extra artificial bit indicating that the Z80 could accept an IRQ before the next instruction (this is different from IFF1 right after an 'EI' instruction). So typically/simplified you'll get the value 0 for 'DI' and 7 for 'EI'.

I agree that there's only obscure documentation on this in openMSX. You have to know that the reg command is implemented in terms of the "cpu regs" debuggable. And then you can look at the description for that debuggable with the command debug desc "cpu regs".


> debug desc "CPU regs"
Registers of the active CPU (Z80 or R800).
Each byte in this debuggable represents one 8 bit register:

  0 ->  A      1 ->  F      2 -> B       3 -> C
  4 ->  D      5 ->  E      6 -> H       7 -> L
  8 ->  A'     9 ->  F'    10 -> B'     11 -> C'
 12 ->  D'    13 ->  E'    14 -> H'     15 -> L'
 16 -> IXH    17 -> IXL    18 -> IYH    19 -> IYL
 20 -> PCH    21 -> PCL    22 -> SPH    23 -> SPL
 24 ->  I     25 ->  R     26 -> IM     27 -> IFF1/2

The last position (27) contains the IFF1 and IFF2 flags in respectively
bit 0 and 1. Bit 2 contains 'IFF1 AND last-instruction-was-not-EI', so
this effectively indicates that the CPU could accept an interrupt at
the start of the current instruction.

By friguron

Expert (97)

friguron's picture

26-01-2020, 13:40

Fantastic! I'm testing it ASAP!


BTW, I was invoking this other help command: "help reg", which responds with similar info... It doesn't explain anything about IFF