6502 Family CPU Reference

by Michael Steil. [github.com/mist64/c64ref, rev fd22ad3, 2025-03-12]

Implied

In the implied addressing mode, the address containing the operand is implicitly stated in the operation code of the instruction.

Bytes: 1

InstructionOpcodeNo. Cycles
AUG $5C4
BRK $002
CLC $181
CLD $D81
CLE $021
CLI $581
CLV $B81
DEX $CA1
DEY $881
DEZ $3B1
INX $E81
INY $C81
INZ $1B1
NOP $EA1
PHA $481
PHP $081
PHX $DA1
PHY $5A1
PHZ $DB1
PLA $681
PLP $281
PLX $FA1
PLY $7A1
PLZ $FB1
RTI $401
RTS $601
SEC $381
SED $F81
SEE $031
SEI $781
TAB $5B1
TAX $AA1
TAY $A81
TAZ $4B1
TBA $7B1
TSX $BA1
TSY $0B1
TXA $8A1
TXS $9A1
TYA $981
TYS $2B1
TZA $6B1

AccumulatorA

This form of addressing is represented with a one byte instruction, implying an operation on the accumulator.

Bytes: 1

InstructionOpcodeNo. Cycles
ASL A$0A1
ASR A$431
DEC A$3A1
INC A$1A1
LSR A$4A1
NEG A$421
ROL A$2A1
ROR A$6A1

Immediate#$nn

In immediate addressing, the operand is contained in the second byte of the instruction, with no further memory addressing required.

Bytes: 2

InstructionOpcodeNo. Cycles
ADC #$nn$692
AND #$nn$292
BIT #$nn$892
CMP #$nn$C92
CPX #$nn$E02
CPY #$nn$C02
CPZ #$nn$C22
EOR #$nn$492
LDA #$nn$A92
LDX #$nn$A22
LDY #$nn$A02
LDZ #$nn$A32
ORA #$nn$092
RTN #$nn$622
SBC #$nn$E92

Immediate (word)#$nnnn

The data used in the operation is taken from the bytes immediately following the opcode in the 3-byte instruction.

Bytes: 3

InstructionOpcodeNo. Cycles
PHW #$nnnn$F43

Absolute$nnnn

In absolute addressing, the second byte of the instruction specifies the eight low order bits of the effective address while the third byte specifies the eight high order bits. Thus, the absolute addressing mode allows access to the entire 65 K bytes of addressable memory.

Bytes: 3

InstructionOpcodeNo. Cycles
ADC $nnnn$6D3
AND $nnnn$2D3
ASL $nnnn$0E3
ASW $nnnn$CB3
BIT $nnnn$2C3
CMP $nnnn$CD3
CPX $nnnn$EC3
CPY $nnnn$CC3
CPZ $nnnn$DC3
DEC $nnnn$CE3
EOR $nnnn$4D3
INC $nnnn$EE3
JMP $nnnn$4C3
JSR $nnnn$203
LDA $nnnn$AD3
LDX $nnnn$AE3
LDY $nnnn$AC3
LDZ $nnnn$AB3
LSR $nnnn$4E3
ORA $nnnn$0D3
PHW $nnnn$FC3
ROL $nnnn$2E3
ROR $nnnn$6E3
ROW $nnnn$EB3
SBC $nnnn$ED3
STA $nnnn$8D3
STX $nnnn$8E3
STY $nnnn$8C3
STZ $nnnn$9C3
TRB $nnnn$1C3
TSB $nnnn$0C3

X-Indexed Absolute$nnnn,X

This form of addressing is used in conjunction with the X index register. The effective address is formed by adding the contents of X to the address contained in the second and third bytes of the instruction. This mode allows the index register to contain the index or count value and the instruction to contain the base address. This type of indexing allows any location referencing and the index to modify multiple fields resulting in reduced coding and execution time.

Bytes: 3

InstructionOpcodeNo. Cycles
ADC $nnnn,X$7D3
AND $nnnn,X$3D3
ASL $nnnn,X$1E3
BIT $nnnn,X$3C3
CMP $nnnn,X$DD3
DEC $nnnn,X$DE3
EOR $nnnn,X$5D3
INC $nnnn,X$FE3
LDA $nnnn,X$BD3
LDY $nnnn,X$BC3
LDZ $nnnn,X$BB3
LSR $nnnn,X$5E3
ORA $nnnn,X$1D3
ROL $nnnn,X$3E3
ROR $nnnn,X$7E3
SBC $nnnn,X$FD3
STA $nnnn,X$9D3
STY $nnnn,X$8B3
STZ $nnnn,X$9E3

