Carl
Colophon

How CodeLab is built

Nothing in these labs is a video or a mockup. When you press Assemble a real assembler runs; when you press Run a real 6502 runs your bytes. Both are small Go programs compiled to WebAssembly, so they run entirely in your browser — there's no server doing the work. It's all open source. If you want to see how the soup is made, here's the stack, top to bottom.

LayerRoleWhat it is
The page Astro + WebAssembly Just hosts the two programs below and wires up the buttons. Nothing runs on a server — the moment the page loads, it all runs on your machine.
go6asm ↗ The assembler Turns your text into real 6502 bytes — and also does the canonical formatter, the error messages, and the disassembly you see. Compiled to WebAssembly.
go6sim ↗ The machine A 6502 with RAM, ROM and a 6522 VIA, wired together on a small software backplane. The headless core is compiled to WebAssembly and runs your bytes.
6502-netsim-go ↗ The CPU, faithfully A transistor-level simulation of the actual 6502. go6sim can run it as its CPU when faithfulness matters more than speed.

Two CPUs — and which one you're running

go6sim can run the 6502 two different ways. One is an instruction-level interpreter: it knows what each opcode does and just does it — fast, and plenty accurate for learning. The other is 6502-netsim-go, a transistor-level model that simulates the actual gates inside the chip — about as faithful as it gets, and much slower.

CodeLab runs the interpreter. It has to: the transistor model is too slow to drive a responsive page. The netsim CPU earns its keep elsewhere — both run the same program and the results are checked against each other, so the fast one you're using is held honest by the slow one you're not.

How fast it runs

A real 6502 typically ran near 1 MHz — about a million cycles a second. CodeLab deliberately runs it at roughly 1 kHz, a thousand cycles a second — about a thousand times slower. That's on purpose: at full speed a counter would blur the LEDs into a smear. Slowed down, you can watch each step happen, which is the entire point. The chip isn't different — only the clock driving it is, and the clock is just another knob.

The whole thing is deliberately small. That's the same idea as the lessons: a system you can actually read top to bottom is a system you can actually understand. Clone a repo and poke at it — same invitation as the labs, one level down.

Explore more