6502 Addressing modes
Immediate | #nn |
---|---|
Absolute | nnnn |
Zero Page | nn |
Implied | |
Indirect Absolute | (nnnn) |
Absolute Indexed,X | nnnn,X |
Absolute Indexed,Y | nnnn,Y |
Zero Page Indexed,X | nn,X |
Zero Page Indexed,Y | nn,Y |
Indexed Indirect (a.k.a. Indirect X) | (nn,X) |
Indirect Indexed (a.k.a. Indirect Y) | (nn),Y |
Relative | +nnnn |
Accumulator | A |
- nnnn = 16 bit unsigned value
- nn = 8 bis unsigned value
- +nn = 8 bits signed (two’s complement) value in range -128 to +127
Flags
flag | | N | V |___| B | D | I | Z | C | | |
---|---|---|
N | Negative | |
V | Overflow | |
B | BRK command | |
D | Decimal mode on | |
I | IRQ disable | |
Z | Zero | |
C | Carry |
6502 Instructions
There are 56 instructions in 6502 (a little more on 65C02)
- Load
- Increment and Decrement
- Flag manipulation
- Stack
- Transfer
- Logical and Shift
- Branch
- Test and Compare
- Arithmetic
- Call
- Others
Load
INST | DESC |
---|---|
LDA | LoaD the Accumulator |
LDX | LoaD the X register |
LDY | LoaD the Y register |
STA | STore the Accumulator |
STX | STore the X register |
STY | STore the Y register |
STZ | STore Zero into memory (65C02 only) |
Increment and Decrement
INST | DESC |
---|---|
INC | INCrement memory by one |
INX | INCrement X by one |
INY | INCrement Y by one |
DEC | DECrement memory by one |
DEX | DEcrement X by one |
DEY | DEcrement Y by one |
Flag manipulation
INST | DESC |
---|---|
CLC | CLear Carry flag |
CLD | CLear Decimal mode |
CLI | CLear Interrupt disable |
CLV | CLear oVerflow flag |
SEC | SEt Carry |
SED | SEt Decimal mode |
SEI | SEt Interrupt disable |
SEV | DO NOT EXIST |
Stack
INST | DESC |
---|---|
TSX | Transfer Stack pointer to X |
TXS | Transfer X to Stack pointer |
PHA | PusH A on stack |
PHP | PusH Processor status flags on stack |
PLA | PulL A from stack |
PLP | PulL Processor status flags from stack |
PHX | PusH X on stack (65C02 only) |
PLX | PulL X from stack (65C02 only) |
PHY | PusH Y on stack (65C02 only) |
PLY | PulL Y from stack (65C02 only) |
Transfer
INST | DESC |
---|---|
TAX | Transfer A to X |
TAY | Transfer A to Y |
TXA | Transfer X to A |
TYA | Transfer Y to A |
TXY or TYX | DO NOT EXIST |
Logical and Shift
INST | DESC |
---|---|
AND | AND memory with A |
ORA | OR memory with A |
EOR | Exclusive-OR (XOR) memory with A |
ASL | Accumulator Shift Left |
LSR | Logical Shift Right |
ROL | ROtate Left |
ROR | ROtate Right |
Branch
INST | DESC | Flag |
---|---|---|
BCC | Branch on Carry Clear | C == 0 |
BCS | Branch on Carry Set | C == 1 |
BEQ | Branch on EQual to zero | Z == 1 |
BNE | Branch on Not Equal to zero | Z == 0 |
BMI | Branch on MInus | N == 1 |
BPL | Branch on PLus | N == 0 |
BVS | Branch on oVerflow Set | V == 1 |
BVC | Branch on oVerflow Clear | V == 0 |
JMP | JuMP to another location | |
BRA | Branch Relative Always (65C02 only) | |
BBR | Branch if specified Bit is Reset ( some 65C02 only) | |
BBS | Branch if specified Bit is Set ( some 65C02 only) |
Test and Compare
INST | DESC |
---|---|
CMP | CoMPare memory and A |
CPX | ComPare memory and X |
CPY | ComPare memory and Y |
BIT | BITs test |
TRB | Test and Reset Bits with A (65C02 only) |
TSB | Test and Set Bits with A (65C02 only) |
RMB | Reset specified Memory Bit ( some 65C02 only) |
SMB | Set specified Memory Bit ( some 65C02 only) |
Arithmetic
INST | DESC |
---|---|
ADC | ADd to accumulator with Carry |
SBC | SuBtract from accumulator with Carry |
Call
INST | DESC |
---|---|
JSR | Jump to SubRoutine |
RTS | ReTurn from Subroutine |
RTI | ReTurn from Interrupt |
Others
INST | DESC |
---|---|
NOP | No OPeration |
BRK | BReak |
STP | ( some 65C02 only) |
WAI | ( some 65C02 only) |