Pointers and 64K Segments

IBM personal computers and compatibles use the Intel 8086, 80186, 80286, or 80386 processors (collectively called the 80x86 family). These processors have a “segmented” architecture, which means they all have a mode that treats memory as a series of segments, each of which occupies up to 64K of memory. An offset from the base of the segment allows you to access information within a given segment. Accessing more than one segment at a time requires additional machine code.

The 64K limit is necessary because the 80x86 registers are 16 bits (2 bytes) wide. A single register can address only 65,536 (64K) unique memory locations.

Summary: A 16-bit pointer can address up to 65,536 locations.

A pointer variable that fully specifies a memory address needs 16 bits for the segment location and another 16 bits for the offset within the segment, a total of 32 bits. However, if you have several variables in the same general area, your program can set the segment register once and treat the pointers as smaller 16-bit quantities.

The 80x86 register CS holds the base for the code segment; the register DS holds the base for the data segment. Two other segment registers are available: the stack segment register (SS) and the extra segment register (ES). (The 80386 has additional segment registers: FS and GS.)