Sinclair ZX Spectrum RAM and ROM Memory Mapping Explained
This article provides a technical overview of how the Sinclair ZX Spectrum allocated its address space between Read-Only Memory (ROM) and Random-Access Memory (RAM). It details the Z80 CPU’s 64KB address limit, the fixed memory map used in the original 16K and 48K models, and the hardware logic that managed access. Additionally, the text covers the evolution of memory banking introduced in the later 128K models to overcome initial hardware limitations.
The foundation of the ZX Spectrum’s memory architecture lies in the Zilog Z80 processor, which was capable of addressing exactly 64KB of memory. This address space ranges from 0x0000 to 0xFFFF in hexadecimal notation. Sinclair designers had to fit the BASIC interpreter, the operating system, the display buffer, and user program space within this strict limit. To achieve this, they implemented a static memory map that divided the address space into distinct regions for ROM and RAM without the need for complex memory management units in the original hardware.
In the original 16K and 48K ZX Spectrum models, the memory map was hardwired. The lower 16KB of the address space, from 0x0000 to 0x3FFF, was permanently assigned to ROM. This section contained the Sinclair BASIC interpreter and the operating system routines required to boot the machine and manage input/output. The remaining upper 48KB, from 0x4000 to 0xFFFF, was designated for RAM. In the 16K model, only the first 16KB of this RAM section was physically populated with chips, while the 48K model utilized the full available space for user programs and the video display file.
Hardware decoding logic, largely handled by the Uncommitted Logic Array (ULA), managed the selection between these memory regions. When the Z80 CPU placed an address on the address bus, the decoding circuitry determined whether to activate the ROM chips or the RAM chips. If the address fell within the lower 16KB range, the ROM was enabled. If the address was higher, the RAM was selected. This process was instantaneous and transparent to the software, allowing the CPU to fetch instructions from ROM and store variables in RAM seamlessly within a single unified address space.
The later ZX Spectrum 128K models introduced a more dynamic approach known as memory banking to utilize the additional memory beyond the Z80’s 64KB limit. Since the CPU could still only address 64KB at any given time, the 128K hardware implemented a paging system. This allowed specific 16KB blocks of the physical RAM to be swapped in and out of the CPU’s addressable range. While the original models relied on a fixed map, the 128K architecture demonstrated how Sinclair evolved memory mapping to support more complex software and larger data requirements while maintaining backward compatibility.