Z80 vs 6502 CPU Architecture for Retro Game Development 2025

Understanding the Z80 vs 6502: Core Differences for Emulation

When developing retro game emulators or studying 8-bit processor architecture, you'll encounter two dominant CPUs: the Zilog Z80 and the MOS Technology 6502. While both powered iconic systems—the Z80 in ZX Spectrum and Game Boy, the 6502 in Apple II and NES—they have fundamentally different instruction sets, addressing modes, and performance characteristics that directly impact emulator design and historical accuracy.

Architecture Overview: Register Layout and Memory Model

The 6502 uses a simpler, more orthogonal register architecture with:

  • Accumulator (A) for arithmetic/logic operations
  • Two index registers (X, Y) for addressing
  • Stack pointer and program counter
  • 8-bit only operations
  • 16-bit address space (64KB maximum)

The Z80 builds on the Intel 8080 with a richer register set:

  • Dual register pairs (BC, DE, HL, IX, IY)
  • Separate accumulator and flags
  • Alternative register banks for interrupt handling
  • Both 8-bit and 16-bit operations
  • Same 64KB address space but with banking support on some systems
6502 Register File:        Z80 Register File:
A (Accumulator)           A (Accumulator)
X (Index)                 BC, DE, HL (Pairs)
Y (Index)                 AF, BC', DE', HL' (Alt)
SP, PC, Flags            SP, PC, Flags, I, R

Instruction Set Comparison

| Aspect | 6502 | Z80 | |--------|------|-----| | Total Instructions | ~56 opcodes | ~158 opcodes | | Addressing Modes | 13 modes | 24+ modes | | 16-bit Operations | Limited | Full support | | Bit Operations | None | Extensive (BIT, SET, RES) | | Relative Branches | 8-bit offset | 8-bit offset | | Clock Cycles (NOP) | 2 | 4 | | Memory to Register | Load only | Load/Store both |

Addressing Mode Depth

The 6502 excels with elegant simplicity:

  • Immediate, Zero Page, Absolute, Indirect
  • Indexed variations (X, Y)
  • Indexed Indirect and Indirect Indexed

This minimalism made the 6502 cheap to manufacture and easy to debug in emulators.

The Z80 offers granular control:

  • Indexed addressing with (IX+d), (IY+d)
  • Register indirect with auto-increment/decrement
  • Bit addressing within registers
  • Conditional relative jumps with 8-bit displacement

For a practical example, reading a value from memory and incrementing a pointer:

6502:

LDY #0
LDA ($20),Y    ; Indirect Indexed mode
INY

Z80:

LD HL, (2000h) ; Load address from memory
LD A, (HL)     ; Load value at address
INC HL         ; Increment with auto-increment available

Performance and Clock Cycles

The 6502 is known for tight, predictable timing. Most instructions execute in 2-4 cycles. A 1MHz 6502 could theoretically execute ~500k instructions per second, though practical throughput varied by instruction mix.

The Z80, running at similar clock speeds (2-4MHz was common), had longer instruction execution (4-15 cycles) but more work per instruction due to 16-bit capabilities. A 4MHz Z80 often outperformed a 2MHz 6502 despite lower clock rates.

6502 Example: Increment and Loop
Loop: LDA #$00       ; 2 cycles
      CMP $80        ; 3 cycles
      BNE Loop       ; 2-3 cycles

Z80 Example: Same operation
Loop: LD A, 0        ; 7 cycles
      CP 80h         ; 7 cycles
      JR NZ, Loop    ; 7-12 cycles

Interrupt Handling and Flags

The 6502 uses a single flag register (P) with:

  • Carry, Zero, Interrupt Disable, Decimal, Break, Overflow, Negative
  • Single interrupt source (NMI and IRQ separated by hardware)
  • Simple interrupt handling with BRK instruction

The Z80 has:

  • Separate Flags register (F) with carry, zero, parity, overflow
  • Two interrupt modes (maskable and non-maskable)
  • Alternate register set for fast context switching
  • IFF (Interrupt Flip-Flop) for interrupt enable/disable

This difference is critical for emulator accuracy. NES games often rely on precise IRQ timing; Z80-based systems (especially Game Boy) use interrupt modes extensively for synchronization.

Practical Implications for Developers

Choose 6502 if you're emulating:

  • Apple II, Commodore 64, or NES
  • You need simpler instruction decoding
  • Cycle-accurate timing is essential
  • Memory footprint matters (smaller disassembler tables)

Choose Z80 if you're emulating:

  • ZX Spectrum, Game Boy, or Sega Master System
  • You need 16-bit arithmetic without workarounds
  • Bit manipulation is common in the target software
  • Game Boy's unique interrupt/stop modes require it

Building an Emulator: Key Differences

When implementing a CPU core, the Z80's complexity matters. The instruction fetch-decode cycle differs:

6502: Single-byte opcodes (mostly). Straightforward dispatch table works well.

Z80: Prefix bytes (CB, ED, DD, FD) extend instructions, creating a multi-level decode tree. This increases complexity but enables powerful operations like bit testing:

Z80 Bit Test: BIT 7, (HL)
Opcode: CB 7E
Prefix CB indicates bit operation
Subsequent byte specifies bit position and register

For cycle accuracy, the 6502 is forgiving (most operations are 2-4 cycles). The Z80 requires careful attention to variable-length instruction timing, especially with prefixes.

Legacy and Modern Relevance

Both CPUs remain relevant in:

  • Educational emulation projects (both are well-documented)
  • Retro game preservation (accurate emulation requires understanding these differences)
  • FPGA implementations of classic systems
  • Historical computing research

If you're building an emulator in 2025, understand that the Z80 is more complex but more capable, while the 6502 rewards you with elegant simplicity and tight cycle counting. Many successful emulators (MAME, Bizhawk, FCEUltra) implement both, making these comparisons essential knowledge for core developer contributors.

Conclusion

The choice between Z80 and 6502 architectures shapes your entire emulator design. The 6502's orthogonal simplicity versus the Z80's feature richness reflects different design philosophies. Modern emulator development benefits from understanding both—6502 teaches you tight cycle accuracy, while Z80 teaches you handling instruction complexity. For serious retro development work, mastering both instruction sets unlocks the ability to contribute to major preservation projects.

Recommended Tools