André's 8-bit Pages  Projects  Code  Resources  Tools  Forum
(by Google)

65002 Opcode Overview

This page gives an overview over the 65002 opcodes, sorted by opcode page. The default page is the standard, 6502 opcode page. The other pages require the corresponding prefix opcode.

LSB->
MSB
0123456789ABCDEF
0
BRK #byte
ORA (zp,X)
LDA zp,Y
prefix1
TSB zp
ORA zp
ASL zp
prefix1
PHP
ORA #byte
ASL
prefix2
TSB abs
ORA abs
ASL abs
EXT
1
BPL rel
ORA (zp),Y
ORA (zp)
prefix1
TRB zp
ORA zp,X
ASL zp,X
prefix1
CLC
ORA abs,Y
INC
prefix2
TRB abs
ORA abs,X
ASL abs,X
2
JSR abs
AND (zp,X)
STA zp,Y
prefix1
BIT zp
AND zp
ROL zp
prefix1
PLP
AND #byte
ROL
prefix2
BIT abs
AND abs
ROL abs
SYS
3
BMI rel
AND (zp),Y
AND (zp)
prefix1
BIT zp,X
AND zp,X
ROL zp,X
prefix1
SEC
AND abs,Y
DEC
prefix2
BIT abs,X
AND abs,X
ROL abs,X
4
RTI
EOR (zp,X)
LDA (abs),Y
prefix1
BSR relwide
EOR zp
LSR zp
prefix1
PHA
EOR #byte
LSR
prefix2
JMP abs
EOR abs
LSR abs
QUICK
5
BVC rel
EOR (zp),Y
EOR (zp)
prefix1
EOR zp,X
LSR zp,X
prefix1
CLI
EOR abs,Y
PHY
prefix2
EOR abs,X
LSR abs,X
6
RTS
ADC (zp,X)
LDA (abs,X)
prefix1
STZ zp
ADC zp
ROR zp
prefix1
PLA
ADC #byte
ROR
prefix2
JMP (abs)
ADC abs
ROR abs
reserved prefix
7
BVS rel
ADC (zp),Y
ADC (zp)
prefix1
STZ zp,X
ADC zp,X
ROR zp,X
prefix1
SEI
ADC abs,Y
PLY
prefix2
JMP (abs,X)
ADC abs,X
ROR abs,X
8
BRA rel
STA (zp,X)
BSR rel
prefix1
STY zp
STA zp
STX zp
prefix1
DEY
BIT #byte
TXA
prefix2
STY abs
STA abs
STX abs
reserved prefix
9
BCC rel
STA (zp),Y
STA (zp)
prefix1
STY zp,X
STA zp,X
STX zp,Y
prefix1
TYA
STA abs,Y
TXS
prefix2
STZ abs
STA abs,X
STZ abs,X
reserved prefix
A
LDY #byte
LDA (zp,X)
LDX #byte
prefix1
LDY zp
LDA zp
LDX zp
prefix1
TAY
LDA #byte
TAX
prefix2
LDY abs
LDA abs
LDX abs
reserved prefix
B
BCS rel
LDA (zp),Y
LDA (zp)
prefix1
LDY zp,X
LDA zp,X
LDX zp,Y
prefix1
CLV
LDA abs,Y
TSX
prefix2
LDY abs,X
LDA abs,X
LDX abs,Y
reserved prefix
C
CPY #byte
CMP (zp,X)
STA (abs),Y
prefix1
CPY zp
CMP zp
DEC zp
prefix1
INY
CMP #byte
DEX
prefix2
CPY abs
CMP abs
DEC abs
reserved prefix
D
BNE rel
CMP (zp),Y
CMP (zp)
prefix1
CMP zp,X
DEC zp,X
prefix1
CLD
CMP abs,Y
PHX
prefix2
JSR (abs)
CMP abs,X
DEC abs,X
reserved prefix
E
CPX #byte
SBC (zp,X)
STA (abs,X)
prefix1
CPX zp
SBC zp
INC zp
prefix1
INX
SBC #byte
NOP
prefix2
CPX abs
SBC abs
INC abs
reserved prefix
F
BEQ rel
SBC (zp),Y
SBC (zp)
prefix1
TRP #byte
SBC zp,X
INC zp,X
prefix1
SED
SBC abs,Y
PLX
prefix2
JSR (abs,X)
SBC abs,X
INC abs,X
reserved prefix

