## 6502 Instruction Set Quick Reference

### Overview

This table is a combination of a number of pieces of information that is
often needed. You have the command and it's English acronym, followed by what
the command actually does, followed by the flags that may be changed. After
this are all the different addressing modes that the 6502 uses with the OP code
and number of cycles the command takes for the addressing modes that are
relevant to that command. It was taken from the Commodore 64 Programmer's
Reference Guide^{1} but as the 6502 was
commonly used, this information could be found from numerous other sources.

It should probably be noted that the commands that have a range of timing values tend to take an extra cycle if addresses cross a page boundary. Branching instructions take an extra cycle if the branch is taken as well as the extra cycle for page boundary crossing.

### Table of 6502 Instructions

Command | Operation | Flags | Accumulator OPC A | Immediate OPC #$12 | Zero Page | Zero Page, X | Zero Page, Y | Absolute OPC $1234 | Absolute, X OPC $1234,X | Absolute, Y OPC $1234,Y | Implied OPC | Relative | (Indirect, X) OPC ($12,X) | (Indirect), Y OPC ($12),Y | Absolute Indirect OPC ($1234) |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

ADC (ADd with Carry) | A + M + C → A, C | NZC--V | $69 (2) | $65 (3) | $75 (4) | $6D (4) | $7D (4-5) | $79 (4-5) | $61 (6) | $71 (5-6) | |||||

AND (Logical AND) | A AND M → A | NZ---- | $29 (2) | $25 (3) | $35 (4) | $2D (4) | $3D (4-5) | $39 (4-5) | $21 (6) | $31 (5) | |||||

ASL (Arithmetic Shift Left) | C ← bits 7..0 ← 0 | NZC--- | $0A (2) | $06 (5) | $16 (6) | $0E (6) | $1E (7) | ||||||||

BCC (Branch on Carry Clear) | Branch if C = 0 | ------ | $90 (2-4) | ||||||||||||

BCS (Branch on Carry Set) | Branch if C = 1 | ------ | $B0 (2-4) | ||||||||||||

BEQ (Branch if EQual) | Branch if Z = 1 | ------ | $F0 (2-4) | ||||||||||||

BIT (BIT test) | A AND M → N=b7, V=bit6 | NZ---V | $24 (3) | $2C (4) | |||||||||||

BMI (Branch on result MInus) | Branch if N = 1 | ------ | $30 (2-4) | ||||||||||||

BNE (Branch if Not Equals) | Branch if Z = 0 | ------ | $D0 (2-4) | ||||||||||||

BPL (Branch if PLus) | Branch if N = 0 | ------ | $10 (2-4) | ||||||||||||

BRK (forced BReaK ) | Force Break | ---I-- | $00 (7) | ||||||||||||

BVC (Branch on oVerflow Clear) | Branch if V = 0 | ------ | $50 (2-4) | ||||||||||||

BVS (Branch on oVerflow Set) | Branch if V = 1 | ------ | $70 (2-4) | ||||||||||||

CLC (CLear Carry Flag) | 0 → C | --C--- | $18 (2) | ||||||||||||

CLD (CLear Decimal mode) | 0 → D | ----D- | $D8 (2) | ||||||||||||

CLI (CLear Interrupt disable) | 0 → I | ---I-- | $$58 (2) | ||||||||||||

CLV (CLear oVerflow flag) | 0 → V | -----V | $B8 (2) | ||||||||||||

CMP ( CoMPare) | A - M | NZC--- | $C9 (2) | $C5 (3) | $D5 (4) | $CD (4) | $DD (4-5) | $D9 (4-5) | $C1 (6) | $D1 (5-6) | |||||

CPX ( ComPare index X) | X - M | NZC--- | $E0 (2) | $E4 (3) | $EC (4) | ||||||||||

CPY ( ComPare index Y) | Y - M | NZC--- | $C0 (2) | $C4 (3) | $CC (4) | ||||||||||

DEC (DECrement) | M - 1 → M | NZ---- | $C6 (5) | $D6 (6) | $CE (6) | $DE (7) | |||||||||

DEX (DEcrement index X) | X - 1 → X | NZ---- | $CA (2) | ||||||||||||

DEY (DEcrement index Y) | Y - 1 → Y | NZ---- | $88 (2) | ||||||||||||

EOR (Exclusive OR) | A XOR M → A | NZ---- | $49 (2) | $45 (3) | $55 (4) | $4D (4) | $5D (4-5) | $59 (4-5) | $41 (6) | $51 (5-6) | |||||

