Skip to content
Hardware

6502: The People's Processor

Eight bits that changed everything

The MOS 6502 powered the Apple II, Atari 2600, Commodore 64, and NES—making home computing affordable and defining a generation of programmers.

commodore-64nintendo-entertainment-systematari-2600apple-iibbc-microatari-800commodore-vic-20 cpuprocessorsmos-technology 1975–present

Overview

The MOS 6502, designed by Chuck Peddle and released in 1975, democratised computing. At $25 when competitors charged $300+, it made personal computers financially viable. Its elegant instruction set and zero-page addressing made assembly programming accessible to bedroom coders worldwide.

Fast facts

  • Clock speed: typically 1-2 MHz depending on system.
  • Data bus: 8-bit with 16-bit address bus (64KB addressable).
  • Registers: accumulator (A), two index registers (X, Y), stack pointer, status register.
  • Zero page: first 256 bytes ($00-$FF) accessed with single-byte addresses for speed.
  • Stack: fixed at $0100-$01FF, grows downward.

Architecture highlights

  • Instruction set: 56 official opcodes with multiple addressing modes each.
  • Addressing modes: immediate, absolute, zero-page, indexed, indirect, and combinations.
  • No multiplication/division: these must be implemented in software.
  • Little-endian: low byte stored first in memory.
  • Interrupts: NMI is edge-triggered (vectors via $FFFA-$FFFB), IRQ is level-triggered (vectors via $FFFE-$FFFF, shared with BRK). Reset vectors via $FFFC-$FFFD. All take 7 cycles.

Status register (P)

BitFlagMeaning
7NNegative — copy of result bit 7
6VOverflow — signed overflow on ADC/SBC
5Unused (reads as 1 when pushed to stack)
4BBreak — no physical bit; appears 1 when pushed by BRK/PHP, 0 when pushed by IRQ/NMI
3DDecimal — selects BCD mode for ADC/SBC (no effect on the NES 2A03)
2IInterrupt disable — when 1, IRQ is masked
1ZZero — set if result == 0
0CCarry — unsigned overflow / shift-out / comparison result

Key addressing modes

ModeSyntaxExampleDescription
Immediate#$nnLDA #$40Load literal value
Zero-page$nnLDA $40Fast access to $00-$FF
Absolute$nnnnLDA $C000Full 16-bit address
Indexed$nnnn,XLDA $C000,XAddress + X register
Indirect($nnnn)JMP ($1234)Jump to address stored at location

Famous quirks

  • JMP indirect page-wrap bug: if the operand of JMP ($xxFF) lies on a page boundary, the high byte of the target is fetched from $xx00, not $xx100 — the high byte wraps within the page. The 65C02 fixes this.
  • Decimal mode flag behaviour: in BCD mode, the N, V, and Z flags reflect the binary intermediate result, not the BCD output. (Most code re-tests after the operation.)
  • Page-cross cycle penalty: read instructions (LDA/CMP/ADC/etc.) using abs,X/abs,Y/(zp),Y cost +1 cycle if the index crosses a page boundary. Read-modify-write (ASL $nnnn,X) and store (STA $nnnn,X) instructions always take the maximum cycle count — they always do a dummy read at the unfixed address.
  • Reset state: I=1, D=1 on some early NMOS parts; A/X/Y/SP/PC undefined. Reset code typically begins with LDX #$FF / TXS / CLD to set up the stack and clear decimal mode.

Undocumented (illegal) opcodes

The NMOS 6502 has 105 unused opcode slots, of which several dozen produce reproducible behaviour and are widely used in production NES and C64 software. Common examples:

MnemonicEffect
LAXLoad A and X simultaneously
SAXStore A AND X
DCPDecrement memory, then compare with A
ISCIncrement memory, then subtract from A with borrow
SLO/RLA/SRE/RRAShift/rotate memory, then OR/AND/EOR/ADC with A
ANCAND immediate, then copy bit 7 to carry

The 65C02 (CMOS) replaces most of these with new documented instructions, so code using illegals breaks on CMOS variants.

Variants and descendants

  • 6510: C64's version with built-in I/O port.
  • 6507: stripped-down version for Atari 2600 (13-bit address bus, 8 KB addressable).
  • 2A03: NES variant — 6502 core with decimal-mode adder disabled in hardware, integrated APU and DMA controller.
  • 65C02: CMOS version with additional instructions and the JMP indirect bug fixed.
  • 65816: 16-bit successor used in Apple IIGS and SNES.

Cultural impact

The 6502 created the first generation of assembly programmers. Its constraints—limited registers, no hardware multiply—forced creative solutions that became hallmarks of 8-bit game design. The skills learnt on a 6502 transfer directly to understanding all computer architecture.

See also