Legend:

NMOS OpcodesCMOS OpcodesNew 65k opcodes65k Prefix codesUnused/Reserved
  • ADC: Add content of memory location to accumulator
  • AND: Bitwise AND accumulator with content of memory location
  • ASL: Arithmetic Shift Left - shift accumulator one bit to the left, shifting in zero in bit 0
  • BCC: Branch on carry clear - take branch when C flag is cleared
  • BCS: Branch on carry set - take branch when C flag is set
  • BEQ: Branch on equal - take branch when Z flag is set
  • BIT: Bitwise test with accumulator - AND the memory location with the accumulator, and set N (=bit 7), V (=bit 7), Z (iff all bits zero) flags from the result. In case of the accumulator addressing, simply set the flags from the accumulator
  • BMI: Branch on minus - take branch when N flag is set
  • BNE: Branch on not equal - take branch when Z flag is cleared
  • BPL: Branch on plus - take branch when N flag is cleared
  • BRA: Branch always - branch independent from any flags
  • BRK: Starts the break routine.
  • BSR: Branch subroutine - similar to JSR, but use relative addressing similar to branch opcodes
  • BVC: Branch on overflow clear - take branch when V flag is cleared
  • BVS: Branch on overflow set - take branch when V flag is set
  • CLC: Clear the C flag
  • CLD: Clear the decimal (D) flag
  • CLI: Clear the interrupt (I) flag
  • CLV: Clear the overflow (V) flag
  • CMP: Compare accumulator with content of memory location
  • CPX: Compare X register with content of memory location
  • CPY: Compare Y register with content of memory location
  • DEC: Decrement the content of a memory location by one
  • DEX: Decrement the content of the X register by one
  • DEY: Decrement the Y register by one
  • EOR: Bitwise Exclusive-OR accumulator with content of memory location
  • INC: Increment the content of a memory location by one
  • INX: Increment the content of the X register by one
  • INY: Increment the content of the Y register by one
  • JMP: Jump to new code address
  • JSR: Jump subroutine - jump to a new code location, save return address on stack for RTS
  • LDA: Load accumulator
  • LDX: Load X register
  • LDY: Load Y register
  • LSR: Logical Shift Right - shift accumulator one bit to the right, shifting in zero in the highest bit
  • NOP: No operation
  • ORA: Bitwise OR accumulator with content of memory location
  • PHA: Push contents of the accumulator onto the stack
  • PHP: Push processor status register onto the stack
  • PHX: Push contents of the X register onto the stack
  • PHY: Push contents of the Y register onto the stack
  • PLA: Pull the contents of the accumulator from the stack
  • PLP: Pull processor status register from the stack
  • PLX: Pull the contents of the X register from the stack
  • PLY: Pull the contents of the Y register from the stack
  • ROL: Rotate Left - shift accumulator one bit to the left, shifting in the carry flag in bit 0, and shifting the highest bit into the carry flag instead.
  • ROR: Rotate Right - shift accumulator one bit to the right, shifting in the carry flag in the highest bit, and shifting bit 0 into the carry flag instead.
  • RTI: Return from interrupt
  • RTS: Return from subroutine - read return address from stack
  • SBC: Substract content of memory location from accumulator
  • SEC: Set the C flag
  • SED: Set the decimal (D) flag
  • SEI: Set the interrupt (I) flag
  • STA: Store the content of the accumulator into a memory location
  • STX: Store the content of the X register to memory.
  • STY: Store the content of the Y register to memory.
  • STZ: Store zero into a memory location
  • TAX: Transfer the contents of accumulator into the X register
  • TAY: Transfer the contents of accumulator into the Y register
  • TRB: Test and Reset Bit - AND the memory location with the accumulator, and set the Z flag from the result, then CLEAR all bits in the memory location that are set in the accumulator.
  • TRP: Trap into 65k supervisor mode
  • TSB: Test and Set Bit - AND the memory location with the accumulator, and set the Z flag from the result, then SET all bits in the memory location that are set in the accumulator.
  • TSX: Transfer the contents of the stack pointer into the X register (Note: needs RS to keep compatibility with 6502)
  • TXA: Transfer the contents of the X register into the accumulator
  • TXS: Transfer the contents of X register into the stack pointer (Note: needs RS to keep compatibility with 6502)
  • TYA: Transfer the contents of the Y register into the accumulator