Y-Indexed Absolute$nnnn,Y

This form of addressing is used in conjunction with the Y index register. The effective address is formed by adding the contents of Y to the address contained in the second and third bytes of the instruction. This mode allows the index register to contain the index or count value and the instruction to contain the base address. This type of indexing allows any location referencing and the index to modify multiple fields resulting in reduced coding and execution time.

Bytes: 3

InstructionOpcodeNo. Cycles
ADC $nnnn,Y$793
AND $nnnn,Y$393
CMP $nnnn,Y$D93
EOR $nnnn,Y$593
LDA $nnnn,Y$B93
LDX $nnnn,Y$BE3
ORA $nnnn,Y$193
SBC $nnnn,Y$F93
STA $nnnn,Y$993
STX $nnnn,Y$9B3

Absolute Indirect($nnnn)

The second byte of the instruction contains the low order eight bits of a memory location. The high order eight bits of that memory location is contained in the third byte of the instruction. The contents of the fully specified memory location is the low order byte of the effective address. The next memory location contains the high order byte of the effective address which is loaded into the sixteen bits of the program counter.

Bytes: 3

InstructionOpcodeNo. Cycles
JMP ($nnnn)$6C3
JSR ($nnnn)$223

Absolute X-Indexed Indirect($nnnn,X)

With the Absolute Indexed Indirect addressing mode, the X Index Register is added to the second and third byes of the instruction to form an address to a pointer. This address mode is only used with the JMP instruction and the program Counter is loaded with the first and second bytes at this pointer.

Bytes: 3

InstructionOpcodeNo. Cycles
JMP ($nnnn,X)$7C3
JSR ($nnnn,X)$233

Base Page$nn

The second byte of the two-byte instruction contains the low-order address byte, and the B register contains the high-order address byte of the memory location to be used by the operation.

Bytes: 2

InstructionOpcodeNo. Cycles
ADC $nn$652
AND $nn$252
ASL $nn$062
ASR $nn$442
BIT $nn$242
CMP $nn$C52
CPX $nn$E42
CPY $nn$C42
CPZ $nn$D42
DEC $nn$C62
DEW $nn$C32
EOR $nn$452
INC $nn$E62
INW $nn$E32
LDA $nn$A52
LDX $nn$A62
LDY $nn$A42
LSR $nn$462
ORA $nn$052
RMB0 $nn$072
RMB1 $nn$172
RMB2 $nn$272
RMB3 $nn$372
RMB4 $nn$472
RMB5 $nn$572
RMB6 $nn$672
RMB7 $nn$772
ROL $nn$262
ROR $nn$662
SBC $nn$E52
SMB0 $nn$872
SMB1 $nn$972
SMB2 $nn$A72
SMB3 $nn$B72
SMB4 $nn$C72
SMB5 $nn$D72
SMB6 $nn$E72
SMB7 $nn$F72
STA $nn$852
STX $nn$862
STY $nn$842
STZ $nn$642
TRB $nn$142
TSB $nn$042

X-Indexed Base Page$nn,X

The second byte of the two-byte instruction is added to the X index register to form the low-order address byte, and the B register contains the high-order address byte of the memory location to be used by the operation.

Bytes: 2

InstructionOpcodeNo. Cycles
ADC $nn,X$752
AND $nn,X$352
ASL $nn,X$162
ASR $nn,X$542
BIT $nn,X$342
CMP $nn,X$D52
DEC $nn,X$D62
EOR $nn,X$552
INC $nn,X$F62
LDA $nn,X$B52
LDY $nn,X$B42
LSR $nn,X$562
ORA $nn,X$152
ROL $nn,X$362
ROR $nn,X$762
SBC $nn,X$F52
STA $nn,X$952
STY $nn,X$942
STZ $nn,X$742

Y-Indexed Base Page$nn,Y

The second byte of the two-byte instruction is added to the Y index register to form the low-order address byte, and the B register contains the high-order address byte of the memory location to be used by the operation.

Bytes: 2

InstructionOpcodeNo. Cycles
LDX $nn,Y$B62
STX $nn,Y$962

X-Indexed Base Page Indirect($nn,X)

