Logo
Segmentation Memory Model
Overview

Segmentation Memory Model

May 11, 2025
1 min read
segmentation

Intro

Memory access in real mode is done using something called segmentation.

The original 8086 processor used mostly 16-bit registers. But a 16-bit register can only represent 216=65536 bytes=64 KB2^{16} = 65536 \text{ bytes} = 64 \text{ KB}. So theoretically, the CPU should only have been only be able to access 64 KB of memory instead of 1 MB.

As a solution to this, segmentation was introduced. Instead of using a single address, memory locations were accessed using segment:offset

8086 Segment Registers

The 8086 introduced several special segment registers:

  1. CS (Code Segment)
  2. SS (Stack Segment)
  3. DS (Data Segment)
  4. ES (Extra Segment)

Calculating Physical Addresses

In real mode, the CPU converts a segment:offset pair into an actual physical memory address using this formula: physical address=(segment×16)+offset\texttt{physical address}=(\texttt{segment} \times 16)+\texttt{offset}

For example, suppose:

Code Segment = 0x7c0
Offset = 0x0

Then the physical address becomes: 0x7c0×0x10+0x0=0x7c00\texttt{0x7c0} \times \texttt{0x10} + \texttt{0x0} = \texttt{0x7c00}