{
  "id": "wire-format/r6502-instruction",
  "family": "wire-format",
  "slug": "r6502-instruction",
  "title": "MOS 6502 instruction encoding",
  "summary": "The MOS 6502 is an 8-bit microprocessor (1975) used in the Apple II, Commodore 64, NES, and Atari 2600. Instructions are 1-3 bytes. Addressing modes: immediate (#), zero page (zp), zero page X/Y (zp,X/Y), absolute (abs), absolute X/Y (abs,X/Y), indirect (ind), indirect X/Y ((ind,X), (ind),Y), relative (rel, for branches). 3 registers: A (accumulator), X, Y (index). Status flags: N (negative), V (overflow), B (break), D (decimal), I (interrupt disable), Z (zero), C (carry).",
  "kind": "wire-format",
  "aliases": [
    "MOS 6502 instruction encoding"
  ],
  "status": "standard",
  "verification": "verified",
  "tier": "B",
  "source_url": "https://en.wikipedia.org/wiki/MOS_Technology_6502",
  "source_version": "retrieved 2026-05-29",
  "retrieved_date": "2026-05-29",
  "ext_type": "wire-format@1",
  "ext": {
    "spec": "MOS 6502",
    "summary": "The MOS 6502 is an 8-bit microprocessor (1975) used in the Apple II, Commodore 64, NES, and Atari 2600. Instructions are 1-3 bytes. Addressing modes: immediate (#), zero page (zp), zero page X/Y (zp,X/Y), absolute (abs), absolute X/Y (abs,X/Y), indirect (ind), indirect X/Y ((ind,X), (ind),Y), relative (rel, for branches). 3 registers: A (accumulator), X, Y (index). Status flags: N (negative), V (overflow), B (break), D (decimal), I (interrupt disable), Z (zero), C (carry).",
    "structure": [
      {
        "field": "Instruction format",
        "size": "1-3 bytes",
        "meaning": "Opcode (1 byte) + optional operand (0, 1, or 2 bytes). No prefixes, no ModR/M."
      },
      {
        "field": "Addressing modes",
        "size": "various",
        "meaning": "Immediate (#imm), Zero Page (zp), Zero Page X (zp,X), Zero Page Y (zp,Y), Absolute (abs), Absolute X (abs,X), Absolute Y (abs,Y), Indirect (ind), Indirect X ((ind,X)), Indirect Y ((ind),Y), Relative (rel, for branches)."
      },
      {
        "field": "Registers",
        "size": "3",
        "meaning": "A (accumulator), X (index), Y (index). Plus SP (stack pointer, 8-bit, page 1: 0x0100-0x01FF), PC (program counter, 16-bit), P (status register, 8 bits)."
      },
      {
        "field": "Status flags (P)",
        "size": "8 bits",
        "meaning": "Bit 7 N (negative), 6 V (overflow), 5 (unused, always 1), 4 B (break), 3 D (decimal mode), 2 I (interrupt disable), 1 Z (zero), 0 C (carry)."
      },
      {
        "field": "Memory",
        "size": "64KB",
        "meaning": "16-bit address space (0x0000-0xFFFF). Zero page (0x00-0xFF) for fast access."
      },
      {
        "field": "Stack",
        "size": "256 bytes",
        "meaning": "Page 1 (0x0100-0x01FF). SP is 8-bit (stack depth max 256)."
      }
    ],
    "example_hex": "a9 00",
    "example_decoded": "6502: LDA #$00 (load accumulator with 0)",
    "notes": [
      "The 6502 is one of the most influential 8-bit CPUs.",
      "6502 uses zero-page addressing for fast 8-bit address access.",
      "6502 has no multiply/divide instructions (done in software).",
      "6502's decimal mode (D flag) enables BCD arithmetic.",
      "The 6502's simple design made it cheap and ubiquitous (Apple II, C64, NES)."
    ]
  },
  "updated": "2026-05-29"
}