The second byte of the two-byte instruction is added to the contents of the X register to form the low-order address byte, and the contents of the B register contains the high-order address byte, of two memory locations that contain the low-order and high-order address of the memory location to be used by the operation.

Bytes: 2

InstructionOpcodeNo. Cycles
ADC ($nn,X)$612
AND ($nn,X)$212
CMP ($nn,X)$C12
EOR ($nn,X)$412
LDA ($nn,X)$A12
ORA ($nn,X)$012
SBC ($nn,X)$E12
STA ($nn,X)$812

Base Page Indirect Y-Indexed($nn),Y

The second and third bytes of the three-byte instruction are added to the unsigned contents of the X index register to form the low-order and high-order address bytes, respectively, of two memory locations containing the low-order and high-order JMP or JSR address bytes.

Bytes: 2

InstructionOpcodeNo. Cycles
ADC ($nn),Y$712
AND ($nn),Y$312
CMP ($nn),Y$D12
EOR ($nn),Y$512
LDA ($nn),Y$B12
ORA ($nn),Y$112
SBC ($nn),Y$F12
STA ($nn),Y$912

Indirect Z-Indexed($nn),Z

The second byte of the two-byte instruction contains the low-order byte, and the B register contains the high-order address byte of two memory locations whose contents are added to the unsigned Z index register to form the address of the memory location to be used by the operation.

Bytes: 2

InstructionOpcodeNo. Cycles
ADC ($nn),Z$722
AND ($nn),Z$322
CMP ($nn),Z$D22
EOR ($nn),Z$522
LDA ($nn),Z$B22
ORA ($nn),Z$122
SBC ($nn),Z$F22
STA ($nn),Z$922

Relative$nnnn

Relative addressing is used only with branch instructions and establishes a destination for the conditional branch.

The second byte of-the instruction becomes the operand which is an “Offset" added to the contents of the lower eight bits of the program counter when the counter is set at the next instruction. The range of the offset is —128 to +127 bytes from the next instruction.

Bytes: 2

InstructionOpcodeNo. Cycles
BCC $nnnn$902
BCS $nnnn$B02
BEQ $nnnn$F02
BMI $nnnn$302
BNE $nnnn$D02
BPL $nnnn$102
BRA $nnnn$802
BVC $nnnn$502
BVS $nnnn$702

Relative (word)$nnnn

The second and third bytes of the three-byte branch instruction are added to the low-order and high-order program counter bytes, respectively. (The program counter now contains the opcode address plus two). If the condition of the branch is true, the sum is stored back into the program counter.

Bytes: 3

InstructionOpcodeNo. Cycles
BCC $nnnn$933
BCS $nnnn$B33
BEQ $nnnn$F33
BMI $nnnn$333
BNE $nnnn$D33
BPL $nnnn$133
BRA $nnnn$833
BSR $nnnn$633
BVC $nnnn$533
BVS $nnnn$733

Base Page, Relative$nn,$nnnn

This mode bit tests the base page location specified for bit set/reset per the mask and performs a conditional relative branch based on the results of the bit test.

Bytes: 3

InstructionOpcodeNo. Cycles
BBR0 $nn,$nnnn$0F3
BBR1 $nn,$nnnn$1F3
BBR2 $nn,$nnnn$2F3
BBR3 $nn,$nnnn$3F3
BBR4 $nn,$nnnn$4F3
BBR5 $nn,$nnnn$5F3
BBR6 $nn,$nnnn$6F3
BBR7 $nn,$nnnn$7F3
BBS0 $nn,$nnnn$8F3
BBS1 $nn,$nnnn$9F3
BBS2 $nn,$nnnn$AF3
BBS3 $nn,$nnnn$BF3
BBS4 $nn,$nnnn$CF3
BBS5 $nn,$nnnn$DF3
BBS6 $nn,$nnnn$EF3
BBS7 $nn,$nnnn$FF3

Stack Relative Indirect Y-Indexed($nnnn,SP),Y

The second byte of the two-byte instruction contains an unsigned offset value, d, which is added to the stack pointer (word) to form the address of two memory locations whose contents are added to the unsigned Y register to form the address of the memory location to be used by the operation.

Bytes: 2

InstructionOpcodeNo. Cycles
LDA ($nnnn,SP),Y$E22
STA ($nnnn,SP),Y$822


Load/Store
Transfer
Stack
Shift
Logic
Arithmetic
Arithmetic: Inc/Dec
Control Flow
Control Flow: Branch
Flags
KIL
NOP