← r0mheat z80 lessons: all projects

Z80 addresses and memory maps

A 16-bit address selects one byte in a 64 KB address space. A memory map shows what each address range is used for.

Number basics

One address selects one byte

The Z80 has 16 address bits. They can represent 65,536 different addresses, from 0000h to FFFFh. That is 64 KB when each address holds one byte. A register pair such as HL can hold an address. For example, LD A,(HL) reads the byte at the address in HL.

Read a memory map

A memory map divides the address space into ranges. These bars mark useful addresses; their heights are not proportional to the distances between them. Each computer assigns its own uses to these addresses.

0000h — low addresses
0100h — 256 bytes from the start
0400h — 1 KB from the start
8000h — middle of the address space
FFFFh — last address

A real map might assign some ranges to ROM, some to RAM, and some to hardware. The exact ranges depend on the machine. The Z80 CPU alone does not define one universal memory map.

Why 100h and 400h are useful

100h = 256One hundred hex is 256 decimal. It is also 1 × 256 bytes, or 100h bytes.
400h = 1024Four hundred hex is 1024 decimal. It is also 4 × 256 bytes, or 1 KB.
1000h = 4096One thousand hex is 4096 decimal. It is 4 KB.
10000h = 65536This is the address-space size. It is one past the last 16-bit address, FFFFh.

Each added hex digit multiplies the place value by 16. So 100h = 1 × 16² = 256, and 400h = 4 × 16² = 1024.

Calculate an address from a base and offset

Many addresses are written as a base plus an offset. Add them to find the final address. For example, 4000h + 0100h = 4100h.

Result
4100h · 16640

4000h + 0100h = 4100h. The offset is 256 bytes from the base.

Enter up to four hex digits in each box. The result may be larger than FFFFh; that means it is outside the 16-bit address range.

Calculate the size of a range

For an inclusive range, subtract the first address from the last, then add 1. For example, 4000h–40FFh contains 0100h bytes: 256 bytes.

An address is a location. A size is a count of bytes. Do not confuse the address 0100h with the size 0100h bytes: the same number can describe either, depending on context.

This page uses a generic Z80 address space. It does not assign ROM, RAM or hardware ranges to a specific computer.