FA-89590 / Instruction set emulation / Member archive
Return from interrupt pops pc before flags · case 05
rti restores the saved flag into pc and the saved pc into I.
Case contract
Input [pc, i, steps] with steps [irq, nmi, instr]. Each step: an NMI 0->1 edge (the line starts low) is taken first; otherwise a high IRQ line is taken when the I flag is 0; otherwise the instruction runs (nop/cli/sei advance pc by 1, rti pops I then pc if the stack is non-empty). Taking an interrupt pushes pc then I, sets I=1 and jumps to 0x9000 (NMI) or 0x8000 (IRQ). The NMI edge detector samples the line every step. Return [event, pc, I] per step.
Why this case matters
Interrupt controllers in CPU emulators must separate edge- and level-triggered sources, masking and nesting to reproduce handler timing.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| masked irq waits for cli | [["nop", 257, 1], ["cli", 258, 0], ["irq", 32768, 1], ["rti", 0, 258], ["nop", 1, 258], ["nop", 2, 258], ["nop", 3, 258], ["nop", 4, 258], ["nop", 5, 258]] | [["nop", 257, 1], ["cli", 258, 0], ["irq", 32768, 1], ["rti", 258, 0], ["nop", 259, 0], ["nop", 260, 0], ["nop", 261, 0], ["nop", 262, 0], ["nop", 263, 0]] | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