# Validation Every oracle found for the CMOS 65C02, its tier, its pin and licence, what was actually run in Phase 0, the rung plan, what no judge decides, and at the end **what the build measured, rung by rung**. Pins are in `scripts/pinned_files.json` and `scripts/pinned_repos.json`; `python -I scripts/fetch_references.py` fetches all of them into `reference/` (gitignored). ## Oracle tiers Best first. A lower tier detects differences; the highest tier that speaks to a question decides it. Emulators are detectors, never judges. 1. **Hardware-captured**: measurements of real chips, and die-level simulation. 2. **Manufacturer**: data sheets and specifications. 3. **Research**: community work that shows or states its measurements. 4. **FPGA cores** written from the die or schematics. 5. **Emulator-derived**: other emulators, and corpora generated by them. A self-checking program (Dormann's, Clark's) has the tier of the evidence that it passes on real hardware: here tier 1 for two parts, because captures of real chips running them exist. ## The oracles ### Logic-analyser captures of real 65C02s: tier 1 - Pins: `hoglet67/6502Decoder` @ `c32dd600` (`test/master/reset.bin.gz`, `test/beebr65c02/reset.bin.gz`, and the NMOS `beeb`, `elk` for contrast); its release asset `extended_tests.zip` (SHA-256 `db61cd3b...`, 71 MB): `master/{dormann_d6502,dormann_d65c10,clark_bcd_full}`, `beebr65c02/{dormann_d6502,dormann_d65c11,clark_bcd_full}`. Decoder: GPL-3.0, built and run as an external program. The captures carry no licence statement and are never committed. - What they are: David Banks's recordings (2018), 16 bits per CPU cycle: the data bus, RnW, SYNC, RDY, RST. Two machines: a **BBC Master** (GTE/CMD G65SC12, the `G65SC02` row) and a **BBC B with a Rockwell R65C02**. Each ran a reset and boot, Dormann's NMOS functional test, Dormann's 65C02 extended test (`d65c10`: built with the bit instructions tested as one-byte NOPs; `d65c11`: built with them tested as instructions; in both `wdc_op = 1`, so `$CB`/`$DB` are not executed) and Bruce Clark's full decimal test. - What they judge: cycles per instruction (SYNC to SYNC), which cycles write, every byte read and written, the reset and interrupt sequences, decimal results. About 100 million instructions in all. - What they cannot judge: addresses directly (no address bus; a read's data identifies the address when the lockstep's memory model knows what each address holds, which is how rung 4 decided the dummy-read addresses), anything the programs never execute (`BRK`, `$CB`, `$DB`), `WAI`/`STP`, the W65C02S, the Lynx cell, and when the IRQ line fell (it is not sampled), hence poll timing. - Also pinned: George Foot's `data14.bin.gz` (SHA-256 `52c20049...`), 8-bit samples of the data bus of a 65C02 with bit instructions running Dormann's 65C02 test (6502Decoder issue #10). No SYNC or RnW; the part's maker is not stated. Tier 1 for data values, weaker for cycle boundaries. - **Run in Phase 0** (`scripts/decode_capture.py`, 2026-11-11): all four extended 65C02 captures decode with 0 prediction failures; timing.md has the measured table. The Master and R65C02 reset captures give the reset rows. ### Die-level work: none found No transistor netlist, schematic recovery or switch-level simulation of any 65C02 was found (searched: visual6502 and its wiki, perfect6502, the Monster 6502, Silicon Pr0n, 6502.org, GitHub). visual6502 and the Monster 6502 are the NMOS 6502. WDC sells a Verilog RTL model and an extracted netlist of the W65C02S as licensed IP (DS sections 8, 9); neither is public. No die work on the Lynx's Mikey was found. This is recorded so the search is not repeated blind; a 65CE02 reverse-engineering thread exists on 6502.org (a different part). ### Manufacturer documents: tier 2 | Key | Document | Pin (SHA-256) | Licence | | --- | --- | --- | --- | | DS | WDC W65C02S data sheet, 8 April 2022 | `a6af3ca9...` | WDC, all rights reserved | | | WDC W65C02S data sheet, March 2000 | `b5ea0b68...` | WDC | | RDS | Rockwell R65C02/R65C102/R65C112 data sheet (scan, no text layer) | `63deee76...` | Rockwell | | GDS | GTE/CMD G65SCXXX family; CMD G65SC02-A (March 2000) | `4371922a...`, `1f9feafb...` | GTE/CMD | | VDS | VLSI Technology 1988 ASIC data book (VL65NC02: PDF pp. 233-246) | `5e1552b6...` | VLSI Technology | | NDS | NCR 1985 data book (NCR65C02: PDF pp. 430-439) | `a429263e...` | NCR | | LS | Epyx/Atari Lynx specification, chapters 4, 8, 10, 11 (HTML, hosted by 42Bastian Schick) | live documents | Epyx/Atari | None has a per-cycle bus table (the W65C816S data sheet's Table 5-7 has no 65C02 counterpart). They give opcode matrices, cycle counts, the NOP table and the "operational enhancements" table. Not obtained: WDC's programming manual (Eyes and Lichty, *Programming the 65816 including the 6502, 65C02 and 65802*): WDC's old URL is gone (404), wdc65xx.com refuses automated fetches (403), the Wayback Machine holds only an error page; a Synertek SY65C02 data sheet: not found. ### Research: tier 3 | Key | Source | Pin | What it gives | | --- | --- | --- | --- | | CL | Clark and Laughton, "65C02 Opcodes", 6502.org | live document | every difference from the NMOS part, the undefined-opcode grid, one-cycle NOPs and interrupts | | LK | Laughton, "KimKlone: Op-Code Mapping" | live document | `$5C`'s bus as observed; which NOPs really read memory | | GF | Foot, 6502Decoder issue #10 | the issue (not pinned; quoted in start-here.md) and his capture | `WAI`/`STP` on a real chip | | BC | Clark, "Decimal Mode", 6502.org | live document | the 65C02 decimal algorithms, the test program | | GW | Wilson, "NMOS-CMOS 6502 differences", "Investigating Interrupts" | live documents | which maker has which instructions, WDC's history, `WAI` use | ### drhelius "Lynx Hardware Tests", `cpu` suite: tier 3, the Lynx cells - Pin: `drhelius/lynx-tests` @ `a920f011` (MIT), sparse `/cpu/` (the same revision `lynx-python` pins in full, with the prebuilt ROMs of release 1.4.9). - Eight tests, expected values "made by analyzing actual hardware" on a Lynx I and a Lynx II (start-here.md lists them). The only evidence from real Lynxes about the cell: which model has the bit instructions (C12), `CLI` latency (U5), one-byte NOPs and IRQs (U7). - It needs a Lynx (timer 6, the display), so it cannot run on a bare core. It is `lynx-python`'s milestone 2 judge and this core's rung 9. - It checks results, not cycles. ### Self-checking programs - **Klaus Dormann's 65C02 extended opcodes test** and **Bruce Clark's decimal test**: pin `amb5l/6502_65C02_functional_tests` @ `966b1a35` (GPL-3.0; the ca65 ports; the same pin `6502-python` uses). `scripts/build_tools.py` assembles the extended test three times with cc65 2.19 (`wdc`: `wdc_op=1, rkwl_wdc_op=1`; `rockwell`: `0, 1`; `sc`: `0, 0`) and the decimal test with `cputype = 1`. **Built in Phase 0**; images load at `$0000`, start at `$0400`: | Image | SHA-256 | Success address | | --- | --- | --- | | `65C02_extended_opcodes_test_wdc.bin` | `1d35eaeb...` | `$24F1` | | `65C02_extended_opcodes_test_rockwell.bin` | `a7601cb8...` | `$2569` | | `65C02_extended_opcodes_test_sc.bin` | `47debe57...` | `$2434` | | `65C02_decimal_test.bin` | `7513fcfa...` | ends in its `JMP *`; `ERROR` byte 0 | The `wdc` image differs from Dormann's prebuilt `bin_files` image in 254 bytes (fill and data placement of the ca65 port; not investigated): take the success address from the build's own `.lst`, as above, and confirm it in the build session by running to it. The `rockwell` and `sc` images expect `$CB` and `$DB` to be one-byte NOPs (U3); the `sc` image expects `x7`/`xF` to be one-byte NOPs (C2). - Tier: the programs compute their own expected values. Real chips ran them (the captures above): the G65SC12 ran the `rkwl_wdc_op = 0, wdc_op = 1` build, the R65C02 the `1, 1` build. No capture of the `wdc_op = 0` builds. ### SingleStepTests 65x02, the CMOS sets: tier 5 - Pin: `SingleStepTests/65x02` @ `2f6980a2` (MIT), sparse `/wdc65c02/`, `/rockwell65c02/`, `/synertek65c02/`: 256 files each, 10,000 cases per file, one case per line: initial and final registers and RAM, and every cycle's address, value and direction. About 380 MB per set on disk. `wdc65c02` has **no cases for `$CB` and `$DB`** (empty files). `huc6280-python` holds `rockwell65c02` at the same revision (its rung 1b). - **Generated by an emulator**: the README says "an implementation is used that conforms to all available documentation, official and third-party; passes all other published test sets; and has been verified by usage in an emulated machine." The author also writes the emulator Clock Signal (pinned: `TomHarte/CLK` @ `5eae9b61`, MIT), whose 6502 has "Synertek", "Rockwell" and "WDC" 65C02 models with the same definitions as the three sets; that CLK is the generator is an inference. So: the volume detector, never a judge. - **Known to be wrong** against tier 1 and 2: `$5C` (C1), `x7`/`xF` in the Synertek set (C2); in conflict with tier 2 and 3: `$CB`/`$DB` (C3), `$DC`/`$FC` (C10). **Measured in Phase 0** with `scripts/survey_sst.py` (timing.md). **Found in the build** (rung 4, tier 1): the address of six more kinds of dummy read (C13 to C18): the decimal cycle, the indexed store within a page, `(zp),Y`'s extra cycle, the branch across a page, the two indirect jumps, and `zp,X`'s third cycle. Its results, cycle counts and directions were never found wrong outside C1, C2 and C3. ### FPGA cores: tier 4 at best, none from a die - https://github.com/MiSTer-devel/AtariLynx_MiSTer @ `3708e457` (Robert Peip's CPU; GPL-2.0; read in Phase 0, not fetched since 2026-11-24, Aubrey): written from documentation and software behaviour. - Not pinned, noted: Arlet Ottens's `verilog-65c02` (not cycle-exact: the decoder has a table of its deviations), Alan Daly's 65C02 core (likewise), Jens Gutschmidt's `cpu65c02_tc` ("true cycle", OpenCores; needs a login), T65's 65C02 mode. None claims a measurement beyond the data sheets. ### Other emulators: tier 5 | Source | Pin | Licence | Use | | --- | --- | --- | --- | | MAME 0.285 `m6502` family | `mamedev/mame` @ `f379cd06` (tag `mame0285`), the installed `mame` 0.285 binary | BSD-3-Clause (devices), GPL-2.0+ (drivers) | the trace detector, one driver per row ([mame-oracle.md](mame-oracle.md)); **run in Phase 0** | | 6502Decoder's `em_6502.c` | above | GPL-3.0 | an independent 65C02 model that a real chip's bus has been checked against; **run in Phase 0** as the capture decoder | | Felix (laoo) `libFelix/CPU.cpp` | `laoo/Felix` @ `f5a9cda3` | MIT | a per-cycle Lynx CPU; a second reading of the cell | | Handy `lynx/c65c02.h` | `libretro/libretro-handy` @ `bc55d462` | zlib | the long-standing Lynx emulator; instruction-stepped | | Clock Signal | above | MIT | what the corpus's generator assumed | ## What ran in Phase 0 (2026-11-11) | Script | What | Result | | --- | --- | --- | | `fetch_references.py` | 18 files, 10 repositories | all pins satisfied; nothing failed (the programming manual and a Synertek data sheet were never pinned: not obtainable) | | `build_tools.py` | `decode6502`; four test images | built (table above) | | `decode_capture.py` | six captures | 0 prediction failures; timing.md | | `survey_sst.py --cases 1000` | 768 corpus files | timing.md; 34 opcodes differ between sets | | `mame_trace.py` | `lynx` (with a cart), `apple2ee`, `cexpert`, `bbcm`, one emulated second each | 1,121,825 / 410,528 / 1,678,793 / 560,847 instruction lines | ## The rungs One rung per commit. Each names its judge and tier and has a measurable exit. "Row" means each of `W65C02S`, `R65C02`, `G65SC02`. | Rung | What | Judge and tier | Exit | | --- | --- | --- | --- | | 0 | The opcode tables: 256 entries per row, mnemonic, mode, bytes, base cycles | DS Table 5-2 and 7-1, RDS, GDS/VDS/NDS (tier 2); CAP's measured counts (tier 1) | a test holds each row against a table transcribed from the data sheets and against timing.md's measured counts; every difference from SST's grid is one of C1, C2, C3, C10 | | 1 | SingleStepTests, every case of every set, bus cycles included: `wdc65c02` on `W65C02S` (2,540,000 cases), `rockwell65c02` on `R65C02`, `synertek65c02` on `G65SC02` (2,560,000 each) | SST (tier 5, a detector) | every case passes registers, RAM, cycle count and every cycle's address, value and direction, **except** the classes counted by name, each tied to a C entry: C1 (10,000 per set), C10 (20,000 per set), C2 (320,000, Synertek set), C3 (20,000 in each of two sets). Any other failure is a bug or a new C entry | | 2 | Dormann's 65C02 extended test, the image for each row, and his NMOS functional test on each row | self-checking; tier 1 for `G65SC02` and `R65C02` (real chips ran these programs: CAP) | each run reaches its success address; a wrong `CMP` carry is shown to trap | | 3 | Clark's decimal test (`cputype = 1`) on each row | self-checking; tier 1 as above | `ERROR` = 0 with the pre-fill check `6502-python` uses; one wrong BCD sum is shown to fail | | 4 | **Capture lockstep**: replay each capture cycle by cycle. The harness feeds every read from the captured data bus (keeping a memory model to learn what each address holds) and compares, per cycle: read or write against RnW, opcode fetch against SYNC, written byte against the data bus, and a dummy read's captured byte against the memory model. Interrupt entries are injected where the capture shows one. `G65SC02` row on the Master captures, `R65C02` row on the Beeb captures | CAP (tier 1) | zero mismatches over the two reset captures and the four extended 65C02 captures (about 100 million instructions), or each mismatch explained as the machine's (the Master's stretched I/O cycles). U4 entries that the data settles are closed here; C1 and C2 are confirmed against the corpus | | 4b | The same for Foot's data-only capture, on `W65C02S` and `R65C02` | CAP (data only) | zero data mismatches, or the report says which row the chip was | | 5 | MAME lockstep: replay the per-instruction traces of `lynx`, `bbcm` (`G65SC02`), `cexpert` (`R65C02`), `apple2ee` (`G65SC02`: MAME's base device), comparing PC A X Y S P and cycle deltas | MAME 0.285 (tier 5, a detector) | 1,000,000 instructions per driver agree, or each disagreement is listed with which side a higher tier supports (expected: reset's stack cycles, C4, C5) | | 6 | Directed tests for reset, interrupts, `BRK`, `WAI`, `STP`, the poll, RDY stretches: one test per U and C entry, naming its source | DS, RDS, GDS (tier 2); GF, CL, LK (tier 3) | every U and C entry in undocumented-behavior.md has a test that pins the default and cites the entry | | 7 | Fault injection: at least 20 seeded faults (a dropped dummy cycle, a write for a read, D not cleared, a wrong NOP length per class, the decimal cycle missing, each row's distinguishing cells swapped) | the rungs above | every fault is caught by a named rung; a fault only rung 1 catches is listed as resting on tier 5 | | 8 | Tooling at the family bar: state, trace, debugger, disassembler, `python -m` | `6502-python`'s tooling tests; MAME's disassembler and cc65's `da65` as detectors | the hooks' tests pass for each row; all 256 opcodes of each row disassemble to the mnemonic and length of rung 0's table | | 9 | (the board's) `lynx-tests` `cpu.lnx` on `lynx-python`, once its milestone 2 passes: all eight tests, test 7 printing "LYNX 1" with the Lynx I row and "LYNX 2" with the Lynx II row | LT (tier 3, hardware-derived) | 18 result bytes equal the expected table for each model; a failure is raised here as an issue, not worked around in the board | Rung 4 is what this core has that its siblings do not: a tier-1 judge of cycle counts and read/write shapes for two of the three rows. The `W65C02S` row has no tier-1 judge beyond Foot's capture; say so in the README's claims. ### What no judge decides Labelled in code and docs as defaults, each a named setting of its row: U1, U2, U3, U5, U6, U7, U9, U10, and whatever part of U4 rung 4 cannot reach (addresses whose data does not identify them). ## What the build measured One row per rung as it passed, with the judge that actually ran, its tier and the counts. "Not met" would be said here, with the reason. CPython is 3.14.4, PyPy is 7.3.23 (Python 3.11.15). The exits are the table's above, as written. | Rung | Result | Judge that ran, tier | Measured | | --- | --- | --- | --- | | 0 | **Passed** 2026-11-12 (`0f9d37d`) | DS Table 5-2 and Table 7-1, GDS Table IV and Table V (tier 2, transcribed in `tests/datasheet.py`); CL sections 4 and 5 for the instructions Table IV lacks (tier 3); the counts measured on two real parts in timing.md (CAP, tier 1); the SST grid as a detector | `tests/test_tables.py`, CPython and PyPy. Documented opcodes per row: 212 (`W65C02S`), 210 (`R65C02`), 178 (`G65SC02`), 210 (`Lynx2Cell`). All 256 cells of DS Table 5-2. All 178 opcodes of GDS Table IV by mnemonic, bytes and cycles, with three stated exceptions: `BRA` (always taken: one more), `BRK` (two bytes: DS Table 4-1 note 5), `INC`/`DEC abs,X` (7, not the printed 6: C11). Every undefined opcode's bytes and cycles (DS Table 7-1, GDS Table V). 253 opcodes against the counts measured on the G65SC12 and the R65C02 (every opcode but `00`, `CB`, `DB`). The corpus grid differs from the rows in exactly `$5C` (C1), `x7`/`xF` of the Synertek set (C2) and `$CB`/`$DB` of the Rockwell and Synertek sets (C3): 37 files | | 1 | **Passed** 2026-11-12, with the exit's clause "a new C entry" used six times | SingleStepTests 65x02 @ `2f6980a2`, the three CMOS sets (tier 5: a detector) | `scripts/run_single_step.py`, all **7,660,000 cases**, on PyPy and on CPython with the same counts: **0 fail**. **5,777,843 pass in full** (registers, RAM, cycle count, every cycle's address, value and direction). **1,882,157 are counted under a named contradiction** and pass the reduced comparison of `tests/single_step.py` (everything the contradiction does not touch; for the dummy-address classes that is everything but the address and value of the named dummy cycle). Per set, W65C02S / R65C02 / G65SC02: full pass 2,032,582 / 2,032,832 / 1,712,429; C1 10,000 each; C2 - / - / 320,000; C3 - / 20,000 / 20,000; C10 20,000 each; C13 90,288 / 89,729 / 89,964; C14 24,939 / 25,127 / 25,209; C15 44,772 / 44,796 / 44,949; C16 12,558 / 12,314 / 12,408; C17 20,000 each; C18 309,997 / 309,995 / 309,996 (a case can be in two classes). The exit named C1, C2, C3 and C10; **C13 to C18 are new**, found by the capture lockstep: in each the corpus's dummy-read address is contradicted by the captures of two real parts (tier 1 against tier 5), so the core does not pass those cases in full and says so. B is not compared (the corpus stores a B bit; the chip has none) | | 2 | **Passed** 2026-11-12 | Dormann's 65C02 extended-opcodes test (the image built for the row) and his NMOS functional test, self-checking. Tier 1 for `G65SC02` and `R65C02` (captures of the real parts running them exist, and rung 4 replays those captures); no hardware evidence for `W65C02S` and `Lynx2Cell` | `scripts/run_programs.py` and `tests/test_dormann.py`, PyPy and CPython. Extended test, success trap reached: `W65C02S` `$24F1` (21,986,986 instructions, 66,907,091 cycles), `R65C02` and `Lynx2Cell` `$2569` (21,987,068; 66,916,134), `G65SC02` `$2434` (21,979,060; 66,874,616). NMOS functional test, `$3469` on all four rows (30,646,177 instructions, 96,561,331 cycles). The oracle can fail: with CMP's carry wrong on equality neither program reaches success; and each image on a row it was not built for (`rockwell` on `G65SC02`, `sc` on `R65C02`, `rockwell` on `W65C02S`) does not reach success | | 3 | **Passed** 2026-11-12 | Clark's decimal test, `cputype = 1`, invalid BCD included, A N V Z C checked; self-checking. Tier as rung 2 | `tests/test_decimal.py`, PyPy and CPython: `ERROR` = 0 at `$044B` on all four rows (18,396,348 instructions, 56,640,811 cycles), with `ERROR` pre-filled with `$A5` so that only the test's own store clears it. The oracle can fail: one wrong sum of the 131,072 (`$45 + $38 + 1`) leaves `ERROR` = 1, and so does V taken from the binary sum | | 4 | **Passed** 2026-11-12: zero mismatches, zero model differences | CAP: David Banks's captures of a BBC Master's G65SC12 (`G65SC02` row) and a BBC B's Rockwell R65C02 (`R65C02` row), 16 bits a cycle (**tier 1**) | `scripts/run_capture.py` (PyPy, 90 s to 4 minutes by machine load) and `tests/test_capture_replay.py`. All eight captures replay **to the end of the capture with no mismatch** (every cycle's direction against RnW, `cpu.sync` against SYNC, every written byte against the data bus, `step()`'s count against the cycles used) **and no model difference** (every read's byte against the memory model). G65SC12: reset 717,906 instructions, `dormann_d65c10` 24,027,452, `clark_bcd_full` 24,844,809, `dormann_d6502` 34,266,482: **83,856,649 instructions, 271,937,798 cycles, 32,982 interrupt entries and 1 reset**; 251,301,246 of 251,562,045 reads agreed with a byte the model knew (the rest were of I/O or of a byte not seen before). R65C02: reset 738,904, `dormann_d65c11` 23,613,972, `clark_bcd_full` 26,029,242, `dormann_d6502` 33,655,548: **84,037,666 instructions, 271,946,258 cycles, 32,790 interrupt entries and 1 reset**; 251,376,779 of 251,628,098 reads agreed. The exit asked for the two reset and four extended 65C02 captures; the two NMOS-test captures were replayed as well. Nothing had to be explained as the machine's: the Master's stretched I/O cycles carry RDY low and are dropped, and its paging is followed by the model (2,301 writes to ROM seen not to stick). Details below | | 4b | **Passed** 2026-11-12; the capture cannot tell the two rows apart | CAP, data bus only: George Foot's capture of a 65C02 with bit instructions running Dormann's 65C02 test (tier 1 for data, no SYNC or RnW) | `scripts/run_capture.py foot`: on `W65C02S` and on `R65C02`, 1,471,138 instructions and 5,242,857 cycles to the end of the capture, **no written byte differs and no read differs from the model** (4,480,940 reads agreed); the board's device registers at `$FF40-$FF6F` are left out of the model. The capture ends part of the way through the program (119 opcodes executed) and never executes `$CB` or `$DB`, the only cells in which the two rows differ, so it does not say which part it was. It does say what it was not: on `G65SC02` the replay is out of step at the first bit instruction (instruction 1,078,516) | | 6 | **Passed** 2026-11-12 | DS, RDS, GDS, VDS, NDS (tier 2); CL, LK, GF, GW, LT (tier 3); CAP (tier 1) where the entry is one the captures settled. Each test's docstring names its source; where no source decides, it says it pins a default | `tests/test_directed.py`, CPython and PyPy: 337 tests (51 functions) when the rung passed, at least one named for and citing each of the 31 entries U1 to U13 and C1 to C18 (the last test checks that); 341 tests and 32 entries since rung 5 added C19 with its test. Among them: reset per row (seven cycles, SYNC in the first, reads or writes, I set, D cleared, nothing else touched); the bus of 65 sequences written out by hand from timing.md, on all four rows; `CLI`, `SEI` and `PLP` against the poll; a request in the last cycle and in the one before; `BRK` with an NMI pending; `WAI` (waiting cycles, wake with I clear and set, IRQ already low, a request made in a waiting cycle), `STP`; one-cycle NOPs and a pending IRQ; a stretched write cycle with `note_stall()` (U12, the Lynx's request 3); `sync`, `fetch` and `opcode` inside the callback; LT `cpu` test 7's four probes on both Lynx rows; `step()`'s return against the callbacks for every opcode of every row | | 5 | **Passed** 2026-11-12: more than 1,000,000 instructions per driver, every disagreement listed and decided | MAME 0.285 (tier 5: a detector), traces recorded with every bus access (`scripts/mame_trace.py --bus`) | `scripts/run_mame_replay.py` (PyPy) and `tests/test_mame_replay.py` (CPython and PyPy). `lynx` 1,120,163 instructions and 1,658 interrupt entries, `bbcm` 1,112,640 and 323, `apple2ee` 1,177,619 and 0 (all on `G65SC02`), `cexpert` 1,683,330 and 489 (`R65C02`): **5,093,752 instructions and 2,470 interrupt entries; no register, flag or written byte differs**. 65 cycle counts differ, of two kinds: the `abs,X` shifts within a page (core 6, MAME 7; 57 executions: the data sheets and the captures support the core, new entry C19), and `STZ $FD91` on the Lynx (8 executions: MAME's CPU-halt for `CPUSLEEP`, the board's). The disagreements the exit expected (reset's stack cycles, C4, C5) are outside these traces, which start after reset and never execute `$CB`/`$DB`. Beyond the exit: two drivers of MAME's "WDC W65C02S" device replayed on the `W65C02S` row, `cmmb103` (5,334,258 instructions, 383,172 of them bit instructions) and `arbv2` (5,360,310 and 1,305 interrupt entries): no difference of any kind; neither executes `WAI` or `STP`. Details in mame-oracle.md | | 7 | **Passed** 2026-11-12: 44 of 44 seeded faults caught, none by rung 1 alone | the rungs above, run on a faulted copy of `src/` | `scripts/seeded_faults.py`: 44 faults (the exit asked for at least 20: dropped dummy cycles, a write for a read, D not cleared by each of interrupt, `BRK` and reset, a wrong length for each NOP class, the decimal cycle missing, each row's distinguishing cells swapped, and the corpus's dummy address for each of C10 and C13 to C18). The control run passes every judge. Rung 4 catches 31, rung 6 40, rung 1 23, rung 2 14, rung 0 10, rung 8 8, rung 3 3. 37 are caught by a tier-1 judge; the other 7 rest on tiers 2 and 3 (the directed tests). The matrix is below | | 8 | **Passed** 2026-11-12 | 6502-python's tooling through its hooks (`StepRecord`, `DebugSession`, `CommandDebugger`, the trace functions at `741419a`); the data sheets' tables for the disassembler (tier 2); MAME's dispatch tables and cc65 2.19's `da65` as detectors | `tests/test_tooling.py`, 60 tests, CPython and PyPy. All 256 opcodes of each of the four rows disassemble to the mnemonic and length of rung 0's tables (DS Table 5-2 and Table 7-1, GDS Table V). Against MAME 0.285's `dw65c02.lst`, `dr65c02.lst` and `dw65c02s.lst`: every mnemonic and operand length agrees except `$CB`/`$DB` on its Rockwell device (C5) and `BRK`'s length. Against `da65`: all 178 opcodes of its `65SC02` and all 212 of its `65C02`, but for `BRK`'s length. State round-trips per row (`WAI`, `STP` and the poll fields included) and is validated; `next_boundary` predicts every kind of step; records, traces and the console work per row (the same byte decodes as the row runs it; a trace reads back equal; two rows' traces diverge at the bit instruction); `python -m w65c02_python` runs, traces and debugs an image | ### Rung 4 in detail: what the captures decided **Starting state.** The reset captures start at the reset sequence. The G65SC12 pushes PC and P there, so its flags are known; the R65C02's V flag was unknown until its first `PHP` (instruction 158,777), where the replay restarted with V as the chip had it. The six long captures start in the middle of a run: the registers come from the capture decoder (`decode6502`) at the first instruction where it knows all of them (sample 815,158 to 1,294,511 by capture), and everything after that is the core's own. **Interrupts.** 65,772 entries were injected where the captures show one (three writes in cycles 3 to 5 that are not a `BRK`); the core took every one as an IRQ at that boundary, each seven cycles, B clear, the vector bytes agreeing with the model. No entry began at a boundary where the core's poll rule forbids one (directly after `CLI`, `PLP` or a one-cycle NOP). The IRQ line itself is not in the captures, so this is agreement about where interrupts began, not a test of latency (U5). **Dummy-read addresses (U4).** A slot is one cycle of one opcode. For each kind of dummy read, the reads that agreed with the model out of the reads made, G65SC12 | R65C02 | Foot's chip; not one read of any slot differed: | Dummy read | Address the core uses | G65SC12 | R65C02 | Foot | | --- | --- | --- | --- | --- | | one-byte instruction, cycle 2 | PC (the next opcode) | 3,373,433 / 3,374,596 | 3,517,021 / 3,518,238 | 30,793 / 30,807 | | `zp,X`, cycle 3 (C18) | PC+1 again | 605,377 / 605,377 | 605,358 / 605,358 | 80 / 80 | | `(zp,X)`, cycle 3 (C18) | PC+1 again | 342,198 / 342,198 | 343,496 / 343,496 | none run | | indexed store, cycle 4 (C14) | the operand's address, or PC+2 across a page | 95,838 / 96,393 | 95,648 / 96,230 | 7 / 99 | | `INC`/`DEC abs,X`, cycle 4 (C14) | the same | 13,709 / 13,715 | 14,020 / 14,077 | none run | | `STA (zp),Y`, cycle 5 (C15) | the pointer's high byte again | 150,267 / 150,267 | 63,536 / 63,536 | 29,952 / 29,952 | | `JMP (abs)`, cycle 4 (C17) | PC+2 again | 444,802 / 444,802 | 451,191 / 451,191 | 3 / 3 | | `JMP (abs,X)`, cycle 4 (C17) | PC+2 again | 484 / 484 | 3 / 3 | none run | | read-modify-write on zero page, second read | the operand | 1,156,266 / 1,156,266 | 1,157,305 / 1,157,305 | 403 / 403 | | pulls, cycle 3 | the stack before the increment | 9,985,488 / 9,985,504 | 9,974,125 / 9,974,147 | 468 / 468 | | `JSR`, cycle 3 | the stack | 1,987,299 / 1,987,315 | 1,986,981 / 1,987,002 | 30,490 / 30,493 | | `RTS`, cycle 6 | the pulled address | 1,987,327 / 1,987,347 | 2,019,812 / 2,019,837 | 30,492 / 30,492 | | interrupt entry, cycles 1 and 2 | PC twice | 65,962 / 65,964 | 65,577 / 65,580 | none | | `BBR`/`BBS`, cycles 3, 4 and 6 | the zero-page byte twice; PC+3 | no such instruction | 10,400 / 10,400 | 10,400 / 10,400 | | `$5C`, cycles 5 to 8 (U9) | `$FFFF` | 12 / 12 | 12 / 12 | 11 / 12 | | `$5C`, cycle 4 (U9) | `$FF00` + low operand | 1 / 3 | 1 / 3 | 1 / 3 | | `$DC`, `$FC`, cycle 4 (C10) | the absolute address | 4 / 6 | 4 / 6 | 4 / 6 | The decimal cycle (C13), the branch across a page (C16) and the `(zp),Y` read across a page (C15) are counted inside their opcodes' slots and likewise never differ. Each address was found by trying the corpus's first and reading the differences; rung 7 seeds each of the corpus's addresses back in and the lockstep reports it (for `$DC`/`$FC` the corpus's address differs from the model in all 6 executions on each part; for `$5C`, MAME's reading differs in all 3). **What it closes.** U4 except the cases listed in undocumented-behavior.md. C1 (`$5C` is 8 cycles on both parts) and C2 (`x7`/`xF` are one cycle on the G65SC12) are confirmed against the corpus: with the corpus's counts the core is out of step with SYNC. C10, C13 to C18. U11 for two parts (Clark's whole test, every result and flag written to memory or pushed, agrees). **What it cannot say.** Addresses directly (it infers them); the W65C02S and the Lynx cells, beyond Foot's capture; `BRK`, `WAI`, `STP`, `$CB`/`$DB` (never executed); interrupt latency. ### Rung 7 in detail: the seeded faults `python scripts/seeded_faults.py` (the list is in the script; 2026-11-12, 45 minutes). Each fault is a change of a few lines in a scratch copy of `src/`; every judge is then run on the copy: rung 0 (`tests/test_tables.py`), rung 1 (SingleStepTests, 250 cases a file), rung 2 (Dormann's two programs on all four rows), rung 3 (Clark's test), rung 4 (the capture lockstep, the first million instructions of each of the ten replays), rung 6 (`tests/test_directed.py`), rung 8 (`tests/test_tooling.py`). With no fault every judge passes (the control run). An `x` is a judge that failed, that is, caught the fault. | Seeded fault | 0 | 1 | 2 | 3 | 4 | 6 | 8 | | --- | --- | --- | --- | --- | --- | --- | --- | | a dropped dummy cycle: PLA without its read of the stack | | x | | | x | x | | | a dropped dummy cycle: one-byte instructions take one cycle (TAX) | | x | | | x | | | | a write for a read: read-modify-write writes twice, as the NMOS part | | x | | | x | x | | | the decimal cycle missing | | x | | | x | x | | | INC and DEC abs,X take six cycles within a page, as the shifts (C11) | x | x | | | x | x | | | ASL abs,X always takes seven cycles, as the NMOS part | x | x | | | x | x | | | STA abs,X takes four cycles within a page | x | x | | | x | x | | | JMP (abs) keeps the NMOS part's page-wrap bug | | x | x | | x | x | | | a wrong NOP length: the x2 NOPs are one byte | | x | x | | x | | | | a wrong NOP length: one-cycle NOPs take two cycles, as $EA | x | x | | | x | x | x | | a wrong NOP length: $5C takes four cycles, as the corpus has it (C1) | | x | | | x | x | | | a wrong NOP length: $44 is three bytes | x | x | x | | x | x | x | | a wrong NOP length: $DC and $FC are two bytes | | x | x | | x | x | | | rows swapped: the G65SC02 has the bit instructions | x | x | x | | x | x | x | | rows swapped: the R65C02 has WAI and STP, as MAME's (C5) | x | x | x | | | x | x | | rows swapped: the R65C02 writes the stack at reset | | | | | x | x | | | rows swapped: the G65SC02 reads the stack at reset | | | | | x | x | | | rows swapped: the Lynx II's cell has no bit instructions (C12) | x | | x | | | x | x | | rows swapped: the W65C02S has no WAI or STP | x | | | | | x | x | | D not cleared by an interrupt entry | | | | | x | x | | | D not cleared by BRK | | x | x | | | x | | | D not cleared by reset | | | | | | x | | | an interrupt entry pushes P with B set | | | | | x | x | | | BRK is one byte: the return address is PC + 1 | | x | x | | | x | | | BIT #imm copies N and V from the operand | | x | x | | x | x | | | TSB takes Z from the stored result, as the HuC6280 | | x | x | | x | x | | | decimal ADC takes V from the binary sum | | x | | x | x | x | | | decimal SBC keeps the NMOS part's result for invalid digits (BC 4d dropped) | | x | x | x | | x | | | decimal ADC gives N and Z of the binary sum, as the NMOS part | | x | x | x | x | x | | | RMB and SMB act on the wrong bit | | x | x | | | | | | corpus address: zp,X reads the unindexed zero-page address (C18) | | | | | x | x | | | corpus address: an indexed store within a page re-reads PC+2 (C14) | | | | | x | x | | | corpus address: STA (zp),Y re-reads PC+1 (C15) | | | | | x | x | | | corpus address: a branch across a page reads the old page (C16) | | | | | x | x | | | corpus address: JMP (abs) reads the pointer first (C17) | | | | | x | x | | | corpus address: the decimal cycle re-reads the last operand byte (C13) | | | | | x | x | | | corpus address: $DC and $FC re-read PC+2 (C10) | | | | | x | x | | | MAME's reading: $5C reads the next opcode's address (U9) | | | | | x | x | | | CLI admits a pending IRQ at once | | | | | | x | x | | one-cycle NOPs poll (U7) | | | | | | x | | | an operand read looks the bus callable up before its addressing cycles | | | | | | x | | | SYNC is not raised in the first cycle of an interrupt entry | | | | | x | x | | | WAI waits even when IRQ is already low | | | | | | x | | | the disassembler gives BBR and BBS two bytes | x | | | | | | x | How to read it: - **No fault rests on tier 5 alone**: none is caught only by rung 1. - **37 of the 44 are caught by a tier-1 judge** (rungs 2, 3 or 4). Rung 4 alone catches 31, among them every dummy-read address the corpus has otherwise: with the corpus's address back in, rung 1 passes those cases in full and says nothing, and the lockstep reports model differences. - **Seven rest on tiers 2 and 3 only** (the directed tests, and for two of them the tables or the tooling): the W65C02S's `WAI`/`STP` (DS), D cleared by reset (DS Table 7-1), `CLI`'s delay (LT, the frame's rule), one-cycle NOPs and the poll (CL, LT), `WAI` with IRQ already low (GF), the callable-lookup trap (the frame's contract), and the disassembler's length of `BBR`. None of these is something the captures or the programs can see: they do not execute `WAI`, do not sample the IRQ line and do not change requests inside a callback. - The lockstep here ran the first million instructions of each capture, not the whole: two faults it would catch further in (`RMB` on the wrong bit; decimal `SBC` with invalid digits) show as caught by other rungs only. - `D not cleared by BRK` and `BRK is one byte` are not seen by rung 4 because no capture executes `BRK` (timing.md): Dormann's programs and the directed tests carry them.