There are (broadly) two types of memory - ROM and RAM.

ROM

ROM is memory that is full of data you can read but can't change. This is what's inside the game cartridges, and is why people call the dumped data "ROMs".

From our perspective, ROM is where all our code and data lives, at least at first.

ROM stands for Read Only Memory, to remind us that we can't change it.

We can have (almost) as much ROM as we want, although in fact it is hard to fill more than a few dozen KB.

RAM

RAM is memory that is initially empty, but you can write things in and read them out later. In general, we are considering the RAM inside the console that is used by every game you play (although game saves are a type of RAM, and some games have extra RAM in the cartridge to supplement the system RAM).

From our perspective, RAM is where we will keep any data that we have calculated or defined from code, especially data that might need to be remembered and/or might need to change.

RAM stands for Random Access Memory, which is nothing to do with what ROM stands for; it just looks similar. Random Access means you can get at any part of it without waiting (a bit like a CD compared to a tape), but that actually applies equally to ROM.

The Master System has 8KB of system RAM.

Mirroring

Due to the way that chips are connected to the CPU, it is possible to connect a chip such that it fills a slot bigger than the amount of memory on the chip. Memory sizes are generally powers of 2 (4KB, 8KB, 16KB, etc), so the slot will be two or four times the size of the memory. The result, when seen from the CPU, is that the whole of the memory is repeated, to fill the slot. Here's an example:

Memory:            Slot:                Result:
1111222233334444   +----------------+   +----------------+
5555666677778888   |                |   |1111222233334444|
99990000aaaabbbb   |                |   |5555666677778888|
ccccddddeeeeffff   |                |   |99990000aaaabbbb|
                   |                |   |ccccddddeeeeffff|
                   |                |   |1111222233334444|
                   |                |   |5555666677778888|
                   |                |   |99990000aaaabbbb|
                   |                |   |ccccddddeeeeffff|
                   +----------------+   +----------------+

This is called mirroring because you see a duplicated "image" of the memory. If you modify one of the "images" (if it is RAM), both are altered. But note that the "reflection" is not flipped!

The system RAM in the Master System and Game Gear is mirrored. The 8KB fills a 16KB "slot". To avoid confusion, we avoid using the "reflection"; we act (mostly) as if it didn't exist.

SMS Memory Map

The Z80 CPU has a 16-bit address space. That literally means that it has 16 pins on it that select a memory address; that means it can select addresses from $0000 to $ffff (64KB). This is divided (generally) into the following slots:

AddressContentsSize
$0000-$00ffROM1KB
$0100-$3fffROM (slot 1)15KB
$4000-$7fffROM (slot 2)16KB
$8000-$bfffROM (slot 3)16KB
$c000-$dfffRAM8KB
$e000-$ffffRAM (mirror)8KB

For larger games, ROM slots 1-3 can be selected ("mapped") by the game. For smaller ones, such as 32KB ones, then the first 1KB plus slots 1 and 2 are enough to hold all 32KB, and slot 3 is empty.


< Opcodes | Lesson 1 | Registers >