Changes

MOS 6502

309 bytes added, 11 May
/* Oddities */
<br>
== Registers Register File ==
{| class="wikitable" style="white-space: nowrap;"
|}
SeeThe 6502 also has internal latches and buffers used for address handling and instruction execution. For example: [https*ABL/ABH:Address Bus Low//www.rightoHigh, latches for the address bus.com/2012/12*AI/BI: Input Registers for the-6502-overflow-flag-explainedALU.*IR: Instruction Register, holds the fetched instruction opcode byte while the CPU decodes and executes it.html The 6502 overflow flag explained mathematically]
<br>
The Zero Page on the 6502 is a special area of memory from addresses $0000 to $00FF that act like pseudo registers. The 6502 provides optimized instructions that operate more efficiently when using addresses within the Zero Page.
Fun fact: the TMS9900 CPU took this further, and had by having no onboard registers (other than , except PC & status register). Everything was in RAM.
<br>
{| class="wikitable" style="white-space: nowrap;"
|-
! rowspan=2|Mnemonic !! colspan=13|Addressing Modes !! colspan=76|Flags !! rowspan=2|Operation !! rowspan=2|Description
|-
! ''No arg'' !! A !! #$nn !! $nnnn !! $nnnn,X !! $nnnn,Y !! ($nnnn) !! $nn !! $nn,X !! $nn,Y !! ($nn,X) !! ($nn),Y !! rel !! N !! V !! B !! D !! I !! Z !! C
|-
| ADC BIT || || || 69 (2) || 6D 2C (4) || 7D (4+p) || 79 (4+p) || || 65 24 (3) || 75 (4) || || 61 (6) || 71 (5+p) || || N || V || - || - || - || Z || C - || A + M + CF , M<sub>7</sub> ANF, CF M<sub>6</sub> → VF || ADd with Carrytest BITs
|-
| AND || || || 29 (2) || 2D (4) || 3D (4+p) || 39 (4+p) || || 25 (3) || 35 (4) || || 21 (6) || 31 (5+p) || || N || - || - || - || - || Z || - || A ∧ M → A || bitwise AND with accumulator
|-
| ASL EOR || || 0A || 49 (2) || 4D (4) || 0E 5D (64+p) || 1E 59 (74+p) || || || 06 45 (53) || 16 55 (64) || || 41 (6) || 51 (5+p) || || N || - || - || - || - || Z || C - || CF ← /M<sub>7</sub>...A ⊻ M<sub>0</sub>/ ← 0 → A || Arithmetic Shift Leftbitwise Exclusive OR
|-
| CMP ORA || || || C9 09 (2) || CD 0D (4) || DD 1D (4+p) || D9 19 (4+p) || || C5 05 (3) || D5 15 (4) || || C1 01 (6) || D1 11 (5+p) || || N || - || - || - || - || Z || C - || A - M → A || CoMPare accumulatorbitwise OR with Accumulator
|-
| CPX ADC || || || E0 69 (2) || EC 6D (4) || 7D (4+p) || 79 (4+p) || || E4 65 (3) || 75 (4) || || 61 (6) || 71 (5+p) || || N || - || - V || - || - || Z || C || X - A + M + CF → A, CF || ComPare X registerADd with Carry
|-
| CPY SBC || || || C0 E9 (2) || CC ED (4) || FD (4+p) || F9 (4+p) || || C4 E5 (3) || F5 (4) || || E1 (6) || F1 (5+p) || || N || - || - V || - || - || Z || C || Y A - M - (1 - CF) → A || ComPare Y registerSuBtract with Carry
|-
| DEC CMP || || || C9 (2) || CE CD (64) || DE DD (74+p) || D9 (4+p) || || C6 C5 (53) || D6 D5 (64) || || C1 (6) || D1 (5+p) || || N || - || - || - || - || Z || - C || M A - 1 → M || DECrement memoryCoMPare accumulator
|-
| DEX CPX || CA (2) || || E0 (2) || EC (4) || || || || E4 (3) || || || || || || N || - || - || - || - || Z || - C || X - 1 → X M || DEcrement ComPare Xregister
|-
| DEY CPY || 88 (2) || || C0 (2) || CC (4) || || || || C4 (3) || || || || || || N || - || - || - || - || Z || - C || Y - 1 → Y M || DEcrement ComPare Yregister
|-
| EOR ASL || || || 49 0A (2) || 4D (4) || 5D 0E (4+p6) || 59 1E (4+p7) || || 45 || 06 (35) || 55 16 (46) || || 41 (6) || 51 (5+p) || || N || - || - || - || - || Z || - C || A ⊻ CF ← /M<sub>7</sub>...M → A <sub>0</sub>/ ← 0 || bitwise Exclusive ORArithmetic Shift Left
|-
| INC LSR || || 4A (2) || || EE 4E (6) || FE 5E (7) || || || E6 46 (5) || F6 56 (6) || || || || || N || - 0 || - || - || - || Z || - C || M + 1 0 /M <sub>7</sub>...M<sub>0</sub>/ → CF || INCrement memoryLogical Shift Right
|-
| INX ROL || E8 || 2A (2) || || 2E (6) || 3E (7) || || || 26 (5) || || 36 (6) || || || || || N || - || - || - || - || Z || - C || X + 1 → X CF ← /M<sub>7</sub>...M<sub>0</sub>/ ← CF || INcrement XROtate Left
|-
| INY ROR || C8 || 6A (2) || || 6E (6) || 7E (7) || || || 66 (5) || || 76 (6) || || || || || N || - || - || - || - || Z || - C || Y + 1 CF → /M<sub>7</sub>...M<sub>0</sub>/ Y CF || INcrement YROtate Right
|-
| LSR DEC || || 4A (2) || || 4E CE (6) || 5E DE (7) || || || 46 C6 (5) || 56 D6 (6) || || || || || 0 || - N || - || - || - || Z || C - || 0 → /M<sub>7</sub>...M<sub>0</sub>/ - 1 CF M || Logical Shift RightDECrement memory
|-
| ORA INC || || || 09 (2) || 0D EE (46) || 1D FE (4+p7) || 19 (4+p) || || 05 E6 (35) || 15 F6 (46) || || 01 (6) || 11 (5+p) || || N || - || - || - || - || Z || - || A ∨ M + 1 A M || bitwise OR with AccumulatorINCrement memory
|-
| ROL DEX || || 2A CA (2) || || 2E (6) || 3E (7) || || || 26 (5) || 36 (6) || || || || || N || - N || - || - || - || Z || C - || CF ← /M<sub>7</sub>...M<sub>0</sub>/ ← CF X - 1 → X || ROtate LeftDEcrement X
|-
| ROR DEY || || 6A 88 (2) || || 6E (6) || 7E (7) || || || 66 (5) || 76 (6) || || || || || N || - N || - || - || - || Z || C - || CF → /M<sub>7</sub>...M<sub>0</sub>/ Y - 1 CF Y || ROtate RightDEcrement Y
|-
| SBC INX || E8 (2) || || E9 (2) || ED (4) || FD (4+p) || F9 (4|| || || || || || || || N || - || - || - || Z || - || X +p) 1 → X || INcrement X|-| E5 (3) INY || F5 C8 (42) || || E1 (6) || F1 (5+p) || || N || V || || || || || || || N || - || - || - || Z || C - || A - M - (Y + 1 - CF) A Y || SuBtract with CarryINcrement Y
|}
{| class="wikitable" style="white-space: nowrap;"
|-
! rowspan=2|Mnemonic !! colspan=12|Addressing Modes !! colspan=76|Flags !! rowspan=2|Operation !! rowspan=2|Description
|-
! ''No arg'' !! #$nn !! $nnnn !! $nnnn,X !! $nnnn,Y !! ($nnnn) !! $nn !! $nn,X !! $nn,Y !! ($nn,X) !! ($nn),Y !! rel !! N !! V !! B !! D !! I !! Z !! C
|-
| LDA || || A9 (2) || AD (4) || BD (4+p) || B9 (4+p) || || A5 (3) || B5 (4) || || A1 (6) || B1 (5+p) || || N || - || - || - || - || Z || - || M → A || LoaD Accumulator
|-
| LDX || || A2 (2) || AE (4) || || BE (4+p) || || A6 (3) || || B6 (4) || || || || N || - || - || - || - || Z || - || M → X || LoaD X register
|-
| LDY || || A0 (2) || AC (4) || BC (4+p) || || || A4 (3) || B4 (4) || || || || || N || - || - || - || - || Z || - || M → Y || LoaD Y register
|-
| PHA STA || 48 (3) || || 8D (4) || 9D (5) || 99 (5) || || 85 (3) || 95 (4) || || 81 (6) || 91 (6) || || - || - || - || - || - || - || - || A↓ A → M || PusH STore Accumulator
|-
| PHP STX || 08 (3) || || 8E (4) || || || || 86 (3) || || 96 (4) || || || || - || - || 1 || - || - || - || - || P↓ X → M || PusH Processor statusSTore X register
|-
| PLA STY || 68 (4) || || 8C (4) || || || || 84 (3) || 94 (4) || || || || || N - || - || - || - || - || Z || - || (S)↑ Y A M || PuLl AccumulatorSTore Y register
|-
| PLP TAX || 28 AA (42) || || || || || || || || || || || || N || V - || - || D || I - || Z || C - || (S)↑ A P X || PuLl Processor statusTransfer A to X
|-
| STA TXA || 8A (2) || || 8D (4) || 9D (5) || 99 (5) || || 85 (3) || 95 (4) || || 81 (6) || 91 (6) || || - N || - || - || - || - Z || - || - X → A || Transfer X to A → M || STore Accumulator
|-
| STX TAY || A8 (2) || || 8E (4) || || || || 86 (3) || || 96 (4) || || || || - N || - || - || - || - || - Z || - || X A M Y || STore X registerTransfer A to Y
|-
| STY TYA || 98 (2) || || 8C (4) || || || || 84 (3) || 94 (4) || || || || || - N || - || - || - || - || - Z || - || Y → M A || STore Transfer Y registerto A
|-
| TAX TSX || AA BA (2) || || || || || || || || || || || || N || - || - || - || - || Z || - || A S → X || Transfer A Stack pointer to X
|-
| TAY TXS || A8 9A (2) || || || || || || || || || || || || N - || - || - || - || - || Z || - || A X Y S || Transfer A X to YStack pointer
|-
| TSX PLP || BA 28 (24) || || || || || || || || || || || || N || - V || - D || - || - I || Z || - C || (S )↑ X P || Transfer Stack pointer to XPuLl Processor status
|-
| TXA PLA || 8A 68 (24) || || || || || || || || || || || || N || - || - || - || - || Z || - || X (S)↑ → A || Transfer X to APuLl Accumulator
|-
| TXS PHP || 9A 08 (23) || || || || || || || || || || || || - || - || - || - || - || - || - || X → S P↓ || Transfer X to Stack pointerPusH Processor status
|-
| TYA PHA || 98 48 (23) || || || || || || || || || || || || N - || - || - || - || - || Z || - || Y → A A↓ || Transfer Y to APusH Accumulator
|}
{| class="wikitable" style="white-space: nowrap;"
|-
! rowspan=2|Mnemonic !! colspan=12|Addressing Modes !! colspan=76|Flags !! rowspan=2|Operation !! rowspan=2|Description
|-
! ''No arg'' !! #$nn !! $nnnn !! $nnnn,X !! $nnnn,Y !! ($nnnn) !! $nn !! $nn,X !! $nn,Y !! ($nn,X) !! ($nn),Y !! rel !! N !! V !! B !! D !! I !! Z !! C 
|-
| BCC JMP || || || 4C (3) || || || 6C (5) || || || || || || 90 (2+t+p) || - || - || - || - || - || - || - || Branch on CF = 0 [PC + 1] → PCL, [PC + 2] → PCH || Branch on Carry ClearJuMP
|-
| BCS JSR || || || 20 (6) || || || || || || || || || B0 (2+t+p) || - || - || - || - || - || - || - || Branch on CF = PC + 2↓, [PC + 1 ] → PCL, [PC + 2] → PCH || Branch on Carry SetJump to SubRoutine
|-
| BEQ RTS || 60 (6) || || || || || || || || || || || F0 (2+t+p) || - || - || - || - || - || - || - || Branch on ZF = (S)↑ → PCL, (S)↑ → PCH, PC + 1 → PC || Branch on EQualReTurn from Subroutine
|-
| BIT RTI || 40 (6) || || 2C (4) || || || || 24 (3) || || || || || || N || V || - D || - || - I || Z || - C || A ∧ M(S)↑ → P, M<sub>7</sub> (S)↑ NFPCL, M<sub>6</sub> (S)↑ VF PCH || test BITsReTurn from Interrupt
|-
| BMI BRK || 00 (7) || || || || || || || || || || || 30 (2+t+p) || - || - || - || - 1 || - || - || - || Branch on NF = 1 PC + 2↓, [FFFE] → PCL, [FFFF] → PCH || Branch on MInusBReaK
|-
| BNE SEI || 78 (2) || || || || || || || || || || || D0 (2+t+p) || - || - || - || - || - 1 || - || - || Branch on ZF = 0 1 → IF || Branch on Not EqualSEt Interrupt flag
|-
| BPL CLI || 58 (2) || || || || || || || || || || || 10 (2+t+p) || - || - || - || - || - 0 || - || - || Branch on NF = 0 → IF || Branch on PLusCLear Interrupt flag
|-
| BRK SEC || 00 38 (72) || || || || || || || || || || || || - || - || 1 - || - || 1 || - || - 1 || PC + 2↓, [FFFE] → PCL, [FFFF] 1 PCH CF || BReaKSEt Carry flag
|-
| BVC CLC || 18 (2) || || || || || || || || || || || 50 (2+t+p) || - || - || - || - || - || - || - 0 || Branch on VF = 0 → CF || Branch on oVerflow ClearCLear Carry flag
|-
| BVS SED || F8 (2) || || || || || || || || || || || 70 (2+t+p) || - || - || - || - 1 || - || - || - || Branch on VF = 1 → DF || Branch on oVerflow SetSEt Decimal flag
|-
| CLC CLD || 18 D8 (2) || || || || || || || || || || || || - || - || - 0 || - || - || - || 0 || 0 → CF DF || CLear Carry Decimal flag
|-
| CLD CLV || D8 B8 (2) || || || || || || || || || || || || - || - 0 || - || 0 || - || - || - || 0 → DF VF || CLear Decimal oVerflow flag
|-
| CLI NOP || 58 EA (2) || || || || || || || || || || || || - || - || - || - || 0 || - || - || 0 → IF No operation || CLear Interrupt flagNo OPeration
|-
| CLV BPL || B8 (2) || || || || || || || || || || || 10 (2+t+p) || - || 0 || - || - || - || - || - || Branch on NF = 0 → VF || CLear oVerflow flagBranch on PLus
|-
| JMP BMI || || || 4C (3) || || || 6C (5) || || || || || || 30 (2+t+p) || - || - || - || - || - || - || - || [PC + Branch on NF = 1] → PCL, [PC + 2] → PCH || JuMPBranch on MInus
|-
| JSR BVC || || || 20 (6) || || || || || || || || || 50 (2+t+p) || - || - || - || - || - || - || - || PC + 2↓, [PC + 1] → PCL, [PC + 2] → PCH Branch on VF = 0 || Jump to SubRoutineBranch on oVerflow Clear
|-
| NOP BVS || EA (2) || || || || || || || || || || || 70 (2+t+p) || - || - || - || - || - || - || - || No operation Branch on VF = 1 || No OPerationBranch on oVerflow Set
|-
| RTI BCC || 40 (6) || || || || || || || || || || || 90 (2+t+p) || N - || V - || - || D - || I - || Z - || C || (S)↑ → P, (S)↑ → PCL, (S)↑ → PCH Branch on CF = 0 || ReTurn from InterruptBranch on Carry Clear
|-
| RTS BCS || 60 (6) || || || || || || || || || || || B0 (2+t+p) || - || - || - || - || - || - || - || (S)↑ → PCL, (S)↑ → PCH, PC + Branch on CF = 1 → PC || ReTurn from SubroutineBranch on Carry Set
|-
| SEC BNE || 38 (2) || || || || || || || || || || || D0 (2+t+p) || - || - || - || - || - || - || 1 || 1 → CF Branch on ZF = 0 || SEt Carry flagBranch on Not Equal
|-
| SED BEQ || F8 (2) || || || || || || || || || || || || - || - || - || 1 || - || - || - || 1 → DF || SEt Decimal flag|-| SEI || 78 F0 (2+t+p) || || || || || || || || || || || || - || - || - || - || 1 || - || - || Branch on ZF = 1 → IF || SEt Interrupt flagBranch on EQual
|}
{| class="wikitable" style="white-space: nowrap;"
|-
! rowspan=2|Mnemonic !! colspan=10|Addressing Modes !! colspan=76|Flags !! rowspan=2|Operation !! rowspan=2|Description
|-
! ''No arg'' !! #$nn !! $nnnn !! $nnnn,X !! $nnnn,Y !! $nn !! $nn,X !! $nn,Y !! ($nn,X) !! ($nn),Y !! N !! V !! B !! D !! I !! Z !! C
|-
| ALR DCP (ASRDCM) || || 4B || CF (26) || DF (7) || DB (7) || C7 (5) || D7 (6) || || C3 (8) || D3 (8) || || 0 || - N || - || - || - || Z || C || A AND oper, 0 M -> [76543210] 1 -> CF M, A - M || AND DEC oper + LSRCMP oper
|-
| ANC ISC (ISB, INS) || || || 0B EF (26) || FF (7) || FB (7) || E7 (5) || F7 (6) || || E3 (8) || || F3 (8) || N || - || - V || - || - || Z || C || A AND oper, bit(7) M + 1 -> M, A - M - CF -> A || AND INC oper + set CF as ASLSBC oper
|-
| ANC2 RLA || || 2B || 2F (26) || 3F (7) || 3B (7) || 27 (5) || 37 (6) || || 23 (8) || || 33 (8) || N || - || - || - || - || Z || C || M = CF <- [76543210] <- CF, A AND oper, bit(7) M -> CF A || AND ROL oper + set CF as ROLAND oper
|-
| RRA || || || 6F (6) || 7F (7) || 7B (7) || 67 (5) || 77 (6) || || 63 (8) || 73 (8) || N || V || - || - || Z || C || M = CF -> [76543210] -> CF, A + M + CF -> A, CF || ROR oper + ADC oper|-| SLO (ASO) || || || 0F (6) || 1F (7) || 1B (7) || 07 (5) || 17 (6) || || 03 (8) || 13 (8) || N || - || - || - || Z || C || M = CF <- [76543210] <- 0, A OR M -> A || ASL oper + ORA oper|-| SRE (LSE) || || || 4F (6) || 5F (7) || 5B (7) || 47 (5) || 57 (6) || || 43 (8) || 53 (8) || N || - || - || - || Z || C || M = 0 -> [76543210] -> CF, A EOR M -> A || LSR oper + EOR oper|-| LAX || || || AF (4) || || BF (4+p) || A7 (3) || || B7 (4) || A3 (6) || B3 (5+p) || N || - || - || - || Z || - || M -> A -> X || LDA oper + LDX oper|-| SAX (AXS, AAX) || || || 8F (4) || || || 87 (3) || || 97 (4) || 83 (6) || || - || - || - || - || - || - || A AND X -> M || Stores the bitwise AND of A and X|-| LAS (LAR) || || || || || BB (4+p) || || || || || || N || - || - || - || Z || - || M AND SP -> A, X, SP || LDA/TSX oper|-| TAS (XAS, SHS) || || || || || style="color: #CC0000;"|'''9B''' (5) || || || || || || - || - || - || - || - || - || A AND X -> SP, A AND X AND (H+1) -> M || Puts A AND X in SP and stores A AND X AND (high-byte of addr + 1) at addrunstable: sometimes 'AND (H+1)' is dropped, page boundary crossings may not work|-| SHA (AHX, AXA) || || || || || style="color: #CC0000;"|'''9F''' (5) || || || || || style="color: #CC0000;"|'''93''' (6) || - || - || - || - || - || - || A AND X AND (H+1) -> M || Stores A AND X AND (high-byte of addr + 1) at addrunstable: sometimes 'AND (H+1)' is dropped, page boundary crossings may not work|-| SHX (A11, SXA, XAS) || || || || || style="color: #CC0000;"|'''9E''' (5) || || || || || || - || - || - || - || - || - || X AND (H+1) -> M || Stores X AND (high-byte of addr + 1) at addrunstable: sometimes 'AND (H+1)' is dropped, page boundary crossings may not work|-| SHY (SYA, SAY) || || || || style="color: #CC0000;"|'''9C''' (5) || || || || || || || - || - || - || - || - || - || Y AND (H+1) -> M || Stores Y AND (high-byte of addr + 1) at addrunstable: sometimes 'AND (H+1)' is dropped, page boundary crossings may not work|-| ANE (XAA) || || style="color: #CC0000;"|'''8B''' (2) || || || || || || || || || N || - || - || - || - || Z || - || (A OR magic) AND X AND oper -> A || * AND X + AND oper
highly unstable: involves a 'magic' constant that depends on temperature, the chip series, and maybe other factors.
Turrican 3 on C64 requires a different magic constant than $EE for ANE. $EF is recommended by Groepaz (VICE team)
|-
| ARR LXA (LAX) || || 6B style="color: #CC0000;"|'''AB''' (2) || || || || || || || || || N || V - || - || - || Z || - || (A OR magic) AND oper -> A -> X || Store * AND oper in A and Xhighly unstable: involves a 'magic' constant that depends on temperature, the chip series, and maybe other factors. Wizball on C64 requires a $EE magic constant for LXA|-| ALR (ASR) || || 4B (2) || || || || || || || || || 0 || - || - || - || Z || C || A AND oper, 0 -> [76543210] -> CF || AND oper + LSR|-| ARR || || 6B (2) || || || || || || || || || N || V || - || - || Z || C || A AND oper, CF -> [76543210] -> CF || AND oper + ROR|-| ANC || || 0B (2) || || || || || || || || || N || - || - || - || Z || C || A AND oper, bit(7) -> CF || AND oper + set CF as ASL|-| ANC2 || || 2B (2) || || || || || || || || || N || - || - || - || Z || C || A AND oper, bit(7) -> CF || AND oper + set CF as ROL
|-
| DCP SBX (DCMAXS, SAX) || || || CF CB (62) || DF (7) || DB (7) || C7 (5) || D7 (6) || || C3 (8) || D3 (8) || N || - N || - || - || - || Z || C || M (A AND X) - 1 oper -> M, A - M X || DEC oper + CMP operand DEX at once, sets flags like CMP
|-
| ISC USBC (ISB, INSSBC) || || || EF EB (62) || FF (7) || FB (7) || E7 (5) || F7 (6) || || E3 (8) || F3 (8) || || N || V || - || - || - || Z || C || M + 1 -> M, A - M - ~CF -> A || INC SBC oper + SBC operNOP
|-
| JAM (KIL, HLT) || 02, 12, 22,
B2, D2, F2 (X)
|| || || || || || || || || || - || - || - || - || - || - || - || Stop execution || Halt the CPU. The processor will be trapped infinitely in T1 phase with $FF on the data bus. Reset required.|-| LAS (LAR) || || || || || BB (4+p) || || || || || || N || - || - || - || - || Z || - || M AND SP -> A, X, SP || LDA/TSX oper|-| LAX || || || AF (4) || || BF (4+p) || A7 (3) || || B7 (4) || A3 (6) || B3 (5+p) || N || - || - || - || - || Z || - || M -> A -> X || LDA oper + LDX oper|-| LXA (LAX) || || style="color: #CC0000;"|'''AB''' (2) || || || || || || || || || N || - || - || - || - || Z || - || (A OR magic) AND oper -> A -> X || Store * AND oper in A and Xhighly unstable: involves a 'magic' constant that depends on temperature, the chip series, and maybe other factors. Wizball on C64 requires a $EE magic constant for LXA
|-
| NOP (DOP, TOP) || 1A, 3A, 5A,
|| || 04, 44, 64 (3) || 14, 34, 54,
74, D4, F4 (4)
|| || || || - || - || - || - || - || - || - || No operation || No Operation|-| RLA || || || 2F (6) || 3F (7) || 3B (7) || 27 (5) || 37 (6) || || 23 (8) || 33 (8) || N || - || - || - || - || Z || C || M = CF <- [76543210] <- CF, A AND M -> A || ROL oper + AND oper|-| RRA || || || 6F (6) || 7F (7) || 7B (7) || 67 (5) || 77 (6) || || 63 (8) || 73 (8) || N || V || - || - || - || Z || C || M = CF -> [76543210] -> CF, A + M + CF -> A, CF || ROR oper + ADC oper|-| SAX (AXS, AAX) || || || 8F (4) || || || 87 (3) || || 97 (4) || 83 (6) || || - || - || - || - || - || - || - || A AND X -> M || Stores the bitwise AND of A and X|-| SBX (AXS, SAX) || || CB (2) || || || || || || || || || N || - || - || - || - || Z || C || (A AND X) - oper -> X || CMP and DEX at once, sets flags like CMP|-| SHA (AHX, AXA) || || || || || style="color: #CC0000;"|'''9F''' (5) || || || || || style="color: #CC0000;"|'''93''' (6) || - || - || - || - || - || - || - || A AND X AND (H+1) -> M || Stores A AND X AND (high-byte of addr + 1) at addrunstable: sometimes 'AND (H+1)' is dropped, page boundary crossings may not work|-| SHX (A11, SXA, XAS) || || || || || style="color: #CC0000;"|'''9E''' (5) || || || || || || - || - || - || - || - || - || - || X AND (H+1) -> M || Stores X AND (high-byte of addr + 1) at addrunstable: sometimes 'AND (H+1)' is dropped, page boundary crossings may not work|-| SHY (SYA, SAY) || || || || style="color: #CC0000;"|'''9C''' (5) || || || || || || || - || - || - || - || - || - || - || Y AND (H+1) -> M || Stores Y AND (high-byte of addr + 1) at addrunstable: sometimes 'AND (H+1)' is dropped, page boundary crossings may not work|-| SLO (ASO) || || || 0F (6) || 1F (7) || 1B (7) || 07 (5) || 17 (6) || || 03 (8) || 13 (8) || N || - || - || - || - || Z || C || M = CF <- [76543210] <- 0, A OR M -> A || ASL oper + ORA oper|-| SRE (LSE) || || || 4F (6) || 5F (7) || 5B (7) || 47 (5) || 57 (6) || || 43 (8) || 53 (8) || N || - || - || - || - || Z || C || M = 0 -> [76543210] -> CF, A EOR M -> A || LSR oper + EOR oper|-| TAS (XAS, SHS) || || || || || style="color: #CC0000;"|'''9B''' (5) || || || || || || - || - || - || - || - || - || - || A AND X -> SP, A AND X AND (H+1) -> M || Puts A AND X in SP and stores A AND X AND (high-byte of addr + 1) at addrunstable: sometimes 'AND (H+1)' is dropped, page boundary crossings may not work|-| USBC (SBC) || || EB (2) || || || || || || || || || N || V || - || - || - || Z || C || A - M - ~CF -> A || SBC oper + NOP
|}
| 68 || PLA
|-
| 6C xx xx || JMP ''zpgind''
|-
| 70 xx || BVS ''rel''
* Conditional jumps are only 8-bit relative. And unconditional jumps are only 16-bit absolute.
* ADC is the only command for addition. To perform an addition without carry, the carry flag must be cleared manually first. Same with SBC for subtract.
* The TXS instruction does not affect any flag, while all other transfer instructions do.* The BIT instruction copies bit 6 of the memory location to VF, regardless of any arithmetic overflow concept.* The CLV (Clear Overflow Flag) instruction exist , but not the SEV (Set Overflow Flag) instruction.* On NMOS, INC A and DEC A instructions do not exist. They do exist on CMOS.
* The NOP instruction takes 2 full-cycles. This is the minimum amount of cycles an instruction can take. It is necessary because, while the instruction itself does nothing, it still has to increment the 16-bit PC register.
* The alternate NOPs are not created equal. Some have one- or two-byte operands (which they don't do anything with), and they take different amounts of time to execute.
For a specific example, the 6502 PLA decodes instructions matching 100XX1XX to the control line STY (ignoring the timing bits for simplicity). This takes 1 row in the PLA, but it would take 16 entries in a ROM. [https://news.ycombinator.com/item?id=13128074 Source]
See: [https://web.archive.org/web/20210519010632/http://visual6502.org/wiki/index.php?title=6507_Decode_ROM 6507 Decode ROM (PLA)] [https://pastraiser.com/cpu/65CE02/65CE02_rom.html 65CE02 Decode ROM (PLA)] [https://www.righto.com/2016/02/reverse-engineering-arm1-instruction.html ARM1, Z80, 6502 instruction sequencing compared] [https://www.pagetable.com/?p=410 Internals of BRK/IRQ/NMI/RESET on a MOS 6502] [https://www.pagetable.com/?p=39 How MOS 6502 illegal opcodes really work] [https://c74project.com/wp-content/uploads/2020/04/c74-6502-microcode.pdf 6502 microcode] [https://c74project.com/wp-content/uploads/2020/04/c74-6502-microinstructions.pdf 6502 microinstructions]
<br>
* The 6502C used in [[Atari 8-bit]] computer range, adds an additional HALT pin for DMA. The 6502C is otherwise a regular NMOS 6502, not to be confused with the CMOS 65C02.
* The CMOS 65C02 fixed multiple bugs of the original NMOS 6502, but also removed access to all illegal instructions. Some cycle counts have been modified and some extra instructions have been added. In fact, there are multiple implementations of the 65C02 (WDC 65C02, WDC 65C02S, Rockwell R65C02, CSG 65CE02, ...), each with its own variant of the instruction set[https://www.pagetable.com/c64ref/6502/?tab=2 6502 Family CPU Reference].
* The HuC6280, used in the [[PC-Engine]] gaming console, is an improved version of the CMOS 65C02. [[Media:HuC6280 - CMOS 8-bit Microprocessor Hardware Manual.pdf|HuC6280 hardware manual]] [[Media:HuC6260 - CMOS Video Color Encoder Manual.pdf|HuC6260 VCE manual]] [[Media:HuC6270 - CMOS Video Display Controller Manual.pdf|HuC6270 VDC manual]]
* The WDC 65C816, used in the [[SNES]] and the [[Apple IIGS]], is a 16-bit version of the 65C02 [https://www.westerndesigncenter.com/wdc/documentation/w65c816s.pdf 65C816 datasheet] [https://archive.org/details/SNESDevManual/ SNES development manual] [https://problemkaputt.de/fullsnes.htm Noca$h's fullsnes] [https://snes.nesdev.org/wiki/SNESdev_Wiki SNESdev wiki]. The 65C816 contains a compatibillity mode, enabled by default upon reset, that makes it behave like a regular 65C02. The full 65C816 cycle-by-cycle steps are in the [https://www.westerndesigncenter.com/wdc/documentation/w65c816s.pdf 65C816 datasheet].
* The Sony SPC700 sound CPU used inside the SNES also behaves similarly to a 6502 with some extensions. [https://wiki.superfamicom.org/spc700-reference Source] [https://www.youtube.com/watch?v=zrn0QavLMyo&list=PLHQ0utQyFw5JD2wWda50J8XuzQ2cFr8RX SPC700 Series] [https://github.com/gilyon/snes-tests SNES-tests]
*[https://www.masswerk.at/6502/6502_instruction_set.html 6502 Instruction Set] [https://www.masswerk.at/nowgobang/2021/6502-illegal-opcodes 6502 illegal opcodes demystified]
*[[Media:NoMoreSecrets-NMOS6510UnintendedOpcodes-20212412.pdf|No more secrets - NMOS 6510 Unintended Opcodes]]
*[https://www.pagetable.com/c64ref/6502/?tab=2 6502 Family CPU Reference]
*[https://llx.com/Neil/a2/opcodes.html The 6502/65C02/65C816 Instruction Set Decoded]
*[https://pastraiser.com/cpu/6502/6502_opcodes.html 6502 opcodes] [https://pastraiser.com/cpu/65CE02/65CE02_opcodes.html 65CE02 opcodes]
13,173
edits