INC (INCrement) | M + 1 → M | NZ---- | $E6 (5) | $F6 (6) | $EE (6) | $FE (7) | |||||||||

INX (INcrement index X) | X + 1 → X | NZ---- | $E8 (2) | ||||||||||||

INY (INcrement index Y) | Y + 1 → Y | NZ---- | $C8 (2) | ||||||||||||

JMP (JuMP to address) | PC = Address | ------ | $4C (3) | $6C (5) | |||||||||||

JSR (Jump to SubRoutine) | PC+2 → Stack; PC = Address | ------ | $20 (6) | ||||||||||||

LDA (LoaD Accumulator) | M → A | NZ---- | $A9 (2) | $A5 (3) | $B5 (4) | $AD (4) | $BD (4-5) | $B9 (4-5) | $A1 (6) | $B1 (5-6) | |||||

LDX (LoaD index X) | M → X | NZ---- | $A2 (2) | $A6 (3) | $B6 (4) | $AE (4) | $BE (4-5) | ||||||||

LDY (LoaD index Y) | M → Y | NZ---- | $A0 (2) | $A4 (3) | $B4 (4) | $AC (4) | $BC (4-5) | ||||||||

LSR (Logical Shift Right) | 0 → bits(7..0) → C | NZC--- | $4A (2) | $46 (5) | $56 (6) | $4E (6) | $5E (7) | ||||||||

NOP (No OPeration) | ------ | $EA (2) | |||||||||||||

ORA (OR Accumulator) | A OR M → A | NZ---- | $09 (2) | $05 (3) | $15 (4) | $0D (4) | $1D (4-5) | $19 (4-5) | $01 (6) | $11 (5) | |||||

PHA (PusH Accumulator) | A → Stack | ------ | $48 (3) | ||||||||||||

PHP (PusH Processor status) | Flags → Stack | ------ | $08 (3) | ||||||||||||

PLA (PulL Accumulator) | Stack → A | NZ---- | $68 (4) | ||||||||||||

PLP (PulL Processor status) | Stack → Flags | NZCIDV | $28 (4) | ||||||||||||

ROL (ROtate Left) | C ← bits 7..0 ← starting C | NZC--- | $2A (2) | $26 (5) | $36 (6) | $2E (6) | $3E (7) | ||||||||

ROR (ROtate Right) | C → bits 7..0 → C | NZC--- | $6A (2) | $66 (5) | $76 (6) | $6E (6) | $7E (6) | ||||||||

RTI ( ReTurn from Interrupt) | Stack → flags; stack → PC | NZCIDV | $40 (6) | ||||||||||||

RTS ( ReTurn from Subroutine) | Stack → PC | ------ | $60 (6) | ||||||||||||

SBC ( SuBtract with Carry) | A - M - C(borrow) → A | NZC--V | $E9 (2) | $E5 (3) | $F5 (4) | $ED (4) | $FD (4-5) | $F9 (4-5) | $E1 (6) | $F1 (5-6) | |||||

SEC (SEt Carry) | 1 → C | --C--- | $38 (2) | ||||||||||||

SED (SEt Decimal mode) | 1 → D | ----D- | $F8 (2) | ||||||||||||

SEI (SEt Interrupt disable) | 1 → I | ---I-- | $78 (2) | ||||||||||||

STA (STore Accumulator) | A → M | ------ | $85 (3) | $95 (4) | $8D (4) | $9D (5) | $99 (5) | $81 (6) | $91 (6) | ||||||

STX (STore index X) | X → M | ------ | $86 (3) | $96 (4) | $8E (4) | ||||||||||

STY (STore index Y) | Y → M | ------ | $84 (3) | $94 (4) | $8C (4) | ||||||||||

TAX (Transfer Accumulator to X) | A → X | NZ---- | $AA (2) | ||||||||||||

TAY (Transfer Accumulator to Y) | A → Y | NZ---- | $A8 (2) | ||||||||||||

TSX (Transfer Stack pointer to X) | SP → X | NZ---- | $BA (2) | ||||||||||||

TXA (Transfer X to Accumulator) | X → A | NZ---- | $8A (2) | ||||||||||||

TXS (Transfer X to Stack pointer) | X → SP | ------ | $9A (2) | ||||||||||||

TYA (Transfer Y to Accumulator) | Y → A | NZ---- | $98 (2) |