6502 Instruction Set

Bits Mode Bits Condition
000[[xx + X]]000PL
001[xx]001MI
010#xx010VC
011[xxxx]011VS
100[[xx] + Y]100CC
101[xx + X]101CS
110[xxxx + Y]110NE
111[xxxx + X]111EQ

ADC

A = A + M + C

Opcode Instruction Size Cycles Flags
011 mode 01ADC M  N Z C V
61ADC [[xx + X]]26N Z C V
65ADC [xx]23N Z C V
69ADC #xx22N Z C V
6DADC [xxxx]34N Z C V
71ADC [[xx] + Y]25*N Z C V
75ADC [xx + X]24N Z C V
79ADC [xxxx + Y]34*N Z C V
7DADC [xxxx + X]34*N Z C V

AND

A = A & M

Opcode Instruction Size Cycles Flags
001 mode 01AND M  N Z
21AND [[xx + X]]26N Z
25AND [xx]23N Z
29AND #xx22N Z
2DAND [xxxx]34N Z
31AND [[xx] + Y]25*N Z
35AND [xx + X]24N Z
39AND [xxxx + Y]34*N Z
3DAND [xxxx + X]34*N Z

ASL

C = M[7], M = M << 1

Opcode Instruction Size Cycles Flags
000 mode 10ASL M  N Z C
02undef--N Z C
06ASL [xx]25N Z C
0AASL A12N Z C
0EASL [xxxx]36N Z C
12undef--N Z C
16ASL [xx + X]26N Z C
1Aundef--N Z C
1EASL [xxxx + X]37N Z C

Bcc

Branch on condition true

Opcode Instruction Size Cycles Flags
cond 10000Bcc xx22* 
10BPL xx22* 
30BMI xx22* 
50BVC xx22* 
70BVS xx22* 
90BCC xx22* 
B0BCS xx22* 
D0BNE xx22* 
F0BEQ xx22* 

BIT

N = (A & M)[7], V = (A & M)[6]

Opcode Instruction Size Cycles Flags
24BIT [xx]23N Z V
2CBIT [xxxx]34N Z V

BRK

Forced interrupt
Opcode Instruction Size Cycles Flags
00BRK17I

CLC

C = 0

Opcode Instruction Size Cycles Flags
18CLC12C

CLD

D = 0

Opcode Instruction Size Cycles Flags
D8CLD12D

CLI

I = 0

Opcode Instruction Size Cycles Flags
58CLI12I

CLV

V = 0

Opcode Instruction Size Cycles Flags
B8CLV12V

CMP

A - M

Opcode Instruction Size Cycles Flags
110 mode 01CMP M  N Z C
C1CMP [[xx + X]]26N Z C
C5CMP [xx]23N Z C
C9CMP #xx22N Z C
CDCMP [xxxx]34N Z C
D1CMP [[xx] + Y]25*N Z C
D5CMP [xx + X]24N Z C
D9CMP [xxxx + Y]34*N Z C
DDCMP [xxxx + X]34*N Z C

CPX

X - M

Opcode Instruction Size Cycles Flags
E0CPX #xx22N Z C
E4CPX [xx]23N Z C
ECCPX [xxxx]34N Z C

CPY

Y - M

Opcode Instruction Size Cycles Flags
C0CPY #xx22N Z C
C4CPY [xx]23N Z C
CCCPY [xxxx]34N Z C

DEC

M = M - 1

Opcode Instruction Size Cycles Flags
110 mode 10DEC M  N Z
C2undef---
C6DEC [xx]25N Z
CADEX12N Z
CEDEC [xxxx]36N Z
D2undef---
D6DEC [xx + X]26N Z
DAundef---
DEDEC [xxxx + X]37N Z

DEX

X = X - 1

Opcode Instruction Size Cycles Flags
CADEX12N Z

DEY

Y = Y - 1

Opcode Instruction Size Cycles Flags
88DEY12N Z

EOR

A = A ^ M

Opcode Instruction Size Cycles Flags
010 mode 01EOR M  N Z
41EOR [[xx + X]]26N Z
45EOR [xx]23N Z
49EOR #xx22N Z
4DEOR [xxxx]34N Z
51EOR [[xx] + Y]25*N Z
55EOR [xx + X]24N Z
59EOR [xxxx + Y]34*N Z
5DEOR [xxxx + X]34*N Z

INC

M = M + 1

Opcode Instruction Size Cycles Flags
111 mode 10INC M  N Z
E2undef---
E6INC [xx]25N Z
EANOP12 
EEINC [xxxx]36N Z
F2undef---
F6INC [xx + X]26N Z
FAundef---
FEINC [xxxx + X]37N Z

INX

X = X + 1

Opcode Instruction Size Cycles Flags
E8INX12N Z

INY

Y = Y + 1

Opcode Instruction Size Cycles Flags
C8INY12N Z

JMP

Jump

Opcode Instruction Size Cycles Flags
4CJMP xxxx33 
6CJMP [xxxx]35 

JSR

Jump to subroutine

Opcode Instruction Size Cycles Flags
20JSR xxxx36 

LDA