LSB->
MSB
0123456789ABCDEF
0
ADD (E)
PEA (abs),Y
PEA relwide
MVN
ADD #byte
ASR zp
PHE
ORA (E)
ASR
TSB (E)
ASL (E)
ASR abs
ASL abs,Y
1
BEV rel
PEA (abs,X)
PEA (abs)
MVP
ASR zp,X
TRB (E)
ASR (E)
ASR abs,X
ASR abs,Y
2
JSR (E)
LEA (abs),Y
LEA relwide
FIL
ADE #byte
RDL zp
PLE
AND (E)
RDL
SCA (E)
ROL (E)
RDL abs
ROL abs,Y
3
BOD rel
LEA (abs,X)
LEA (abs)
BIT
ADE
RDL zp,X
LDE #byte
LLA (E)
RDL (E)
RDL abs,X
RDL abs,Y
4
PEA [[abs]],Y
PSH
ADS #byte
LEA zp
PHB
EOR (E)
JMP (E)
LSR (E)
LSR abs,Y
5
BLTS rel
PEA [[abs,X]]
PEA [[abs]]
PLL
ADS
LEA zp,X
PRB
LDB #byte
6
LEA [[abs]],Y
RMB
ADB #byte
RDR zp
PLB
ADC (E)
RDR
JMP long
ROR (E)
RDR abs
ROR abs,Y
7
BGES rel
LEA [[abs,X]]
LEA [[abs]]
WMB
ADB
RDR zp,X
RDR (E)
RDR abs,X
RDR abs,Y
8
SUB (E)
PEA (zp,X)
PEA rel
HBS
SUB #byte
PEA zp
TAE
BIT (E)
TYS
STY (E)
STA (E)
STY abs,X
9
BLE rel
PEA (zp),Y
PEA (zp)
HBC
PEA zp,X
TEA
SXY
STZ (E)
STX (E)
STZ abs,Y
A
LDY (E)
LEA (zp,X)
LEA rel
INV
SBE #byte
SAB
LDA (E)
LDX (E)
LEA abs
STX abs,Y
B
BGT rel
LEA (zp),Y
LEA (zp)
BCN
SBE
SEB
SAX
LEA abs,X
LEA abs,Y
C
CPY (E)
PEA [[zp]],Y
EXT
SBS #byte
TPA
CMP (E)
TSY
DEC (E)
PEA abs
DEC abs,Y
D
BLES rel
PEA [[zp,X]]
PEA [[zp]]
SWP
SBS
PEA zp,Y
SAE
SAY
JSR long
PEA abs,X
PEA abs,Y
E
CPX (E)
LEA [[zp]],Y
SBB #byte
TAB
SBC (E)
TEB
RMB (E)
INC (E)
INC abs,Y
F
BGTS rel
LEA [[zp,X]]
LEA [[zp]]
BSW
SBB
LEA zp,Y
TBA
TBE
WMB (E)
  • ADB: Add value to B register
  • ADE: Add value to E register
  • ADS: Add value to stack pointer
  • ASR: Arithmetic Shift Right - Similar to LSR, but shifts in the sign of the value, not zero
  • BCN: Bit Count: counts 1-bits in AC or in given location, stores number of 1-bits back in AC
  • BEV: Branch on even
  • BGES: Branch on signed greater or equal than
  • BGT: Branch if greater - take branch when C flag is set but Z flag is clear
  • BGTS: Branch if greater - take branch when signed greater or equal G flag is set but Z flag is clear
  • BLE: Branch if less or equal - take branch when C flag is clear or Z flag is set
  • BLES: Branch if less or equal - take branch when signed greater or equal flag G is clear or Z flag is set
  • BLTS: Branch on signed less than
  • BOD: Branch on odd
  • BSW: Bit Swap: exchanges bit 0 with bit W-1, bit 1 with bit W-2 and so on.
  • EXT: Extend a value in AC from RS to the full size. Setting LE defines the type of extension.
  • FIL: Fill a memory area of size AC at address XR with a value from YR
  • HBC: Highest Bit Clear: Determines the number of the highest bit that is set to zero.
  • HBS: Highest Bit Set: Determines the number of the highest bit that is set to one.
  • INV: invert AC, i.e. set AC to the 2s-complement of AC
  • LDB: Load B with an immediate value
  • LDE: Load E with an immediate value
  • LEA: Load Effective Address: compute the effective address and store it in the E (effective Address) register (always full width)
  • LLA: Load linked AC - load the content from a memory location into accumulator, optimistic-locking the address for SCA
  • MVN: Move block of data of size AC from XR to YR, count addresses down. All registers full size, interruptable
  • MVP: Move block of data of size AC from XR to YR, count addresses down. All registers full size, interruptable
  • PEA: Push Effective Address: compute the effective address and push it onto the stack (always full width)
  • PHB: Push B onto stack (full width)
  • PHE: Push E onto stack (always full width)
  • PLB: Pull E from stack (full width)
  • PLE: Pull E from stack (full width)
  • PLL: Pull the contents of all registers from the stack
  • PRB: Push and Replace Base register: Push base offset register to the stack, then transfer accumulator to the base register
  • PSH: Push contents of all registers (A, X, Y, B, E) onto the stack
  • RDL: Rotate Direct Left - similar to ROL, but do not shift in carry, but the highest bit of the original value
  • RDR: Rotate Direct Right - similar to ROR, but do not shift in carry, but the lowest bit of the original value
  • RMB: Read memory barrier: invalidates cache content (globally, or for a specific, given location)
  • SAB: Swap A register with B register. Always done full width, no flags set.
  • SAE: Swap AC with E register. Always done full width, no flags set.
  • SAX: Swap AC with X register. Always done full width, no flags set.
  • SAY: Swap AC with Y register. Always done full width, no flags set.
  • SBB: Substract value from B register
  • SBE: Add value to E register
  • SBS: Substract value from stack pointer
  • SCA: Store conditional - store the contents of AC into a memory location, if location has not been accessed since LLA with same address (and no other LLA in same thread)
  • SEB: Swap E register with B register. Always done full width, no flags set.
  • STZ: Store zero into a memory location
  • SWP: swap upper and lower part nibble / byte / word / long word of a byte / word / long / quad (longlong) operand in Accumulator
  • SXY: Swap X with Y register. Always done full width, no flags set.
  • TAB: Transfer AC to B register
  • TAE: Transfer AC to E register
  • TBA: Transfer base register B to Accumulator
  • TBE: Transfer content of B register into E register (full width)
  • TEA: Transfer E register to Accumulator
  • TEB: Transfer E to B register (full width)
  • TPA: Transfer Program counter to Accumulator
  • TRB: Test and Reset Bit - AND the memory location with the accumulator, and set the Z flag from the result, then CLEAR all bits in the memory location that are set in the accumulator.
  • TSB: Test and Set Bit - AND the memory location with the accumulator, and set the Z flag from the result, then SET all bits in the memory location that are set in the accumulator.
  • TSY: Transfer stack pointer to Y
  • TYS: Transfer Y to stack pointer
  • WMB: Write memory barrier: flushes dirty caches (globally, or for a specific, given location)
 

Disclaimer

All Copyrights are acknowledged. The information here is provided under the terms as described in the license section.

Last updated 2012-04-23. Last modified: 2013-11-17
follow

Follow my 8-bit tweets on Mastodon (In new window) or Bluesky

discuss

Discuss my site on this 6502.org forum thread

(Forum registration required to post)

hot!

Dive into the retro feeling and build yourself a Micro-PET or a Multi-board Commodore 4032 replica

Need more speed? Speed up your 6502 computer with this 10 MHz 6502 CPU accelerator board

Interested in electronics design? Look at the design lesson I got from Bil Herd, the hardware designer of the C128

Want 64bit? - pimp the 6502 with the 65k processor design!