CPU Inside a CPU Inside a CPU — Russian Doll Silicon
A working 8-bit CPU running a tiny operating system, which schedules a 4-bit CPU emulator written in 8-bit assembly. Three layers of computation, all visible side-by-side, all running at once.
What this is
Three live panes, side by side. OUTER 8-BIT CPU: 4 general registers, ALU, 256-byte RAM, 26-instruction ISA, live disassembly view. TINY OS: a real kernel (~115 bytes of 8-bit assembly) that does round-robin scheduling between two tasks. INNER 4-BIT CPU: a 16-nibble RAM, 2-register, 8-instruction nested machine that the OS steps as one of its tasks. Speed slider goes from 1 Hz to 10 MHz. Everything in green-phosphor CRT.
Why this is mind-blowing
You can build the entire history of computing — registers, ALUs, instruction sets, operating systems, scheduling, virtualization — in one HTML file from one prompt. The model has read every architecture textbook ever written. You just have to know which abstractions to ask for.
Build a working 8-bit CPU simulator in one HTML file: registers, ALU,
instruction pipeline, memory bus, all live-visualized. Then write a
tiny operating system in its assembly that boots inside it. Then have
that OS run an even tinier 4-bit CPU emulator inside itself. Three
layers of computation, all running simultaneously, all visible side-by-side
as live register dumps and memory heatmaps. Beautiful retro CRT aesthetic
— green-on-black phosphor look. Pause/step/run controls.
Paste this into Claude, Cursor, or Copilot. Change one thing that matters to you.
What I learned shipping it
- Computers are a stack of abstractions. Building all three layers — CPU, OS, nested emulator — in one HTML file makes the stack visible in a way college courses never do.
- An inline two-pass assembler that builds the kernel at boot is more honest than hardcoding bytecode. You see the assembly. You see it become bytes. You see the bytes execute.
- Treating SYS handlers as 'microcode in JS' is the same compromise real CPUs make with microcode. Be honest about it in the README and the demo is more credible, not less.