wire / wire-format / r6502-instruction

MOS 6502 instruction encoding

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).

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: MOS 6502 instruction encoding

wire format

spec: MOS 6502

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).

fieldsizemeaning
Instruction format1-3 bytesOpcode (1 byte) + optional operand (0, 1, or 2 bytes). No prefixes, no ModR/M.
Addressing modesvariousImmediate (#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).
Registers3A (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).
Status flags (P)8 bitsBit 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).
Memory64KB16-bit address space (0x0000-0xFFFF). Zero page (0x00-0xFF) for fast access.
Stack256 bytesPage 1 (0x0100-0x01FF). SP is 8-bit (stack depth max 256).

example:

a9 00

6502: LDA #$00 (load accumulator with 0)


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/r6502-instruction or /wire-format/r6502-instruction.json