Memory paging

From Sinclair Wiki
Revision as of 06:09, 29 April 2021 by Szaszg (talk | contribs) (Created page with "Various spectrum models and peripherals use '''memory paging''' (or memory mapping) technic to extend the 64kb memory limit of Z80 CPU. == General principles == The Z...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Various spectrum models and peripherals use memory paging (or memory mapping) technic to extend the 64kb memory limit of Z80 CPU.

General principles

The Z80 CPU has 16 address lines and no builtin MMU unit, so can address 64KB (2^16) memory (or I/O) space (0x0000 - 0xffff).

The original ZX Spectrum 16K/48K (or the ZX Spectrum+, Timex) only uses 64KB memory (16KB ROM and 16KB or 48KB RAM), but other models (128K) and several peripheral have extra RAM or ROM.

In order to use the extra RAM or ROM machines and peripherals use some MMU (like) logic and technic:

  • /ROMCS combined with an MMU on the peripheral onboard (e.g. Interface I/II, Disk interfaces, etc)
  • built in MMU logic (e.g. 128K, +2, Timex machines)

The MMU unit determines which physical memory address ranges (pages) reachable on which address range of the CPU (banks).

The alignement and the size of pages and banks is fixed and usually 16KB. e.g.

  • bank0 is 0x0000 to 0x3fff
  • bank1 is 0x4000 to 0x7fff
  • bank2 is 0x8000 to 0xbfff
  • bank3 is 0xc000 to 0xffff

in the CPU address space and

  • page0 is 0x00000 to 0x03fff
  • page1 is 0x04000 to 0x07fff

...

  • page7 is 0x1c000 to 0x1ffff

in the RAM.

Both method (ROMCS or builtin MMU) use some simple event to change the actual paging of ROM or RAM.:

  • out a byte to a specific port (e.g. 0x7ffd)
  • PC register of Z80 CPU hit a specific address
  • user press a (red) button