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
6502 Functional Test
This is a test suite for 6502/65C02/65C816 processors. It contains a plethora of tests, which covers all documented opcodes.
Note that the binary was not built from the source code in the repository, but pre-built binaries were used instead. That is because the source code is not compatible with the assembler used by the cc65 toolchain.
Building
make build
This will create a 6502_functional_test.bin file, which the emulator will
load.
Running
Then, from the root of the repository, run:
cargo run --release --example functional
Credits
Taken from https://github.com/amb5l/6502_65C02_functional_tests which is a CA65-compatible port of https://github.com/Klaus2m5/6502_65C02_functional_tests
The original source code was written by Klaus Dormann, and is licensed under the GPL-3.0 license.
6502 Timing Test
The 6502_timing_test.bin file is from the dp111/6502Timing project:
https://github.com/dp111/6502Timing
This test ROM validates instruction cycle timing for the 6502 processor.
The ROM includes undocumented/illegal 6502 instructions which are not implemented in this emulator. Therefore, it cannot run successfully yet.
The timing test ROM is kept here for reference and potential future use if undocumented instruction support is added.
Credits
Created by dp111, licensed under the 3-Clause BSD License.