Paradox63 Built a CPU From Scratch and Made Its Assembly Testable
A Rust project ships the whole 8-bit stack (ISA, assembler, disassembler, emulator, games) with a calling convention that turns every routine into a unit test.
- Paradox63 is a complete 8-bit computing stack written in Rust by one developer: an original ISA, an assembler, a disassembler, an emulator, a cartridge format, and four playable games.
- Its register file borrows the 6809's composite model (D = A:B, W = E:F, Q = D:W) but widens addressing to 24 bits, which is unusual for an otherwise 8-bit chip.
- The call subcommand and a memory-mapped test mailbox at $00F000 turn assembly routines into callable, unit-testable units without touching the CPU.
- The README's stated goal is understanding the machine underneath the software, so the toolchain is the point and the games are the proof.
The Assembly Routine as a Unit Test
$ p63-sim call utils/bitops.p63 POP_COUNT A=$A5
The command looks like a unit test because that is exactly what it is. The call subcommand loads utils/bitops.p63, preloads register A with $A5, invokes the POP_COUNT routine, and runs it until the routine returns or the instruction budget runs out. The default budget is 10 million instructions, which is enough to catch an infinite loop without hanging the tool.
Routines chain with shared state. RAND_SEED8,RAND8 seeds a generator and then draws from it in a single invocation, passing the seed forward between them. Every named routine becomes a callable unit with an explicit calling convention: which registers go in, which come out, what the routine is allowed to touch.
This is the part that is genuinely rare. Retro assembly is untestable by construction. The routines run on hardware that has no notion of a test result, no return value, no assert. Paradox63 sidesteps that by treating the calling convention as a first-class interface. The CPU was not changed to make this work.
The README states the project's purpose plainly, and the test loop is how that purpose gets practiced:
One Stack, Built Together
The call trick only makes sense as part of a whole stack that was designed together. Paradox63 is a Cargo workspace with nine members, and the seams between them are deliberate. A specification crate, a CPU core, an assembler, a disassembler, a simulator binary, a bus, a cartridge format, and separate graphics and sound chips.
p63-spec: the ISA specificationp63-core: the CPU model and reference interpreterp63-asm: the assemblerp63-dis: the disassemblerp63-sim: the CLI binaryp63-bus: the device mapp63-cart: the cartridge formatp63-ppu: the graphics chipp63-apu: the sound chip
Five subcommands cover the whole development loop. asm assembles a file and reports segment sizes. call invokes named routines with register preloads. run boots a program headlessly for a fixed number of frames. play opens a window with keyboard-as-gamepad mapping (arrows for the D-pad, Enter for Start, Z and X for A and B). test runs test ROMs and prints PASS or FAIL.
Four sample games ship with the repo: pong, scale, song, and stream. They are not the point. They are the proof that the lower layers hold. A CPU you cannot run a game on is a CPU you have not finished.
Understanding the Machine Underneath
The author works under the GitHub handle dotslashCosmic. No interviews, blog posts, or conference talks are publicly verifiable, so the README is the only statement of intent available, and it keeps the framing spare. The cited inspirations are the Motorola 6809 and HD6309, the 6502, and the 8080: three CPUs that taught a generation how a processor actually works.
That choice of ancestors is not decorative. It tells you what kind of machine the author wanted to build before a single opcode was assigned.
A 6809 in a 24-Bit Coat
The register file is where the 6809 lineage shows. Five 8-bit accumulators: A, B, E, F, and GP. Two composite 16-bit registers built from them: D = A:B and W = E:F. One 32-bit register built from those: Q = D:W. Writing Q decomposes into writes to D and W, and reading it shifts and ORs the halves back together.
Index and pointer registers X, Y, SP, and PC are 24 bits wide. They are stored as u32 and masked to 24 bits on every write, enforced twice: once at the type level in Addr::new, and again in the register setters. That double enforcement is a small thing that signals the author cared about the invariant.
The condition code register matches the 6809 layout bit for bit: E, F, H, I, N, Z, V, C. The F flag is explicitly marked reserved, which is the designer leaving room for future work without committing to it.
The twist is the address bus. The 6809 and its descendants had 16-bit addressing, which capped them at 64 KB. Paradox63 widens it to 24 bits, giving 16 MB of reach. That is unusual for a chip that is otherwise 8-bit in every dimension, and it is the first place the project stops being a tribute act.
The Mailbox at $00F000
Here is the mechanism that makes the testable-assembly claim actually work. Test ROMs, built on games/tests/testlib.p63, write a result block to a fixed memory address: $00F000. The block holds a status byte, a kind byte (where 2 means a flags mismatch), a case number, a got word, and a want word.
The host does not reach into the CPU to read that. It polls the mailbox after every frame: run a frame, read the status byte, break if it is nonzero. The CPU has no idea it is being tested.
const TEST_RESULT: u32 = 0x00F000;
for _ in 0..frames {
machine.run_frame()?;
let status = machine.cpu.bus.read(Addr::new(TEST_RESULT));
if status != 0 {
break;
}
}
This is a memory-mapped mailbox, and it is the clever part. The ROM reports its own result, so the host needs no special hooks, no breakpoints, no instrumentation inside the interpreter. The same mechanism would work on real hardware, or in any emulator that exposes memory. Failure reports include the case number, the expected and actual values, and whether the failure was a value mismatch or a flag mismatch. For a retro-ROM test, that is about as informative as it gets.
Faults along the way are annotated with the program counter, so a crash reports where it happened. The test loop is not a separate tool bolted on. It is the same simulator that runs the games, pointed at a different kind of program.
How Paradox63 Compares
Placed next to the CPUs it descends from, Paradox63 reads like a 6809 that was allowed to grow up. Same register DNA, same condition-code layout, but the address bus widened to 24 bits and the toolchain ships with a test loop built in.
| Paradox63 | MOS 6502 | Motorola 6809 | Zilog Z80 | |
|---|---|---|---|---|
| Data width | 8-bit | 8-bit | 8-bit | 8-bit |
| Address width | 24-bit | 16-bit | 16-bit | 16-bit |
| Accumulators | A, B, E, F, GP | A | A, B | A |
| Composite registers | D (A:B), W (E:F), Q (D:W) | none | D (A:B) | none |
| Index registers | X, Y, SP, PC (24-bit) | X, Y | X, Y, U, S | IX, IY, SP |
| Condition codes | E, F, H, I, N, Z, V, C | N, V, Z, C | E, F, H, I, N, Z, V, C | S, Z, H, P/V, N, C |
| Built-in test harness | yes (call, test) | no | no | no |
Two columns are worth staring at. The address width is the first: every reference chip here is capped at 16 bits, and Paradox63 is not. The last row is the second: none of the machines it borrows from has any concept of a test harness, because none of them needed one. Those two rows are where the project stops being a homage and starts being its own design.
Everything else in the table is a variation on a familiar theme. The registers echo the 6309. The flags are the 6809's, unchanged. The innovation is not in the instruction set. It is in the decision to build the ISA, the assembler, the emulator, and the tests as one artifact, so that a routine can be called and checked the same way you would call and check a function in any other language.





