# Validation plan and oracle inventory ## The claim this project will make, and the one it cannot When the core exists, the strongest claim available today is: > a pure-Python 6809 instruction core whose semantics, flags, bus-cycle > counts and interrupt entry agree with MAME 0.285's `m6809` over the > `neetandev/m6809` corpus and over multi-million-instruction traces of real > Williams arcade code; whose undocumented-opcode and undefined-flag rules > follow hoglet67's and Flamand's hardware captures where MAME simplifies > them; and which agrees with XRoar's independently written core wherever > the two have been compared. It cannot claim "verified against real silicon" for the documented instruction set, because **no hardware-captured single-step corpus exists for the 6809** (below). Hardware evidence exists only for the undocumented corners (hoglet67, Flamand) and, indirectly, for one 2003 self-checking program (Schwotzer). Under the tier rule that means the judge for documented behaviour is the **datasheet plus the programming manual**, and the emulators are detectors: when two independent emulators and the datasheet agree, the core must agree with them; when emulators disagree with each other, the datasheet decides; when the datasheet is silent, the rule is stated as `[unverified]` and follows the hardware-captured source if one exists. ## Oracle tiers | Tier | Meaning | 6809 sources | | --- | --- | --- | | **hardware-captured** | expected values read off a real 6809's bus or registers | hoglet67 6809Decoder wiki + test programs; Flamand's document; the FM-77AV observation quoted by `neetandev` (mixed-width TFR/EXG only) | | **hardware-corrected** | a self-checking program whose assertions were adjusted until a real 6809 passed them | Schwotzer's `6809test.asm` (EF6809P, 2003), as far as its header states | | **emulator-derived** | values produced by another emulator | `neetandev/m6809` (MAME), MAME 0.285 traces, XRoar 1.12, vecx | | **datasheet** | the manufacturer's stated behaviour, with "undefined" marked | MC6809/MC6809E datasheets, M6809PM programming manual | A lower tier never overrides a higher one. An emulator-derived oracle is used to *find* divergences to explain, never to *settle* them. ## Inventory ### SingleStepTests: no 6809 corpus (confirmed 2026-09-12) The SingleStepTests organisation's repositories, enumerated with `gh api orgs/SingleStepTests/repos` on 2026-09-12: `ProcessorTests`, `GameboyCPUTests`, `8088`, `65x02`, `680x0`, `65816`, `sm83`, `z80`, `spc700`, `v20`, `sh4`, `m68000`, `ARM7TDMI`, `r3000`, `8086`, `80186`, `huc6280`, `80286`, `80386`, `ares_r3000_ssts`, `ares_tcls900h_ssts`, `tlcs900h`. `ProcessorTests` (HEAD `bb11756`, 2024-05-15) contains `6502`, `65816`, `680x0`, `8088`, `nes6502`, `rockwell65c02`, `spc700`, `synertek65c02`, `wdc65c02` and `tools`. **There is no 6809, 6309 or Konami-1 directory or repository.** `https://github.com/SingleStepTests/6809` returns 404. ### neetandev/m6809: emulator-derived single-step corpus (fetchable, pinned) - Repository: , "SingleStepTests compatible test vectors for the m6809 CPU using MAME as the oracle". - Pinned revision: `9dd7b59284ecc2667268149dbad049e91e36cc9e` (2026-07-10, "fix: mixed-width CC/DP behavior"). Three commits in total; created 2026-07-08. - Licence: the README states "Test data itself is licensed under MIT-0" and "Test data generator is licensed under BSD-3". **The repository has no LICENSE file** at that revision (GitHub reports `license: none`); the generator directory carries its own `LICENSE`. The README statement is the only licence for the vectors. Not bundled here. - Tier: **emulator-derived**. The generator runs "hard copies" of MAME's `m6809.lst`, `base6x09.lst`, `m6809.h`, `m6809inl.h` and `m6809make.py` (`testgen/mame/`), cycle model "MC6809E", with random register, DP, CC and full-64 KB memory state per test, interrupt lines held clear. One deliberate deviation from MAME: the register-transfer helpers "apply the mixed-width CC/DP behavior observed on a real FM-77AV and documented by 77AVEMU", which is a hardware observation the project has not yet seen in primary form ([undocumented-behavior](undocumented-behavior.md)). - Coverage: **315 files, 249,871 cases** (from `v1/manifest.txt`); 266 opcodes `normal`, 49 `undocumented`, 5 `skipped` (`13` SYNC, `3C` CWAI, `14`/`15`/`CD` HCF), per `v1/metadata.json`. 1,000 cases per opcode except the skipped ones. Each case records instruction bytes, initial and final registers (`pc s u x y dp a b cc`, each as u16), RAM at every touched address, and one entry per bus cycle with pins, address and data, so cycle totals *and* bus order are checkable. Format: SingleStepTests "MOO" binary, gzip-compressed (`v1/.moo.gz`, header `MOO ` then chunks `NAME`, `BYTS`, `REGS`, ...); a reader is about eighty lines and the generator's `moo_writer.cpp` is the format reference. - Limits: it inherits every MAME simplification listed on the undocumented page (store-immediate flags, XADDU's `| $FF00`, undefined postbytes) and it cannot contain interrupts. It is the right first gate and the wrong last word. - Fetch: `python scripts/fetch_m6809_vectors.py` clones the repository into `tests/vectors/m6809/` (gitignored), checks out the pinned commit, and verifies two SHA-256 values: | File | SHA-256 | | --- | --- | | `v1/manifest.txt` | `45e5f52adb82bd142a473b6e4af1ec1591d223de94994b71e2c735d7ee3f8f23` | | `v1/metadata.json` | `9f9c3342219d511e34e55199dfe839edf98189edeeea3c3f3a88d9fd9fc57c0b` | Run on 2026-09-12: `Fetched neetandev/m6809 at 9dd7b59...: 315 vector files`, 32 MB on disk, 2.7 s. The individual `.moo.gz` files are not hashed here; the commit pins them and the manifest hash pins the file list. ### hoglet67/6809Decoder: hardware-captured undocumented behaviour (cite, do not fetch) - , David Banks; HEAD `4f7e184` (2025-01-27); wiki page *Undocumented 6809 Behaviours*. - Tier: **hardware-captured**: a bus decoder for logic-analyser captures of 6809/6309 systems; the wiki's rules were "validated against original devices" by test programs (`test/assembler/*.bas`, `6809test.asm`, `stimm.bas`, `illeg1.bas`, `illeg2.bas`, `x18.bas`, `daa.bas`, `hcf.bas`, `syncwai.bas`, `reset.bas`, ...) whose results were pushed to the stack and compared cycle by cycle. - Licence: **none in the repository**. The wiki is cited as a source of facts; the programs are not fetched or redistributed by this project. If a build session wants to run them it must ask the author or reproduce the method. - Coverage: every illegal page-1/2/3 opcode, the undefined H and V cases, prefix chaining. Not the documented instruction set as such, and no machine-readable vectors. ### David Flamand, 6809_undoc: hardware-captured (cite) - , commit `3b8d5cf` (2022-08-11): `6809_undocumented_behavior.pdf`, `tfr.txt`, `Cycle_Analyzer.jpg`. No licence stated. Tier **hardware-captured** (a cycle analyser on real parts); credited by hoglet67 for the `18` opcode's dependence on the next byte and for TFR/EXG measurements. Cited, not fetched. ### Schwotzer 6809test.asm: hardware-corrected self-checking program - Found as `test/assembler/6809test.asm` in hoglet67's repository; header: "MC6809 CPU Emulation Validation. Tested on an SGS Thomson EF6809P Processor. W. Schwotzer, 20.07.2003". Wolfgang Schwotzer is the author of flexemu (, GPL-2.0, HEAD `dc5290a` 2026-08-24); whether this file ships in flexemu, and under which licence the copy in hoglet67's repository stands, was **not confirmed** (a code search of flexemu returned nothing). Tier: **hardware-corrected** by its own statement. It is a FLEX program (uses FLEX's `WARMS`, `PUTCHR` entry points), so running it needs a FLEX stub the way ZEX needs a CP/M stub. Not fetched until the licence is settled. ### MAME 0.285: emulator-derived traces (tooling in this repository) [mame-oracle](mame-oracle.md) records the working command line, the Lua script, the register names, the Williams Advance-button trap, and a verified 20-second Robotron trace with 2,069 IRQ entries at the expected scanlines. Tier **emulator-derived**; licence BSD-3-Clause for MAME's source, but the traces derive from copyrighted ROMs and stay out of the repository. Use: a boot-segment replay of straight-line ROM code (552,507 instructions before the first I/O dependency), per-instruction cycle costs, and interrupt-entry frames. ### XRoar 1.12: independent emulator (cross-check) - , Ciaran Anscomb, GPL-3.0; git at `https://www.6809.org.uk/git/xroar.git` (GitHub mirror `stahta01/xroar`, HEAD on `main` pushed 2026-08-03). Source `src/mc6809/`. Version 1.12 dated 2026-07-27. - Its 6809 core is written independently of MAME's and has had "6809: flesh out some illegal instruction behaviours [David Banks]" and "Implement some more 6809 undocumented behaviour" applied (ChangeLog), so on the undocumented corners it is a second transcription of the same hardware source; on documented behaviour it is a genuinely independent detector. It ships no test-vector corpus. Use: build it, run the same single-instruction cases through its core (it has a GDB stub, per the 1.12 ChangeLog), and diff against MAME and this core; three-way agreement is the plan's strongest available evidence for documented instructions. ### Vectrex emulators (cross-check candidates) `vecx` (Valavan Manohararajah; SDL port `jhawthorn/vecx`, GPL-3.0, pushed 2024-09-10; `raz0red/jsvecx`, GPL-3.0) has a small hand-written 6809 core (`e6809.c`) that has run every Vectrex game for two decades. Emulator-derived; useful as a third opinion on documented instructions only. ### Other material found and why it is not an oracle - **cavnex/mc6809** (, HEAD `17e94a6`, 2020-11-26, no licence): a cycle-accurate Verilog 6809 whose README says it was validated by running "nearly every instruction in every addressing mode" through MAME and then capturing the soft core's bus on a GODIL and matching cycle counts. That is hardware-cross-checked *Verilog*, and the vectors it used are not published; it is evidence that MAME's cycle counts match silicon for the documented set, which is worth citing, and nothing runnable. - **MCL6809** (MicroCore Labs, Ted Fried; `MicroCoreLabs/Projects`, no licence stated): a Teensy-based drop-in 6809E whose author wrote "a test suite to exercise each of the 6809 opcodes, flags, and addressing modes" because none existed. Self-checking, expectations hand-derived from the datasheet as far as the project page says; not stated to have been corrected on real hardware. Datasheet tier at best; not examined further. - **Darren Atkinson's Programming Reference**, **Ciaran Anscomb's 1994 article**, **dragon32.info undocops**: prose descriptions, superseded by hoglet67 on the undocumented set; cited there. - Repositories named `6809 test` on GitHub (`AutryAviators/Off-Season-6809-Test`, `papin002/6809617159_Test`, `jasonalexander-ja/6809Stuff`) are unrelated to CPU testing. ## The plan, in oracle-tier order Run these in order; each is cheaper than the next and earns a specific claim. | Step | Gate | Judge or detector | Claim earned | | --- | --- | --- | --- | | 1 | The datasheet cycle table and flag rules transcribed into the core's per-opcode unit tests (`start-here.md` is the table) | datasheet, judge | documented semantics and counts as Motorola states them | | 2 | `neetandev/m6809`, all 315 files, registers + RAM + cycle count + bus order | MAME, detector | agreement with MAME on 249,871 cases; every disagreement listed and attributed to the datasheet, to hoglet67, or to a core bug | | 3 | hoglet67's and Flamand's rules as focused unit tests for `18`, `38`, `3E`, `4E`, `87/8F/C7/CF`, `XADDD/XADDU`, `XNC`, `XDEC`, H/V after the listed instructions, prefix chains | hardware-captured, judge | the undocumented set follows silicon where it was measured, with the MAME divergences named | | 4 | MAME boot-segment replay of Robotron and Joust (`docs/mame-oracle.md`), registers per instruction and `totalcycles` deltas, through the RAM test and into attract mode with the VA11 IRQ model in the host | MAME, detector | millions of real arcade instructions and 2,000+ interrupt entries agree | | 5 | XRoar (and optionally vecx) run on the same single-instruction cases as step 2, three-way diff | independent emulators, detectors | every rule in the core is either datasheet-backed, hardware-backed, or agreed by three independent implementations | | 6 | Schwotzer's `6809test.asm` under a FLEX stub, if its licence allows fetching it | hardware-corrected | a 2003 program that passed on an EF6809P passes here | What would raise the ceiling: a bus capture of a real 6809E running a random-state single-step generator (the hoglet67 decoder plus a logic analyser on a Dragon, CoCo or a Williams board would do it). That is the 6809 equivalent of what SingleStepTests did for the 65x02 and would turn step 2 from a detector into a judge. It is outside this repository's scope and is recorded here so that the claim's ceiling is explicit. ## Scope limits, stated now - Instruction-level semantics, flags, bus-cycle counts and order, and interrupt-entry sequences. Not bus-pin timing within a cycle, not MRDY/DMA stretching, not the 6809E's LIC/AVMA/BUSY pins. - MC6809 and MC6809E only. HD6309 native mode and the Konami-1 opcode map are out of scope ([start-here](start-here.md)). - No complete Williams board: the host contract is documented in [timing](timing.md) so that a host can be built, and the MAME replay in step 4 is what stands in for one.