The original NMOS version of the 6502 has 151 legal opcodes.
Out of the total number of possible opcodes, ilegal opcodes have been found to be sometimes useful.
The ISA included in this page will cover the legal opcodes. Ilegal opcodes may be added in the future as an extension to this page.
The instructions can be categorized according to the type of operation they perform. We can distinguish between the following categories:
Logical and bit manipulation operations . Operations such as AND, OR, XOR, etc.
Arithmetic operations . Operations such as ADD, SUBSTRACT, INCREMENT, etc.
Data shifting instructions . Shift values in registers. Can be either logical, arithmetic or rotation instructions.
Program control flow operations . Control the flow of the program. They allow to set/modify the value of the program counter.
Memory transfer operations . Transfers memory between different parts of the system (Mainly processor and main memory).
Mnemonic Opcode Addressing mode Modified Flags Description
AND 29'hImmediate N, ZAnd M with A: A AND M -> A
25'hZeropage
35'hZeropage, X-Indexed
2D'hAbsolute
3D'hAbsolute, X-Indexed
39'hAbsolute, Y-Indexed
21'hX-Indexed, Indirect
31'hIndirect, Y-Indexed
ORA 09'hImmediate N, ZOr M with A. A OR M -> A.
05'hZeropage
15'hZeropage, X-Indexed
0D'hAbsolute
1D'hAbsolute, X-Indexed
19'hAbsolute, Y-Indexed
01'hX-Indexed, Indirect
11'hIndirect, Y-Indexed
EOR 49'hImmediate N, ZExclusive or A with M. (A XOR M) -> A.
45'hZeropage
55'hZeropage, X-Indexed
4D'hAbsolute
5D'hAbsolute, X-Indexed
59'hAbsolute, Y-Indexed
41'hX-Indexed, Indirect
51'hIndirect, Y-Indexed
Mnemonic Opcode Addressing mode Modified Flags Description
CMP C9'hImmediate N, Z, CCompare M with A. (A-M). Result is not stored.
C5'hZeropage
D5'hZeropage, X-Indexed
CD'hAbsolute
DD'hAbsolute, X-Indexed
D9'hAbsolute, Y-Indexed
C1'hX-Indexed, Indirect
D1'hIndirect, Y-Indexed
CPX E0'hImmediate N, Z, CCompare M and X. (X - M). The result is not stored.
E4'hZeropage
EC'hAbsolute
CPY C0'hImmediate N, Z, CCompare M and Y. (Y - M). The result is not stored.
C4'hZeropage
CC'hAbsolute
NOP EA'hImplied NOP.
Mnemonic Opcode Addressing mode Modified Flags Description
BIT 24'hZeropage N, Z, VM7 -> N, M6 -> V, (M AND A == 0) -> Z.
2C'hAbsolute
CLC 18'hImplied Clear C flag.
CLD D8'hImplied Clear D flag.
CLI 58'hImplied Clear I flag.
CLV B8'hImplied Clear O flag.
SEC 38'hImplied CSet C flag.
SED F8'hImplied DSet D flag.
SEI 78'hImplied ISet I flag.
Mnemonic Opcode Addressing mode Modified Flags Description
ADC 69'hImmediate N, Z, C, VAdd with carry: A + M + C -> A, C.
65'hZeropage
75'hZeropage, X-Indexed
6D'hAbsolute
7D'hAbsolute, X-Indexed
79'hAbsolute, Y-Indexed
61'hX-Indexed, Indirect
71'hIndirect, Y-Indexed
SBC E9'hImmediate N, Z, C, VSubtract M from A with borrow. (A - M - Cbar) -> A.
E5'hZeropage
F5'hZeropage, X-Indexed
ED'hAbsolute
FD'hAbsolute, X-Indexed
F9'hAbsolute, Y-Indexed
E1'hX-Indexed, Indirect
F1'hIndirect, Y-Indexed
Mnemonic Opcode Addressing mode Modified Flags Description
INC E6'hZeropage N, ZIncrement M by one. (M + 1) -> M.
F6'hZeropage, X-Indexed
EE'hAbsolute
FE'hAbsolute, X-Indexed
INX E8'hImplied N, ZIncrement X by one. (X + 1) -> X.
INY C8'hImplied N, ZIncrement Y by one. (Y + 1) -> Y.
DEC C6'hZeropage N, ZDecrement M by one. (M - 1) -> M.
D6'hZeropage, X-Indexed
CE'hAbsolute
DE'hAbsolute, X-Indexed
DEX CA'hImplied N, ZDecrement X by one. (X - 1) -> X.
DEY 88'hImplied N, ZDecrement Y by one. (Y - 1) -> Y.
Mnemonic Opcode Addressing mode Modified Flags Description
LSR 4A'hAccumulator N(0), Z, CLogical shift right (1 bit).
46'hZeropage
56'hZeropage, X-Indexed
4E'hAbsolute
5E'hAbsolute, X-Indexed
ASL 0A'hAccumulator N, Z, CArithmetic shift left by one bit (M or A).
06'hZeropage
16'hZeropage, X-Indexed
0E'hAbsolute
1E'hAbsolute, X-Indexed
ROL 2A'hAccumulator N, Z, CRotate one bit left (Circular rotation, including C bit).
26'hZeropage
36'hZeropage, X-Indexed
2E'hAbsolute
3E'hAbsolute, X-Indexed
ROR 6A'hAccumulator N, Z, CRotate one bit left (Circular rotation, including C bit).
66'hZeropage
76'hZeropage, X-Indexed
6E'hAbsolute
7E'hAbsolute, X-Indexed
Mnemonic Opcode Addressing mode Modified Flags Description
JMP 4C'hAbsolute Jump to the M location.
6C'hIndirect
Mnemonic Opcode Addressing mode Modified Flags Description
BCS B0'hRelative Branch if C is set.
BCC 90'hRelative Branch if C is clear.
BEQ F0'hRelative Branch if Z is set.
BNE D0'hRelative Branch if Z is clear
BMI 30'hRelative Branch if N is set
BPL 10'hRelative Branch if N is clear
BVS 70'hRelative Branch if V is set
BVC 50'hRelative Branch if V is clear
Mnemonic Opcode Addressing mode Modified Flags Description
JSR 20'hAbsolute Jump to subrutine (Saves return address in the stack)
RTS 60'hImplied Returns from subroutine. Pulls PC from SP
Mnemonic Opcode Addressing mode Modified Flags Description
BRK 00'hImplied I Triggers a software interrupt. Pushes the PC+2 and SP to the stack
RTI 40'hImplied From SP Returns from the current ISR. Pulls P and PC
Mnemonic Opcode Addressing mode Modified Flags Description
LDA A9'hImmediate N, ZLoads the A with M.
A5'hZeropage
B5'hZeropage, X-Indexed
AD'hAbsolute
BD'hAbsolute, X-Indexed
B9'hAbsolute, Y-Indexed
A1'hX-Indexed, Indirect
B1'hIndirect, Y-Indexed
STA 85'hZeropage Stores the A in M.
95'hZeropage, X-Indexed
8D'hAbsolute
9D'hAbsolute, X-Indexed
99'hAbsolute, Y-Indexed
81'hX-Indexed, Indirect
91'hIndirect, Y-Indexed
LDX A2'hImmediate N, ZLoads the X register with M.
A6'hZeropage
B6'hZeropage, Y-Indexed
AE'hAbsolute
BE'hAbsolute, Y-Indexed
STX 86'hZeropage Stores the X register in M.
96'hZeropage, Y-Indexed
8E'hAbsolute
LDY A0'hImmediate N, ZLoads the Y register with M.
A4'hZeropage
B4'hZeropage, X-Indexed
AC'hAbsolute
BC'hAbsolute, X-Indexed
STY 84'hZeropage Stores the Y register in M.
94'hZeropage, X-Indexed
8C'hAbsolute
Mnemonic Opcode Addressing mode Modified Flags Description
TAX AA'hImplied Transfer A to X. A -> X.
TXA 8A'hImplied Transfer X to A. X -> A.
TAY A8'hImplied Transfer A to Y. A -> Y.
TYA 98'hImplied Transfer Y to A. Y -> A.
TSX BA'hImplied Transfer SP to X. SP -> X.
TXS 9A'hImplied Transfer X to SP. X -> SP.
Mnemonic Opcode Addressing mode Modified Flags Description
PHA 48'hImplied Push A to the stack.
PLA 68'hImplied Pull A from the stack.
PHP 08'hImplied Push P to the stack.
PLP 28'hImplied Pull P from the stack.