A 6502 emulator written in C.
Name | Mnemonic |
---|---|
Absolute | $nnnn |
Absolute Indirect | ($nnnn) |
Accumulator | A |
Immediate | #nn (canonically #$nn) |
Implied | |
Relative | $nnnn (only for branch instructions) |
X-Indexed Absolute | $nnnn,X |
X-Indexed Absolute Indirect | ($nnnn,X) |
X-Indexed Zero Page | $nn,X |
X-Indexed Zero Page Indirect | ($nn,X) |
Y-Indexed Absolute | $nnnn,Y |
Y-Indexed Zero Page | $nn,Y |
Zero Page | $nn |
Zero Page Indirect | ($nn) |
Zero Page Indirect Y-Indexed | ($nn),Y |
Zero Page Relative | $nn,$nnnn (only for branch instructions) |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
| x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
0x | BRK | ORA | | | | ORA | ASL | | PHP | ORA | ASL | | | ORA | ASL | |
| | ($nn,X) | | | | $nn | $nn | | | #nn | A | | | $nnnn | $nnnn | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
1x | BPL | ORA | | | | ORA | ASL | | CLC | ORA | | | | ORA | ASL | |
| $nnnn | ($nn),Y | | | | $nn,X | $nn,X | | | $nnnn,Y | | | | $nnnn,X | $nnnn,X | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
2x | JSR | AND | | | BIT | AND | ROL | | PLP | AND | ROL | | BIT | AND | ROL | |
| $nnnn | ($nn,X) | | | $nn | $nn | $nn | | | #nn | A | | $nnnn | $nnnn | $nnnn | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
3x | BMI | AND | | | | AND | ROL | | SEC | AND | | | | AND | ROL | |
| $nnnn | ($nn),Y | | | | $nn,X | $nn,X | | | $nnnn,Y | | | | $nnnn,X | $nnnn,X | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
4x | RTI | EOR | | | | EOR | LSR | | PHA | EOR | LSR | | JMP | EOR | LSR | |
| | ($nn,X) | | | | $nn | $nn | | | #nn | A | | $nnnn | $nnnn | $nnnn | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
5x | BVC | EOR | | | | EOR | LSR | | CLI | EOR | | | | EOR | LSR | |
| $nnnn | ($nn),Y | | | | $nn,X | $nn,X | | | $nnnn,Y | | | | $nnnn,X | $nnnn,X | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
6x | RTS | ADC | | | | ADC | ROR | | PLA | ADC | ROR | | JMP | ADC | ROR | |
| | ($nn,X) | | | | $nn | $nn | | | #nn | A | | ($nnnn) | $nnnn | $nnnn | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
7x | BVS | ADC | | | | ADC | ROR | | SEI | ADC | | | | ADC | ROR | |
| $nnnn | ($nn),Y | | | | $nn,X | $nn,X | | | $nnnn,Y | | | | $nnnn,X | $nnnn,X | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
8x | | STA | | | STY | STA | STX | | DEY | | TXA | | STY | STA | STX | |
| | ($nn,X) | | | $nn | $nn | $nn | | | | | | $nnnn | $nnnn | $nnnn | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
9x | BCC | STA | | | STY | STA | STX | | TYA | STA | TXS | | | STA | | |
| $nnnn | ($nn),Y | | | $nn,X | $nn,X | $nn,Y | | | $nnnn,Y | | | | $nnnn,X | | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
Ax | LDY | LDA | LDX | | LDY | LDA | LDX | | TAY | LDA | TAX | | LDY | LDA | LDX | |
| #nn | ($nn,X) | #nn | | $nn | $nn | $nn | | | #nn | | | $nnnn | $nnnn | $nnnn | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
Bx | BCS | LDA | | | LDY | LDA | LDX | | CLV | LDA | TSX | | LDY | LDA | LDX | |
| $nnnn | ($nn),Y | | | $nn,X | $nn,X | $nn,Y | | | $nnnn,Y | | | $nnnn,X | $nnnn,X | $nnnn,Y | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
Cx | CPY | CMP | | | CPY | CMP | DEC | | INY | CMP | DEX | | CPY | CMP | DEC | |
| #nn | ($nn,X) | | | $nn | $nn | $nn | | | #nn | | | $nnnn | $nnnn | $nnnn | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
Dx | BNE | CMP | | | | CMP | DEC | | CLD | CMP | | | | CMP | DEC | |
| $nnnn | ($nn),Y | | | | $nn,X | $nn,X | | | $nnnn,Y | | | | $nnnn,X | $nnnn,X | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
Ex | CPX | SBC | | | CPX | SBC | INC | | INX | SBC | NOP | | CPX | SBC | INC | |
| #nn | ($nn,X) | | | $nn | $nn | $nn | | | #nn | | | $nnnn | $nnnn | $nnnn | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
Fx | BEQ | SBC | | | | SBC | INC | | SED | SBC | | | | SBC | INC | |
| $nnnn | ($nn),Y | | | | $nn,X | $nn,X | | | $nnnn,Y | | | | $nnnn,X | $nnnn,X | |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
| x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
0x | BRK | ORA | HLT | SLO | NOP | ORA | ASL | SLO | PHP | ORA | ASL | ANC | NOP | ORA | ASL | SLO |
| | ($nn,X) | | ($nn,X) | $nn | $nn | $nn | $nn | | #nn | A | #nn | $nnnn | $nnnn | $nnnn | $nnnn |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
1x | BPL | ORA | HLT | SLO | NOP | ORA | ASL | SLO | CLC | ORA | NOP | SLO | NOP | ORA | ASL | SLO |
| $nnnn | ($nn),Y | | ($nn),Y | $nn,X | $nn,X | $nn,X | $nn,X | | $nnnn,Y | | $nnnn,Y | $nnnn,X | $nnnn,X | $nnnn,X | $nnnn,X |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
2x | JSR | AND | HLT | RLA | BIT | AND | ROL | RLA | PLP | AND | ROL | ANC | BIT | AND | ROL | RLA |
| $nnnn | ($nn,X) | | ($nn,X) | $nn | $nn | $nn | $nn | | #nn | A | #nn | $nnnn | $nnnn | $nnnn | $nnnn |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
3x | BMI | AND | HLT | RLA | NOP | AND | ROL | RLA | SEC | AND | NOP | RLA | NOP | AND | ROL | RLA |
| $nnnn | ($nn),Y | | ($nn),Y | $nn,X | $nn,X | $nn,X | $nn,X | | $nnnn,Y | | $nnnn,Y | $nnnn,X | $nnnn,X | $nnnn,X | $nnnn,X |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
4x | RTI | EOR | HLT | SRE | NOP | EOR | LSR | SRE | PHA | EOR | LSR | ASR | JMP | EOR | LSR | SRE |
| | ($nn,X) | | ($nn,X) | $nn | $nn | $nn | $nn | | #nn | A | #nn | $nnnn | $nnnn | $nnnn | $nnnn |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
5x | BVC | EOR | HLT | SRE | NOP | EOR | LSR | SRE | CLI | EOR | NOP | SRE | NOP | EOR | LSR | SRE |
| $nnnn | ($nn),Y | | ($nn),Y | $nn,X | $nn,X | $nn,X | $nn,X | | $nnnn,Y | | $nnnn,Y | $nnnn,X | $nnnn,X | $nnnn,X | $nnnn,X |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
6x | RTS | ADC | HLT | RRA | NOP | ADC | ROR | RRA | PLA | ADC | ROR | ARR | JMP | ADC | ROR | RRA |
| | ($nn,X) | | ($nn,X) | $nn | $nn | $nn | $nn | | #nn | A | #nn | ($nnnn) | $nnnn | $nnnn | $nnnn |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
7x | BVS | ADC | HLT | RRA | NOP | ADC | ROR | RRA | SEI | ADC | NOP | RRA | NOP | ADC | ROR | RRA |
| $nnnn | ($nn),Y | | ($nn),Y | $nn,X | $nn,X | $nn,X | $nn,X | | $nnnn,Y | | $nnnn,Y | $nnnn,X | $nnnn,X | $nnnn,X | $nnnn,X |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
8x | NOP | STA | NOP | SAX | STY | STA | STX | SAX | DEY | NOP | TXA | XXA | STY | STA | STX | SAX |
| #nn | ($nn,X) | #nn | ($nn,X) | $nn | $nn | $nn | $nn | | #nn | | #nn | $nnnn | $nnnn | $nnnn | $nnnn |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
9x | BCC | STA | HLT | SHA | STY | STA | STX | SAX | TYA | STA | TXS | SHS | SHY | STA | SHX | SHA |
| $nnnn | ($nn),Y | | ($nn),Y | $nn,X | $nn,X | $nn,Y | $nn,Y | | $nnnn,Y | | $nnnn,Y | $nnnn,X | $nnnn,X | $nnnn,Y | $nnnn,Y |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
Ax | LDY | LDA | LDX | LAX | LDY | LDA | LDX | LAX | TAY | LDA | TAX | LXA | LDY | LDA | LDX | LAX |
| #nn | ($nn,X) | #nn | ($nn,X) | $nn | $nn | $nn | $nn | | #nn | | #nn | $nnnn | $nnnn | $nnnn | $nnnn |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
Bx | BCS | LDA | HLT | LAX | LDY | LDA | LDX | LAX | CLV | LDA | TSX | LAS | LDY | LDA | LDX | LAX |
| $nnnn | ($nn),Y | | ($nn),Y | $nn,X | $nn,X | $nn,Y | $nn,Y | | $nnnn,Y | | $nnnn,Y | $nnnn,X | $nnnn,X | $nnnn,Y | $nnnn,Y |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
Cx | CPY | CMP | NOP | DCP | CPY | CMP | DEC | DCP | INY | CMP | DEX | SBX | CPY | CMP | DEC | DCP |
| #nn | ($nn,X) | #nn | ($nn,X) | $nn | $nn | $nn | $nn | | #nn | | #nn | $nnnn | $nnnn | $nnnn | $nnnn |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
Dx | BNE | CMP | HLT | DCP | NOP | CMP | DEC | DCP | CLD | CMP | NOP | DCP | NOP | CMP | DEC | DCP |
| $nnnn | ($nn),Y | | ($nn),Y | $nn,X | $nn,X | $nn,X | $nn,X | | $nnnn,Y | | $nnnn,Y | $nnnn,X | $nnnn,X | $nnnn,X | $nnnn,X |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
Ex | CPX | SBC | NOP | ISC | CPX | SBC | INC | ISC | INX | SBC | NOP | SBC | CPX | SBC | INC | ISC |
| #nn | ($nn,X) | #nn | ($nn,X) | $nn | $nn | $nn | $nn | | #nn | | #nn | $nnnn | $nnnn | $nnnn | $nnnn |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
Fx | BEQ | SBC | HLT | ISC | NOP | SBC | INC | ISC | SED | SBC | NOP | ISC | NOP | SBC | INC | ISC |
| $nnnn | ($nn),Y | | ($nn),Y | $nn,X | $nn,X | $nn,X | $nn,X | | $nnnn,Y | | $nnnn,Y | $nnnn,X | $nnnn,X | $nnnn,X | $nnnn,X |
----+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
| x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
0x | BRK | ORA | NOP | NOP | TSB | ORA | ASL | RMB0 | PHP | ORA | ASL | NOP | TSB | ORA | ASL | BBR0 |
| | ($nn,X) | #nn | | $nn | $nn | $nn | $nn | | #nn | A | | $nnnn | $nnnn | $nnnn | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
1x | BPL | ORA | ORA | NOP | TRB | ORA | ASL | RMB1 | CLC | ORA | INC | NOP | TRB | ORA | ASL | BBR1 |
| $nnnn | ($nn),Y | ($nn) | | $nn | $nn,X | $nn,X | $nn | | $nnnn,Y | A | | $nnnn | $nnnn,X | $nnnn,X | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
2x | JSR | AND | NOP | NOP | BIT | AND | ROL | RMB2 | PLP | AND | ROL | NOP | BIT | AND | ROL | BBR2 |
| $nnnn | ($nn,X) | #nn | | $nn | $nn | $nn | $nn | | #nn | A | | $nnnn | $nnnn | $nnnn | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
3x | BMI | AND | AND | NOP | BIT | AND | ROL | RMB3 | SEC | AND | DEC | NOP | BIT | AND | ROL | BBR3 |
| $nnnn | ($nn),Y | ($nn) | | $nn,X | $nn,X | $nn,X | $nn | | $nnnn,Y | A | | $nnnn,X | $nnnn,X | $nnnn,X | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
4x | RTI | EOR | NOP | NOP | NOP | EOR | LSR | RMB4 | PHA | EOR | LSR | NOP | JMP | EOR | LSR | BBR4 |
| | ($nn,X) | #nn | | $nn | $nn | $nn | $nn | | #nn | A | | $nnnn | $nnnn | $nnnn | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
5x | BVC | EOR | EOR | NOP | NOP | EOR | LSR | RMB5 | CLI | EOR | PHY | NOP | NOP | EOR | LSR | BBR5 |
| $nnnn | ($nn),Y | ($nn) | | $nn,X | $nn,X | $nn,X | $nn | | $nnnn,Y | | | $nnnn,X | $nnnn,X | $nnnn,X | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
6x | RTS | ADC | NOP | NOP | STZ | ADC | ROR | RMB6 | PLA | ADC | ROR | NOP | JMP | ADC | ROR | BBR6 |
| | ($nn,X) | #nn | | $nn | $nn | $nn | $nn | | #nn | A | | ($nnnn) | $nnnn | $nnnn | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
7x | BVS | ADC | ADC | NOP | STZ | ADC | ROR | RMB7 | SEI | ADC | PLY | NOP | JMP | ADC | ROR | BBR7 |
| $nnnn | ($nn),Y | ($nn) | | $nn,X | $nn,X | $nn,X | $nn | | $nnnn,Y | | | ($nnnn,X) | $nnnn,X | $nnnn,X | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
8x | BRA | STA | NOP | NOP | STY | STA | STX | SMB0 | DEY | BIT | TXA | NOP | STY | STA | STX | BBS0 |
| $nnnn | ($nn,X) | #nn | | $nn | $nn | $nn | $nn | | #nn | | | $nnnn | $nnnn | $nnnn | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
9x | BCC | STA | STA | NOP | STY | STA | STX | SMB1 | TYA | STA | TXS | NOP | STZ | STA | STZ | BBS1 |
| $nnnn | ($nn),Y | ($nn) | | $nn,X | $nn,X | $nn,Y | $nn | | $nnnn,Y | | | $nnnn | $nnnn,X | $nnnn,X | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
Ax | LDY | LDA | LDX | NOP | LDY | LDA | LDX | SMB2 | TAY | LDA | TAX | NOP | LDY | LDA | LDX | BBS2 |
| #nn | ($nn,X) | #nn | | $nn | $nn | $nn | $nn | | #nn | | | $nnnn | $nnnn | $nnnn | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
Bx | BCS | LDA | LDA | NOP | LDY | LDA | LDX | SMB3 | CLV | LDA | TSX | NOP | LDY | LDA | LDX | BBS3 |
| $nnnn | ($nn),Y | ($nn) | | $nn,X | $nn,X | $nn,Y | $nn | | $nnnn,Y | | | $nnnn,X | $nnnn,X | $nnnn,Y | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
Cx | CPY | CMP | NOP | NOP | CPY | CMP | DEC | SMB4 | INY | CMP | DEX | WAI | CPY | CMP | DEC | BBS4 |
| #nn | ($nn,X) | #nn | | $nn | $nn | $nn | $nn | | #nn | | | $nnnn | $nnnn | $nnnn | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
Dx | BNE | CMP | CMP | NOP | NOP | CMP | DEC | SMB5 | CLD | CMP | PHX | STP | NOP | CMP | DEC | BBS5 |
| $nnnn | ($nn),Y | ($nn) | | $nn,X | $nn,X | $nn,X | $nn | | $nnnn,Y | | | $nnnn,X | $nnnn,X | $nnnn,X | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
Ex | CPX | SBC | NOP | NOP | CPX | SBC | INC | SMB6 | INX | SBC | NOP | NOP | CPX | SBC | INC | BBS6 |
| #nn | ($nn,X) | #nn | | $nn | $nn | $nn | $nn | | #nn | | | $nnnn | $nnnn | $nnnn | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
Fx | BEQ | SBC | SBC | NOP | NOP | SBC | INC | SMB7 | SED | SBC | PLX | NOP | NOP | SBC | INC | BBS7 |
| $nnnn | ($nn),Y | ($nn) | | $nn,X | $nn,X | $nn,X | $nn | | $nnnn,Y | | | $nnnn,X | $nnnn,X | $nnnn,X | $nn,$nnnn |
----+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+