# Validation plan and oracle record ## The claim to be earned `i8086-python` will claim to be a **SingleStep-complete pure-Python 8086 instruction core**: for every opcode file in the pinned hardware-captured 8088 corpus, the registers, flags, and memory the core produces match what an AMD D8088 produced on a bench, and the memory and I/O accesses it performs match in address, value, direction and order. It will claim documented instruction clock totals, not cycle-exact bus timing ([timing.md](timing.md)). It will claim an interrupt acceptance model at instruction boundaries sourced from the manuals, cross-checked against MAME, and it will say that no hardware oracle for interrupts exists. Nothing here is yet earned: this page is the plan and the record of what was fetched and measured on 2026-09-12. ## The rule for ranking oracles Rank an oracle by where its expected values came from: 1. **hardware-captured**: a real chip ran the instruction and its outputs were logged; 2. **hardware-corrected**: a model whose disagreements with hardware were found and fixed (z80-python's SingleStepTests corpus is of this kind); 3. **emulator-derived**: another program's opinion. A lower-tier oracle is a **detector**, never a **judge**: it may raise a difference for investigation, and the higher-tier source decides. Every oracle below states its tier. Documentation (the Intel and NEC manuals) is not an oracle in this sense; it is the source of unit tests and of the interrupt model, and it is stated as such. ## Oracles ### SingleStepTests/8088 v2: hardware-captured, the judge for the 8086 core | | | | --- | --- | | URL | | | Pinned revision | `aea84484abc79d09639d855b7b0ab32bc9e4dbeb` (2025-09-03, "Update README with clarification on internal register usage") | | Directory | `v2/` (`v1/` is the superseded 1.x set; `v2_binary/` the same in the MOO binary format; `v2_undefined/` 13 extra files for 8F /1-7, FE /2-7, FF /2-7) | | License | MIT, Copyright (c) 2024 SingleStepTests (LICENSE in the repository) | | Provenance | Generated by Daniel Balsom with the Arduino8088 harness driving an **AMD D8088 8441DMA (1982)**, an NMOS second-source part, in maximum mode with i8288 bus signals emulated; the MartyPC emulator supplies the test generation (README, `metadata.json`: `cpu_detail`, `generator: arduino8088`) | | Size on GitHub | 324 files under `v2/`, 761.1 MB gzipped (GitHub tree API at the pinned commit) | | Fetched here | 323 `.json.gz` vector files + `metadata.json`; 732 MB on disk; **3,007,000 cases; 84,150,872 cycle entries** (`scripts/fetch_test_vectors.py --corpus 8088 --count`, 2026-09-12; every file verified against its git blob SHA-1 from the tree) | | Cases per file | 10,000, except strings 2,000; D2/D3 5,000; 40-4F and F5/F8-FD 1,000 | | Coverage | Every opcode except 0F (POP CS), 9B (WAIT), F0/F1 (LOCK), F4 (HLT), the prefixes 26/2E/36/3E/F2/F3 (which appear randomly *on* other instructions), and FE /2-7 (in `v2_undefined`). Group opcodes are split per REG: `80.0` ... `FF.7`. Undefined flag values captured from the chip. Divide exceptions run to the handler's first byte (IVT type 0 at 0x0400). | | Environment the cases assume | 1 MiB of writable RAM, address wrap at 0xFFFFF, IN returns 0xFF, no wait states, IF and TF not exercised; half of the cases start with a full 4-byte queue (`initial.queue` non-empty), half empty | **Record shape** (README, and checked on `00.json.gz`): a list of objects with keys `name` (disassembly), `bytes`, `initial` (`regs`: ax bx cx dx cs ss ds es sp bp si di ip flags; `ram`: `[address, value]` pairs in access order; `queue`), `final` (only the registers and RAM bytes that changed; the whole `flags` if any flag changed; `queue`), `cycles`, `hash` (SHA-1 of the test), `idx`. Each `cycles` entry has eleven fields: pin bitfield (bit 0 ALE, bit 1 INTR, bit 2 NMI), the multiplexed address/data bus (a valid address only when ALE is set), segment status (`ES DS CS SS --`), memory status (`R--`, `-A-`, `-AW` for MRDC/AMWC/MWTC), I/O status (the same three for IORC/AIOWC/IOWC), BHE (always 0 on the 8088, present for 8086 compatibility), data bus, bus status (`INTA IOR IOW MEMR MEMW HALT CODE PASV`), T-state (`T1 T2 T3 T4 Tw Ti`), queue operation (`F` first byte, `S` subsequent byte, `E` flush, `-`), and the byte read from the queue. **How prefetch is represented**: the `queue` lists are the instruction queue's contents before and after; `CODE` bus cycles in `cycles` are prefetches; the `F`/`S` queue-status column shows the execution unit consuming bytes; an instruction's cycles run from its first-byte read to the *next* instruction's first-byte read, so `len(cycles)` includes any fetch the next instruction had to wait for. All bytes beyond the instruction are 0x90 (NOP). **What it proves for an 8086, and what it does not.** The 8088 and 8086 share the execution unit and microcode; Intel calls the differences (bus width, queue depth, word-access cost) "invisible to programs" (Intel p. 2-8, 2-15). So final registers, flags (including the captured undefined ones), memory contents, and the *sequence* of operand accesses transfer to the 8086. What does not transfer: the cycle counts (every word is two bus cycles on the 8088), the number of `CODE` fetches, the queue contents, and BHE. The 8086 corpus below is the cross-check that the two chips agree on the transferable part; where their metadata differ (D2/D3 OF listed undefined only in the 8086 set) the difference is a documentation choice, not a hardware one. One residual caveat: this is an AMD part, presumed microcode-identical to Intel's 8088 [unverified]; a disagreement between it and the Intel 8086 corpus on an undefined-flag value would be the way to find out. **What the runner must do**: load `initial`, execute one instruction, compare `final` registers with the corpus's `flags-mask` from `metadata.json` applied until undefined flags are reproduced, compare the `final.ram` bytes, and compare the operand accesses the core performed with the `MEMR`/`MEMW`/`IOR`/`IOW` entries of `cycles` (address from the latched ALE value, value from the data bus at T3/Tw) in order; ignore `CODE` cycles, `PASV`/`Ti`, and `len(cycles)`. Port reads must return 0xFF. Divide-exception cases end at the handler, so the runner compares the state after the interrupt sequence and must mask the flags word pushed to the stack. ### SingleStepTests/v20 v1_native: hardware-captured, the judge for the V30 milestone | | | | --- | --- | | URL | | | Pinned revision | `9efbd02b8ec1a3aad347c2b59672ad25f3bcdb21` (2025-08-19, corpus version 1.0.3: "Replaced 0F31 and 0F39 opcodes to correct invalid initial RAM states") | | Directory | `v1_native/` (`v1_emulation/`, the 8080 mode, does not exist yet) | | License | MIT | | Provenance | **NEC D70108C-8 (V20), date code 8902NX, 1984 mask**, Arduino8088 v1.1, maximum mode (README, `metadata.json`) | | Size on GitHub | 362 files, 882.9 MB gzipped | | Fetched here | 360 `.json.gz` + `metadata.json` + `metadata.toml`; 848 MB on disk; **3,125,000 cases; 94,438,658 cycle entries** | | Cases per file | 10,000; strings 5,000; C0/C1/D2/D3 5,000; ENTER (C8) 2,000; INC/DEC r16 and flag instructions 1,000 | | Coverage | Everything the 8088 set covers plus 60-63, 66-69, 6A-6F, C0.0-C1.7, C8, C9 and 24 `0Fxx` files (0F10-0F1F, 0F20, 0F22, 0F26, 0F28, 0F2A, 0F31, 0F33, 0F39, 0F3B). Not covered: 64/65 (REPC/REPNC are prefixes and appear on string instructions; they are `prefix` in metadata), 0FFF BRKEM (metadata lists its flags but there is no file: the 8080 mode is out of scope anyway), WAIT, HLT, LOCK, POP CS, 8E /1 | | Record shape | identical to the 8088 v2 shape; the README's cycle-field list omits BHE but the files have the same eleven fields (checked on `00.json.gz`) | The V20 and V30 differ the way the 8088 and 8086 do: bus width and queue depth (NEC p. 1-1, 3-4). So this corpus judges the V30 core's registers, flags, memory and access order, not its clocks. The V30's clocks come from NEC section 12 ([timing.md](timing.md)). ### SingleStepTests/8086 v1: hardware-captured, supplementary | | | | --- | --- | | URL | | | Pinned revision | `e71c68d215a6bb8c356bd4cb3842de3bef345ca9` (2025-11-02, corpus version 1.0.1: "Updated metadata.json to add flag mask for D2 and D3") | | Directory | `v1/` (`v1_binary/` is the MOO form) | | License | MIT | | Provenance | **Intel P80C86A-2 782003 J20**, a CMOS 80C86, ArduinoX86 harness, 8288 bus controller, maximum mode; 2,000 cases per opcode; every case starts with a full 5- or 6-byte queue; registers have a 2 % chance of being 0 and memory a 2 % chance of being all 0x00 or 0xFF (README) | | Size on GitHub | 324 files, 181.5 MB gzipped | | Fetched here | 323 `.json.gz` + `metadata.json`; 180 MB; **646,000 cases; 22,975,865 cycle entries** | | Record shape | as the 8088 set, but the per-test keys are `test_hash` and `test_num`, not the `hash` and `idx` the README shows (observed on `00.json.gz`); the cycle entries carry a live BHE column | Its author calls it "supplemental to the 8088 tests" and aimed at the 8086's bus and prefetch behaviour. Here it earns two things: it is the only oracle from an *Intel* 8086 die, so a disagreement with the AMD 8088 set on an undefined flag or an undocumented form is decisive; and its `cycles` arrays are the hardware truth for a future BIU model of the 6-byte queue. Its own caveat: a CHMOS 80C86 is a re-implementation of the NMOS 8086, and whether its undefined-flag results are identical to an NMOS 8086's is not established by anything in this repository [unverified]. ### Intel and NEC manuals: documentation, the source of unit tests - Intel, *The 8086 Family User's Manual*, October 1979, order 9800722-03. (748-page scan with a text layer; 63 MB). Copyright Intel; cited only. - Intel, *iAPX 86,88 User's Manual*, 1981. . Same content reorganised; not used for page citations. - NEC, *µPD70108/70116 User's Manual*, October 1986, stock no. 500350. (228 pages, 11 MB). Copyright NEC Electronics; cited only. Unit tests derived from them cover what the corpora do not: the interrupt sequence and priorities (Intel p. 2-22 to 2-28), the segment-register shadow, the STI delay, HLT, and the V20/V30 differences in section 6 of the NEC manual. These are tier "documentation": right if the manual is right and the reading is right, and stated as such in any claim. ### MAME 0.285: emulator-derived, a detector | | | | --- | --- | | Binary | `/usr/games/mame`, reports `0.285 (unknown)` | | Source cited | `src/devices/cpu/nec/nec.cpp`, `necinstr.hxx`, `necinstr.h`, `necmacro.h` (BSD-3-Clause, copyright Bryan McPhail; "(Re)Written June-September 2000 ... based on the i286 emulator by Fabrice Frances which had initial work based on David Hedley's pcemu"); `src/mame/irem/m72.cpp` (BSD-3-Clause). Read at tag `mame0285` on GitHub. | | What it gives | Per-instruction register traces of R-Type's V30 (or any V30/V33/V35 board in the ROM collection), with the whole board around the CPU: the µPD71059C, the scanline timer, the sound CPU. Recipe and a verified sample in [mame-oracle.md](mame-oracle.md). | | Known limits as an oracle | Its flags are NEC-style throughout, which is right for a V30 host and wrong for an 8086 (its own header says so). `AAM imm8` ignores the immediate. 63/66/67/F1 are "invalid" NOPs. The interrupt shadow is applied after every MOV to a segment register and LOCK. Cycle counts are "99% accurate" by its own account and are not compared. | | Use | Lockstep on `rtype` after the V30 milestone: run the core inside a host with the M72 memory map and feed it the same interrupt timing; stop at the first divergence and decide it from the corpus or the manual. Before the V30 milestone, the same run is still useful up to the first V30-only instruction. | ### What is missing No hardware-captured corpus exercises INTR, NMI, TF, HLT, WAIT or LOCK on any of these parts; the 8088 README says the pin bitfield's INTR and NMI bits "may be" exercised in a future release. There is no tier-2 oracle. The interrupt model will therefore rest on documentation plus MAME as a detector, and the README must say exactly that. ## Fetching the corpora ```text python scripts/fetch_test_vectors.py # 8088 v2 and v20, about 1.6 GB python scripts/fetch_test_vectors.py --corpus 8086 python scripts/fetch_test_vectors.py --opcodes 00,01,F6.6 --count # a subset ``` The script reads the pinned commit's git tree from the GitHub API, fetches each file from `raw.githubusercontent.com` at that commit, and verifies the git blob SHA-1 of every file against the tree; a mismatch aborts. It is resumable (already-verified files are skipped) and writes a `REVISION` marker into each destination. Destinations are `tests/8088_test_vectors/`, `tests/v20_test_vectors/`, `tests/8086_test_vectors/`, all gitignored. SingleStepTests publishes no archive checksum; the immutable commit plus per-blob hashes is the provenance. `--count` reports files, cases and cycle entries, which is how the numbers on this page were produced. Record of the run on 2026-09-12 (Python 3.14.4, Linux x86_64): ```text SingleStepTests/8088 v2 @ aea84484abc79d09639d855b7b0ab32bc9e4dbeb (MIT) present: 323 vector files, 3,007,000 cases, 84,150,872 cycles SingleStepTests/v20 v1_native @ 9efbd02b8ec1a3aad347c2b59672ad25f3bcdb21 (MIT) present: 360 vector files, 3,125,000 cases, 94,438,658 cycles SingleStepTests/8086 v1 @ e71c68d215a6bb8c356bd4cb3842de3bef345ca9 (MIT) present: 323 vector files, 646,000 cases, 22,975,865 cycles ``` ## The gates, in order | Gate | Oracle | Tier | What passing lets you say | | --- | --- | --- | --- | | 1 | Unit tests written from Intel chapter 2 and 4 | documentation | The decoder, EA computation, flag rules and interrupt sequence follow the manual. | | 2 | SingleStepTests/8088 v2, all 323 files, registers + masked flags + RAM + access order | hardware-captured | The 8086 core's instruction semantics match an 8088 die. | | 2b | The same with no flag masks | hardware-captured | The undefined flags match too. | | 2c | SingleStepTests/8086 v1, all 323 files, the same comparison | hardware-captured | An Intel 8086 die agrees. | | 3 | SingleStepTests/v20 v1_native, all 360 files (V30 milestone) | hardware-captured | The V30 core's semantics, including NEC flag results, match a V20 die. | | 4 | MAME 0.285 lockstep on `rtype` | emulator-derived | No divergence from MAME over N instructions, or every divergence explained by a higher tier. | State the corpus revisions, the MAME version, and the pass counts with every claim. A claim without those numbers is not reproducible.