Skip to content
Techniques & Technology

Bank Switching

Expanding memory through hardware tricks

Bank switching allows systems with limited address space to access more memory by swapping different memory regions into the same address range.

NESC64zx-spectrumsms memoryhardwarecartridge 1970–present

Overview

Bank switching solves a fundamental problem: CPUs with 16-bit address buses can only address 64KB of memory, but games and programs often need more. The solution involves mapping different physical memory regions into the same address range, swapping “banks” as needed. This technique enabled NES cartridges to contain megabytes of data despite the console’s limited addressing.

Fast Facts

AspectDetail
Problem solved16-bit address limit (64KB)
MethodSwap memory regions via hardware
Common platformsNES, Game Boy, C64, ZX Spectrum 128K
Modern equivalentVirtual memory, paging

The Address Space Problem

An 8-bit CPU with 16-bit addressing:

AddressingMaximum
16-bit address bus2^16 = 65,536 bytes
64KB ceilingHard limit for direct access
Game requirementsOften exceeded 64KB

How Bank Switching Works

The concept:

StepAction
1CPU sees fixed address range (e.g., $8000-$BFFF)
2Hardware maps this to physical ROM/RAM
3Writing to special register selects which bank
4New bank appears at same addresses
5Program code switches banks as needed

Platform Examples

NES Mappers

The NES used cartridge hardware called “mappers”:

MapperFeatures
NROM (0)No switching, 32KB PRG
MMC1 (1)256KB PRG, CHR switching
MMC3 (4)512KB PRG, IRQ counter
MMC5 (5)1MB PRG, extended features

Different games used different mappers depending on complexity.

Commodore 64

The C64 used ROM/RAM banking:

RegionBanks
$A000-$BFFFBASIC ROM or RAM
$D000-$DFFFI/O or character ROM or RAM
$E000-$FFFFKernal ROM or RAM

Switching via the processor port at $01.

ZX Spectrum 128K

The 128K Spectrum banked RAM at $C000-$FFFF:

FeatureDetail
Fixed bankBank 5 always at $4000-$7FFF
SwitchableEight 16KB banks at $C000-$FFFF
ControlPort $7FFD

Technical Challenges

ChallengeConsequence
Code can’t span banksJump targets must be in same bank
Data access planningKnow which bank contains what
Interrupt handlingBank state during interrupts
Performance overheadBank switching takes cycles

Programming Patterns

PatternPurpose
Fixed bankCode that must always be accessible
Data banksLevel data, graphics, audio
Trampoline codeJump between banks via fixed code
Bank tablesTrack what’s where

NES Bank Switching Code

A simplified example:

; Switch to bank 3
LDA #$03
STA $8000    ; Bank select register (mapper-specific)

; Now $8000-$BFFF contains bank 3's data

The exact mechanism varies by mapper hardware.

Historical Context

EraApproach
Arcade boardsCustom banking hardware
Console cartridgesMapper chips in cart
Home computersSystem-level banking
CD-ROM eraStreaming replaced banking

Legacy

Bank switching was the bridge between limited addressing and modern virtual memory. Developers learned to structure code and data around bank boundaries—skills that translated into understanding memory hierarchies, caching, and modern paging systems. Emulator developers must accurately emulate mapper behaviour to run games correctly.

See Also