# i8086-python **Status: documents and oracles only.** There is no core code in this repository yet. What is here is the groundwork a later session builds from: a primer on the processor, its timing, its undocumented behaviour, a validation plan with every oracle ranked by provenance, a script that fetches the hardware-captured test corpora at pinned commits, a recipe for producing emulator-derived traces from MAME, and a handoff brief with milestones and acceptance tests. Read [docs/README.md](docs/README.md) for the index. ## What the project is `i8086-python` will be a readable, dependency-free Python 3.12+ Intel 8086 **instruction core**, in the shape of the author's existing [z80-python](https://github.com/alewman/z80-python) and [6502-python](https://github.com/alewman/6502-python) cores: - **readable**: instruction families as ordinary Python with explicit dispatch, every handler named by its Intel mnemonic, hardware reasons as comments on the lines that encode them; - **pure Python**: no runtime dependencies, CPython and PyPy; - **independently validated**: correctness claims come from external oracles ranked by where their expected values came from, never from confidence; - **embeddable**: the host owns the 20-bit memory space and the 16-bit I/O port space and supplies `read_byte`/`write_byte`/`read_port`/`write_port`; the core owns registers, flags, segmentation, instruction semantics, documented cycle totals, and the interrupt acceptance model at instruction boundaries; `step()` advances one instruction or accepted interrupt and returns its cycle count; - **inspectable**: processor state, disassembly, and traces without contaminating the hot path. The host contract is the same as the two existing cores', widened: addresses are 20-bit physical values (segment × 16 + offset, wrapped at 0xFFFFF) and ports are 16-bit. The core performs word accesses as two byte accesses in little-endian order so a host never has to know about the 8086's 16-bit bus. ## Scope decision: 8086 first, then V30 The 8086, 8088, and NEC V20/V30 share one execution model and differ in ways that matter to a validation plan: | Part | Data bus | Prefetch queue | Instruction set | Why it matters here | | --- | --- | --- | --- | --- | | Intel 8086 | 16-bit | 6 bytes | base | The core's first target. | | Intel 8088 | 8-bit | 4 bytes | identical to 8086 | Same execution unit; differs only in bus width and queue depth, which are "invisible to programs" (Intel 8086 Family User's Manual, p. 2-8 and 2-15). The largest hardware-captured corpus was generated on an 8088, so it is the judge for the 8086 core's register, flag, and memory results, and says nothing about the 8086's cycle counts. | | NEC V20 (µPD70108) | 8-bit | 4 bytes | 8086 + 80186-class + NEC-specific | Same execution unit as the V30 (NEC V20/V30 User's Manual, p. 1-1, 3-1). A hardware-captured corpus exists. | | NEC V30 (µPD70116) | 16-bit | 6 bytes | as V20 | **What the arcade boards actually run.** Adds instructions, changes cycle counts (a hardware multiplier, an effective-address generator, a loop counter: NEC manual p. 3-1 to 3-3), changes some undefined-flag results, and has an 8080 emulation mode (out of scope). | The plan is therefore: build and certify the **8086** core against the 8088 corpus first; then add the **V30** as a milestone (NEC register names, the added instructions, NEC flag results, NEC cycle counts) certified against the V20 corpus. Only then does MAME lockstep on an Irem M72 board become a meaningful detector, because R-Type runs a V30. See [docs/handoff-brief.md](docs/handoff-brief.md). ## The arcade boards From MAME 0.285's machine list (`mame -listxml`, parent sets only, main CPU tag), the 8086-family and V-series arcade hardware this core is aimed at: | Maker | Boards and games | CPU | | --- | --- | --- | | Irem | M72: R-Type, Battle Chopper, Image Fight, Ninja Spirit, Legend of Hero Tonma, R-Type II, Dragon Breed, X Multiply, Air Duel, Hammerin' Harry, Major Title, Pound for Pound (14 parent sets, 1987-1990) | V30 @ 8 MHz | | Irem | M72 late (Cosmic Cop, Lightning Swords), M90 (Dynablaster, Hasamu, Bomber Man World, Quiz F1, Risky Challenge) | V35 @ 16 MHz (V30 core plus on-chip peripherals) | | Irem | M92 (Gunforce, Blade Master, Lethal Thunder, Hook, R-Type Leo, Undercover Cops, In The Hunt, Ninja Baseball Bat Man, ...), M107 (Air Assault, Dream Soccer '94) | V33 @ 9-14 MHz main + V35 sound | | Seibu Kaihatsu | Raiden (two V30 @ 10 MHz), Dynamite Duke, Dead Angle, Pop'n Run (two V30 @ 8 MHz), Raiden II / Raiden DX / Zero Team (V30 @ 16 MHz), Raiden DX V33 PCB (V33A @ 16 MHz) | V30 / V33A | | Tatsumi | TX-1 and Buggy Boy (two Intel 8086 @ 5 MHz), Lock-On (three V30 @ 8 MHz), Apache 3 (V30 + V20), Round Up 5 (V30) | 8086 / V30 / V20 | | Seibu (1986) | Panic Road | V20 @ 8 MHz | | Sun Electronics | Kyuukyoku no Othello | V30 @ 8 MHz | | Toaplan | Dogyuun, FixEight, Grind Stormer, Batsugun, Knuckle Bash (1992-1993) | V25 as **sound** CPU only; the main CPUs are 68000 | Corrections to the working assumptions this repository was commissioned with, from the same MAME listing: Toaplan's *Tatsujin* (`truxton`) is a 68000 game with a Z80 for sound, not an 8086-family board; Toaplan's V-series use is the V25 sound CPU in its 1992-93 games. MAME 0.285 lists **no** Nichibutsu and **no** Namco parent set whose main CPU is an 8086, 8088, V20, V30, V33, or V35 (Namco's contemporaneous boards are 6809- and 68000-based), so those two makers are dropped from the target list rather than kept on hearsay. ## Oracles at a glance Ranked by where their expected values came from (hardware-captured > hardware-corrected > emulator-derived; a low-tier oracle is a detector, never a judge). Details, pins, sizes, and limits are in [docs/validation.md](docs/validation.md). | Oracle | Tier | Pin | Size | | --- | --- | --- | --- | | SingleStepTests/8088 v2 (AMD D8088 on an Arduino harness) | hardware-captured | `aea8448` | 323 files, 3,007,000 cases | | SingleStepTests/v20 v1_native (NEC D70108C-8) | hardware-captured | `9efbd02` | 360 files, 3,125,000 cases | | SingleStepTests/8086 v1 (Intel P80C86A-2, CMOS) | hardware-captured | `e71c68d` | 323 files, 646,000 cases | | Intel *8086 Family User's Manual* (1979) and NEC *V20/V30 User's Manual* (1986) | documentation | bitsavers scans | basis for unit tests | | MAME 0.285 `nec` core on `rtype` | emulator-derived | 0.285 | per-instruction traces | There is no known hardware-corrected (tier 2) oracle for this family; the gap between tier 1 and tier 3 is stated rather than papered over. ## Repository layout ```text README.md this file LICENSE MIT docs/ see docs/README.md scripts/fetch_test_vectors.py fetch the pinned corpora into tests/ (ignored) scripts/mame/ the MAME trace recipe as runnable files tests/ corpora land here; nothing is committed ``` ## License MIT. External oracles retain their own licenses (SingleStepTests: MIT; MAME: BSD-3-Clause for the files cited; the Intel and NEC manuals are cited, not redistributed) and are never bundled.