The MOS Technology 6502 is an 8-bit microprocessor introduced in 1975. It is notable for its low cost, efficient instruction set, and widespread use in early personal computers and game consoles, including the Apple II, Commodore 64, Atari 2600, NES (Ricoh 2A03 variant), and BBC Micro.
| Feature | Description |
|---|---|
| Data width | 8-bit |
| Address width | 16-bit |
| Address space | 64 KB (0x0000–0xFFFF) |
| Registers | A, X, Y, SP, PC, P |
| Endianness | Little-endian |
| Clock speed | ~1–3 MHz (original NMOS) |
| Technology | NMOS |
- 8-bit register
- Used for arithmetic, logic, and data transfer operations
- 8-bit registers
- Used for indexing memory, counters, and offsets
- 8-bit register
- Points to the current stack location
- Stack resides in page
$0100–$01FF
- 16-bit register
- Holds address of next instruction
| Bit | Name | Description |
|---|---|---|
| 7 | N | Negative |
| 6 | V | Overflow |
| 5 | – | Unused (always set in pushes) |
| 4 | B | Break |
| 3 | D | Decimal Mode |
| 2 | I | Interrupt Disable |
| 1 | Z | Zero |
| 0 | C | Carry |
| Address Range | Usage |
|---|---|
$0000–$00FF |
Zero Page |
$0100–$01FF |
Hardware Stack |
$0200–$FFFF |
Program / Data / I/O |
| Vector | Address | Description |
|---|---|---|
| NMI | $FFFA–$FFFB |
Non-maskable interrupt |
| RESET | $FFFC–$FFFD |
Reset vector |
| IRQ/BRK | $FFFE–$FFFF |
Interrupt request |
| Mode | Syntax | Description |
|---|---|---|
| Implied | CLC |
Operand implied |
| Accumulator | ASL A |
Operates on accumulator |
| Immediate | LDA #$10 |
Constant value |
| Zero Page | LDA $20 |
Zero-page address |
| Zero Page,X | LDA $20,X |
Zero-page indexed |
| Zero Page,Y | LDX $20,Y |
Zero-page indexed |
| Absolute | LDA $1234 |
Full 16-bit address |
| Absolute,X | LDA $1234,X |
Indexed absolute |
| Absolute,Y | LDA $1234,Y |
Indexed absolute |
| Indirect | JMP ($1234) |
Pointer-based jump |
| Indexed Indirect | LDA ($20,X) |
X-indexed pointer |
| Indirect Indexed | LDA ($20),Y |
Y-indexed pointer |
| Relative | BEQ label |
Branch offset |
LDA,LDX,LDYSTA,STX,STY
TAX,TAY,TXA,TYA,TSX,TXS
PHA,PLA,PHP,PLP
ADC– Add with CarrySBC– Subtract with Carry
AND,ORA,EOR
ASL,LSR,ROL,ROR
INC,INX,INYDEC,DEX,DEY
CMP,CPX,CPY
BEQ,BNE,BMI,BPL,BCS,BCC,BVS,BVC
JMP,JSR,RTS,RTI
CLC,SEC,CLI,SEI,CLV,CLD,SED
BRK,NOP
-
Most instructions execute in 2–7 cycles
-
Additional cycles may be added for:
- Page boundary crossings
- Taken branches
When the D flag is set:
ADCandSBCoperate using BCD arithmetic- Only valid on NMOS 6502 (behavior varies on CMOS derivatives)
-
JMP (addr)indirect bug: page boundary wraparound- Example:
JMP ($10FF)reads from$10FFand$1000
- Example:
-
No dedicated multiply or divide instructions
-
Stack is fixed to page
$01xx
| Variant | Notes |
|---|---|
| 6502 | Original NMOS |
| 65C02 | CMOS, fixes bugs, adds instructions |
| 2A03 | NES variant, decimal mode disabled |
| 6510 | Adds I/O port (Commodore 64) |
LDX #$00
loop: INX
TXA
STA $0200,X
CPX #$10
BNE loop
BRK- https://syncopate.us/books/Synertek6502ProgrammingManual.html
- https://en.wikipedia.org/wiki/MOS_Technology_6502
- https://web.archive.org/web/20061114024257/http://www.westerndesigncenter.com/wdc/documentation/Programmanual.pdf
- Tutorial excerpts from https://wilsonminesco.com/6502primer/
- https://wilsonminesco.com/6502primer/LogicFamilies.html
- https://wilsonminesco.com/6502primer/ClkGen.html
- https://wilsonminesco.com/6502primer/RSTreqs.html
- https://wilsonminesco.com/6502primer/displays.html
- https://wilsonminesco.com/6502primer/debug.html
- https://wilsonminesco.com/6502primer/potpourri.html