velxio/test/test_intel/test_8080
David Montero afad6a1ed0 test_intel: historic ROM boots — Busicom + Tiny BASIC + Galaksija
Wire up three real, public-domain ROMs from the silicon era and prove
they boot end-to-end on the clean-room chip implementations. Each
test reads a separate well-known boot artifact:

* Busicom 141-PF firmware (4004, 1 KB, Intel PD 2009)
  Wires real 4004 + real 4002 chips on the multiplexed nibble bus.
  Toggles TEST every ~400 phases to mimic the printer-drum encoder
  pulse the firmware polls. Asserts >2000 opcode fetches, >15 unique
  PC addresses, and >100 CMROM strobes.

* Palo Alto Tiny BASIC v2 (8080, 1.9 KB, Wang 1976 PD)
  CPUville port loaded from Intel HEX. Fake polled 8251 UART at port
  0x02 (data) / 0x03 (status). Asserts the captured TX stream
  contains the BASIC "OK" prompt — proving the interpreter reached
  its REPL.

* Galaksija ROM A (Z80, 4 KB, Voja Antonić PD 1984)
  ROM A+B at 0x0000..0x1FFF, system RAM at 0x2000..0x3FFF. Asserts
  PC visits the JP target 0x03DA from reset and the ASCII "READY"
  prompt appears in RAM after init.

ROMs are downloaded to roms/{4004,8080,z80}/ and gitignored — the
tests skip cleanly when the binaries are absent. License-clean: no
GPL ROMs, all PD by upstream provenance.

Total: 126 → 129 passing, 0 todo, 0 failed; 19 → 22 test files.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 04:18:00 +02:00
..
8080.c test_intel: phase A — 8080 INTA bus protocol 2026-04-30 04:33:55 +02:00
8080.test.js test_intel: phase D-3 + todo cleanup — 125/126 passing 2026-05-01 03:20:50 +02:00
README.md
cpudiag.test.js test_intel: phase F — software validation (CPUDIAG + ZEXDOC pass) 2026-04-30 20:44:17 +02:00
tinybasic.test.js test_intel: historic ROM boots — Busicom + Tiny BASIC + Galaksija 2026-05-01 04:18:00 +02:00

README.md

test_8080 — Intel 8080 as a velxio custom chip

See ../autosearch/02_intel_chips_overview.md for the spec.

Status

Implemented. 18/20 tests passing. ~470 LOC clean-room C in 8080.c compiled to fixtures/8080.wasm.

Validated against:

  • Intel 8080 Microcomputer Systems User's Manual (Sept 1975, doc 98-153B)
  • Intel 8080/8085 Assembly Language Programming Manual (May 1981, doc 9800301D)
  • Cross-checked AC flag rules, DAA, status bytes, and CALL/RST stack ordering against superzazu/8080 (MIT, passes 8080EXM) and mayawarrier/intel8080-emulator (MIT). No code was copied — only authoritative spec consultation.

The 2 remaining it.todo tests are integration milestones (hand-built loop, CPUDIAG ROM run) deferred until a generic rom-32k chip exists.

Pin contract (40-pin DIP)

Power simplified: real 8080 needed +12 V / +5 V / 5 V; we collapse to single VCC / GND. Documented under ../autosearch/05_open_questions.md.

Group Pins Dir
Address bus A0..A15 out
Data bus D0..D7 I/O
Status/ctl SYNC, DBIN, WR̅, INTE out
Inputs RESET, READY, HOLD, INT in
Outputs WAIT, HLDA out
Clock φ1, φ2 in
Power VCC, GND power

Total registered pins: 16 (addr) + 8 (data) + 4 (status) + 4 (inputs) + 2 (outputs) + 2 (clock) + 2 (power) = 38. Two real-silicon pins (+12, 5) are dropped.

Bus cycle reference

For each machine cycle:

T1: drive A0..A15 with target address.
    Drive D0..D7 with status byte (memory read = 0x82, etc.).
    Pulse SYNC high.
T2: deassert SYNC. Switch D0..D7 to input (for reads) or hold them
    as data output (for writes). Assert DBIN (read) or WR̅ (write).
T3: sample D0..D7 (read) or hold (write).
TW: optional, while READY is low.
T4..T5: instruction-internal work, no bus activity.

In the timer-driven model we collapse all five T-states into a single "step one instruction" callback that internally walks T1→T3 and emits the pin events in order. A faithful single-step mode driven by an external clock chip is a follow-up.

Target demo sketch

CP/M-style "hello world" via memory-mapped UART: 8080 wired to a ROM chip (program), a RAM chip (stack/heap), and a UART chip (velxio's uart-rot13.c example shows that custom UARTs work). Program prints to UART; user sees output in the velxio serial monitor.

This is a real, recognisable retro-computing demo.

Implementation plan

  1. Spike a minimal 8080 chip that runs MOV / ADD / JMP only, driving an LED off D0 of a memory-mapped output port. Confirms the bus state machine works.
  2. Port the full ISA from a permissively-licensed reference (see autosearch/04) into 8080.c.
  3. Run CPUDIAG (the standard 8080 self-test program) — load it as ROM, verify it prints "CPU IS OPERATIONAL" via the UART.
  4. Add interrupt support (8259-style PIC is out of scope; just INT pin → fixed RST vector for the first cut).

Files to create later

  • 8080.chip.json
  • 8080.c (or split into 8080.c + 8080_decode.h if it gets large)
  • roms/cpudiag.bin (public-domain test ROM)
  • 8080.test.ts