This adds support for illegal opcodes:
lax, dcp, isc, slo, rla, sre, rra, arr, sbx, las, usbc, jam, nops, sax, xaa, alr, anc
The illegal opcodes implementation caused README doc tests to hang:
1. First example used 0xff as program terminator
- Previously 0xff was unimplemented (returned None), stopping execution
- Now 0xff is ISC (INC+SBC) AbsoluteX, causing infinite loop
- Fix: Use 0x02 (JAM) which explicitly halts the CPU
2. Second example loads euclid.bin which uses BRK (0x00) to terminate
- BRK jumps to IRQ vector at $FFFE/$FFFF
- Uninitialized memory contains 0x00, jumping to address $0000
- This causes infinite loop executing whatever is in low memory
- Fix: Mark as no_run since it depends on external file anyway
- fix: make euclid.bin example runnable as doc test
- Replace BRK with JAM ($02) to halt CPU after illegal opcodes impl
- Fix assembly label structure (algo/algo_ were dead infinite loops)
- Simplify linker.cfg to output raw binary at $0010 (was 64KB image)
- Enable README doc test (remove no_run marker)
The old linker config produced a 64KB memory image with code at $0400,
but README loaded at $0010 causing address mismatch. New config outputs
only the code segment at the correct load address.
Co-authored-by: mlund <mlund@localhost>
Fixes critical bugs in the 6502 emulator and successfully passes
the Klaus2m5 functional test suite, one of the most complete test
suites for 6502 emulators (~30 million instructions).
Along the way, we fixed stack operation bugs that were preventing proper execution:
- RTI: Removed extra pull_from_stack() and fixed PCH retrieval
- RTS: Removed extra pull_from_stack() and fixed PCH retrieval
- PLA, PLP, PLX, PLY: Fixed to use single pull_from_stack() call
- pull_from_stack: Fixed to increment SP before reading (6502 SP points
to next available slot, not last used)
The emulator now passes one of the most rigorous 6502 test suite that I know of, which provides high confidence in our emulation correctness.
* start on separating 6502 variants from cpu itself
* add a single variant: the NMOS one
* get examples & tests running again
* Add the Revision A variant, one that has no ROR
* disable failing lint in build-time dependencies
* Variant with no decimal mode
* Revert "disable failing lint in build-time dependencies"
This reverts commit c87975e937.
* some doc comments
* specify the variant in unit test now the API has changed
---------
Co-authored-by: Sam M W <you@example.com>