Skip to content
Techniques & Technology

Memory Banking

Exceeding address limits

Memory banking allowed systems to access more memory than their address buses could directly reach, swapping different banks of RAM or ROM into the same address range.

C64NESzx-spectrumgame-boy memoryhardwaretechnique 1980–present

Overview

The 6502 could only address 64KB. The Z80 reached the same limit. But games needed more—more graphics, more levels, more music. Memory banking solved this by swapping different memory “banks” into the same address range. The CPU saw the same addresses, but different data appeared depending on which bank was active.

The problem

CPUAddress busMaximum memory
650216-bit64KB
Z8016-bit64KB

Games needed more than 64KB.

The solution

ConceptImplementation
BanksMultiple memory blocks
SwitchingControl register selects bank
WindowAddress range that changes
FixedAddresses that don’t change

C64 banking

Memory map

AddressContents
$0000-$9FFFRAM
$A000-$BFFFBASIC ROM or RAM
$C000-$CFFFRAM
$D000-$DFFFI/O, char ROM, or RAM
$E000-$FFFFKERNAL ROM or RAM

Bank switching register

    lda #$35       ; All RAM, I/O visible
    sta $01        ; Processor port

NES cartridge banking

Mappers

MapperCapability
NROMNo banking (32KB max)
MMC1256KB PRG, 128KB CHR
MMC3512KB PRG, 256KB CHR
MMC51MB PRG, 1MB CHR

Mapper registers

Write to specific addresses to control banks:

    lda #$05       ; Bank number
    sta $8000      ; Bank select register

ZX Spectrum 128

128KB model

BankAddress
0-78 × 16KB banks
Paged at$C000-$FFFF
Fixed$0000-$BFFF

Bank select

    ld a,$05       ; Bank 5
    ld bc,$7ffd    ; Port
    out (c),a      ; Select bank

Game Boy

FeatureDesign
ROM banksSwitchable at $4000-$7FFF
RAM banksSwitchable at $A000-$BFFF
MBC chipsMemory Bank Controllers

Uses

ApplicationBenefit
More levelsLarger games
Graphics banksMore sprites/tiles
Music dataLonger soundtracks
CodeLarger programs

Programming considerations

ChallengeSolution
Code in paged areaKeep critical code fixed
Data accessKnow which bank is active
InterruptsEnsure correct bank for handlers
DebuggingTrack bank state

See also