1
0
mirror of https://github.com/mre/mos6502.git synced 2026-04-19 14:16:52 +00:00

17 Commits

Author SHA1 Message Date
Matthias 9385b99484 Add buble sort example 2026-02-06 16:42:17 +01:00
omarandlorraine c91d604efe Add support for illegal opcodes (#126)
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>
2026-02-06 16:19:01 +01:00
Matthias Endler 673e7e42e3 Functional Test (#81)
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.
2025-12-30 18:42:23 +01:00
Matthias 035ebe3c00 Fix clippy lints 2025-07-29 11:44:41 +02:00
omarandlorraine 11499b6bc8 Starting on implementing different variants (#88)
* 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>
2023-10-31 16:45:15 +01:00
Matthias Endler e88c971625 Add assembly example code (#80)
* Add assembly example code

This should make it easier for beginners to understand
how to test this emulator.

* cleanup

* fix typo
2023-06-20 10:32:28 +02:00
Sam M W 0708a1084c fix the tests back up 2023-04-03 07:39:18 +01:00
Sam M W a8dac6e805 extract memory functionality into a trait 2023-04-03 06:59:40 +01:00
Sam M W 3de8f9158d move tests and README away from Address 2022-10-18 10:01:55 +01:00
Sam M W 18e55aaeca remove call to .trim(), as clippy suggests 2022-08-09 04:14:46 +01:00
Matthias 7398fc4c3f Simplify GCD program 2022-06-07 20:17:44 +02:00
Matthias 363dc47755 Format code 2022-06-07 19:30:29 +02:00
GooseDB 6a0163138a refactoring 2019-10-13 01:22:57 +03:00
GooseDB 0e112a8a44 return newline 2019-10-13 00:19:09 +03:00
GooseDB c837d7c986 return comments 2019-10-13 00:18:07 +03:00
GooseDB 71ac36b083 return comment 2019-10-13 00:14:55 +03:00
GooseDB 8c70df142c new example 2019-10-13 00:07:53 +03:00