GARTHWILSON wrote:
I answered similarly, but then deleted my answer when I reviewed the question which was, "What happens if the processor receives an IRQ signal while executing the BRK z instruction?" which I take to be about what would happen if, let's say, a couple of cycles into the BRK instruction itself (not the BRK routine), IRQ\ goes low. We have the topic somewhere about the fact that one of the NMOS 6502 bugs is that if an NMI hits during a BRK instruction, the BRK interrupt will not get executed; but I don't know about IRQ. I'd have to try it.
Indeed
this thread included some nice Visual6502 experiments - it looks like
this one in particular demonstrates an IRQ occuring during the early stages of processing a BRK, and you can see the bug occur - the flags were pushed on cycle 8 with the B bit not set, but the PC was incremented before being pushed, so cycle 19 returned to the instruction after the BRK, without executing the handler with the B bit set at all.
Just to reinforce the point about this being an NMOS-only bug - the modern WDC 65C02 does not suffer this bug and will instead process both the BRK and the IRQ separately without fail.