Tiny 6502

The smallest 6502 emulator in JS — ~300 lines, ~50 functions

BUILD GUIDE
1. Architecture Overview

The 6502 has a minimal register set: • A (Accumulator) - main math register • X, Y - index registers • SP - stack pointer (

00-
FF) • PC - 16-bit program counter • Status - N V - B D I Z C flags Memory: flat 64KB address space (0x0000-0xFFFF)

function create6502() { return { a: 0, x: 0, y: 0, sp: 0xFD, pc: 0x0600, n:0, v:0, b:0, d:0, i:0, z:0, c:0, mem: new Uint8Array(65536), cycles: 0 }; }
2. Memory Access
3. Addressing Modes
4. ALU Operations
5. The Step Function
6. Stack Operations
REGISTERS
A
$00
0
X
$00
0
Y
$00
0
SP
$FD
253
PC
$0600
1536
CYC
0
FLAGS:
N
V
-
B
D
I
Z
C
SPEED:1000 Hz
MEMORY
ADDR0123456789ABCDEF
$0600
$0610
$0620
$0630
$0640
$0650
$0660
$0670
DISASSEMBLY
$0600BRK
$0601BRK
$0602BRK
$0603BRK
$0604BRK
$0605BRK
$0606BRK
$0607BRK
$0608BRK
$0609BRK
OUTPUT ($F001)
...
Built with ❤️ and 6502 nostalgiaThe 6502 powered the Apple II, NES, and Commodore 64Remix on Berrry