A = M

Opcode Instruction Size Cycles Flags
101 mode 01LDA M  N Z
A1LDA [[xx + X]]26N Z
A5LDA [xx]23N Z
A9LDA #xx22N Z
ADLDA [xxxx]34N Z
B1LDA [[xx] + Y]25*N Z
B5LDA [xx + X]24N Z
B9LDA [xxxx + Y]34*N Z
BDLDA [xxxx + X]34*N Z

LDX

X = M

Opcode Instruction Size Cycles Flags
A2LDX #xx22N Z
A6LDX [xx]23N Z
AELDX [xxxx]34N Z
B6LDX [xx + Y]24N Z
BELDX [xxxx + Y]34*N Z

LDY

Y = M

Opcode Instruction Size Cycles Flags
A0LDY #xx22N Z
A4LDY [xx]23N Z
ACLDY [xxxx]34N Z
B4LDY [xx + X]24N Z
BCLDY [xxxx + X]34*N Z

LSR

C = M[0], M = M >> 1

Opcode Instruction Size Cycles Flags
010 mode 10LSR M  N Z C
42undef---
46LSR [xx]25N Z C
4ALSR A12N Z C
4ELSR [xxxx]36N Z C
52undef---
56LSR [xx + X]26N Z C
5Aundef---
5ELSR [xxxx + X]37N Z C

NOP

No operation

Opcode Instruction Size Cycles Flags
EANOP12 

ORA

A = A | M

Opcode Instruction Size Cycles Flags
000 mode 01ORA M  N Z
01ORA [[xx + X]]26N Z
05ORA [xx]23N Z
09ORA #xx22N Z
0DORA [xxxx]34N Z
11ORA [[xx] + Y]25N Z
15ORA [xx + X]24N Z
19ORA [xxxx + Y]34*N Z
1DORA [xxxx + X]34*N Z

PHA

Push A

Opcode Instruction Size Cycles Flags
48PHA13 

PHP

Push P

Opcode Instruction Size Cycles Flags
08PHP13 

PLA

Pop A

Opcode Instruction Size Cycles Flags
68PLA14 

PLP

Pop A

Opcode Instruction Size Cycles Flags
28PLP14N Z C I D V

ROL

T = M[7], M = (M << 1) + C, C = T

Opcode Instruction Size Cycles Flags
001 mode 10ROL M  N Z C
22undef---
26ROL [xx]25N Z C
2AROL A12N Z C
2EROL [xxxx]36N Z C
32undef---
36ROL [xx + X]26N Z C
3Aundef---
3EROL [xxxx + X]37N Z C

ROR

T = M[0], M = (M >> 1) + (C << 7), C = T

Opcode Instruction Size Cycles Flags
011 mode 10ROR M  N Z C
62undef---
66ROR [xx]25N Z C
6AROR A12N Z C
6EROR [xxxx]36N Z C
72undef---
76ROR [xx + X]26N Z C
7Aundef---
7EROR [xxxx + X]37N Z C

RTI

Return from interrupt

Opcode Instruction Size Cycles Flags
40RTI16 

RTS

Return from subroutine

Opcode Instruction Size Cycles Flags
60RTS16 

SBC

A = A - M - ~C

Opcode Instruction Size Cycles Flags
111 mode 01SBC M  N Z C V
E1SBC [[xx + X]]26N Z C V
E5SBC [xx]23N Z C V
E9SBC #xx22N Z C V
EDSBC [xxxx]34N Z C V
F1SBC [[xx] + Y]25*N Z C V
F5SBC [xx + X]24N Z C V
F9SBC [xxxx + Y]34*N Z C V
FDSBC [xxxx + X]34*N Z C V

SEC

C = 1
Opcode Instruction Size Cycles Flags
38SEC12C

SED

D = 1

Opcode Instruction Size Cycles Flags
F8SED12D

SEI

I = 1

Opcode Instruction Size Cycles Flags
78SEI12I

STA

M = A

Opcode Instruction Size Cycles Flags
100 mode 01STA M   
81STA [[xx + X]]26 
85STA [xx]23 
89undef---
8DSTA [xxxx]34 
91STA [[xx] + Y]26 
95STA [xx + X]24 
99STA [xxxx + Y]35 
9DSTA [xxxx + X]35 

STX

M = X

Opcode Instruction Size Cycles Flags
86STX [xx]23 
8ESTX [xxxx]34 
96STX [xx + Y]24 

STY

M = Y

Opcode Instruction Size Cycles Flags
84STY [xx]23 
8CSTY [xxxx]34 
94STY [xx + X]24 

TAX

X = A

Opcode Instruction Size Cycles Flags
AATAX12N Z

TAY

Y = A

Opcode Instruction Size Cycles Flags
A8TAY12N Z

TSX

X = S

Opcode Instruction Size Cycles Flags
BATSX12N Z

TXA

A = X

Opcode Instruction Size Cycles Flags
8ATXA12N Z

TXS

S = X

Opcode Instruction Size Cycles Flags
9ATXS12 

TYA

A = Y

Opcode Instruction Size Cycles Flags
98TYA12N Z