Source · assembled here · run on the switches

Seven programs,
assembled in the page.

Every other page here shows a 6502 in the middle of running something. This is the something: seven programs, written as assembly rather than as a column of hex, assembled in this page, and executed on the same 3,510-transistor simulation the die view draws.

The program selected here is the one the Explorer, the Blueprint, the Exploded view and the Schematic run.

assembled · in this page Pick a program

Addr Bytes Source Cyc Len

The binary


          

Run it here

A real chip, not a preview: the same simulation, stepped one half-cycle at a time. Registers and memory are read back out of the storage nodes.

Loading the simulator…

See it somewhere else

How this page is built

The bytes come from the text

These programs used to live in this repository as arrays of hex with a comment beside each byte. That arrangement has one failure mode and it is silent: the comment and the byte are two independent claims, and nothing ever checks that they still agree. A listing assembled from source cannot drift, because the column on the left is computed from the column on the right.

The assembler is about three hundred lines and it does not carry an opcode table of its own. It inverts the one the disassembler uses, so the two are the same table read in opposite directions, which is what makes the round trip in the test harness evidence rather than a tautology. Undocumented opcodes are absent from both: the chip executes them, and this simulator will show you exactly what they do, but giving them a mnemonic would imply a canonical meaning they do not have.

The cycle counts in the last column are not from a datasheet. They were measured by running each opcode on the silicon from one sync to the next, which is the same measurement the Timing page is made of. Where an instruction can take longer (a taken branch, a page crossed) the count shown is the shortest, because the extra cycles depend on values this page cannot know without running the program. The run panel above counts the real ones.

Every program loops rather than ending. There is no operating system here to return to, and running off the end reaches $00, which is BRK, which vectors through $FFFE to $0000, which is another BRK: a chip climbing down its own stack forever while every gate on the die lights up convincingly. That was a real bug on two pages of this site, and nothing on either could have revealed it until something showed what the chip was reading.