1
0
mirror of https://github.com/mre/mos6502.git synced 2026-03-10 23:28:17 +00:00
Files
Matthias Endler 9ff04c75f1 Add interrupt handling (NMI, IRQ) and WAI/STP wait states (#122)
Implements hardware interrupt support following the W65C02S datasheet:

Interrupt handling:
- Add nmi_pending() and irq_pending() to Bus trait
- NMI: edge-triggered (falling edge detection)
- IRQ: level-triggered, maskable by I flag
- service_interrupt() pushes PC/status, sets I flag, jumps to vector

Wait states:
- Replace `halted: bool` with WaitState enum (Running,
  WaitingForInterrupt, WaitingForReset)
- WAI instruction waits for interrupt, resumes on IRQ or NMI
- STP instruction waits for reset

Helper methods:
- Add push_address() for pushing 16-bit addresses to stack
- Add set_word() to Bus trait for writing 16-bit values

Testing:
- Integrate Klaus2m5 interrupt test suite
- Add unit tests for IRQ, NMI, and WAI behavior
- Concurrent BRK+IRQ+NMI test disabled (hardware timing edge case)

References:
- W65C02S Datasheet, Section 3.4 (IRQB) and 3.6 (NMIB)
- Klaus2m5/6502_65C02_functional_tests

Closes #64
2026-02-06 17:16:13 +01:00
..
2025-12-30 18:42:23 +01:00
2026-01-10 18:02:49 +01:00