IBM PC Architecture : Memory Addressing
"Standard" addresses (i.e. not "extended") are composed of "segment" and "offset" components. Segment addresses are "paragraph" addresses; offset addresses are byte distances from some paragraph boundary. As implied by the preceding, memory is divided into paragraphs; each paragraph is composed of 16 (10 hex.) bytes.
16-bit Addressing - Precursor to Intel 8086
Prior to the Intel 8086 processor (and the IBM PC, which ensured its popularity), Intel produced a microprocessor called the 8080 which formed the basis for a common generic microcomputer Operating System, CP/M. This processor had a 16-bit address bus and thus supported a maximum of 64K (bytes) of memory.
The 8080's 16-bit address was a "real" address; that is, no conversion was required to transform the 16-bit address value into a "real" or physical memory byte-cell address.
Addressing 1 Megabyte - IBM PC and the 8086
By combining a 16-bit paragraph segment address and a 16-bit byte offset address, a resultant 20-bit address is achieved enabling access to up to 1 Megabyte of memory.
Paragraphs
- Memory within an IBM PC system is addressable at the byte level. However, bytes of memory are grouped into blocks of 16 bytes, called paragraphs. Each paragraph has its own paragraph address. For example, paragraph address 312 (decimal) / 138(hex.) corresponds to a collection of bytes beginning at byte address 4992(decimal) / 1380(hex.)
Segments
- Segments are blocks of (up to) 64K bytes used for instruction space, or data space, or some combination of the two. Segment addresses are addresses which may be used the initial memory location for a segment. Segment addresses are always 16-bit paragraph addresses.
Offsets
- Offsets are distances, expressed as a number of bytes, from the beginning of some segment. Offset addresses are always 16-bit byte addresses.
Combining Segments and Offsets
- When expressed in hexadecimal, addresses for the IBM PC are normally written as a segment value followed by a colon, followed by an offset value, for example, 13A7:5092(hex). Since the segment portion refers to a paragraph address which needs to be multiplied by 10 (or 16 decimal) to be converted into a byte address and since the offset is a distance from this segment location, the real memory address represented by the address 13A7:5092 is 13A70+5092 or 18B02 (hex.). The resultant real memory address is a 20-bit value, giving the IBM PC a 1 Megabyte addressible memory space.
Beyond 1 Megabyte - IBM AT and the 80x86+ family
The 80286 Real and Protected Modes
- Real Mode is equivalent to the standard memory addressing just described for the 8086
- Protected Mode ("Protected Virtual Address Mode" to use its full name) permits addresses of up to 24-bits in length (16 Megabytes) but these physical addresses are not directly accessible by programs. Furthermore, program accessible memory is "virtual" with up to 1 Gigabyte of addressable space (30-bit address). In "protected" mode the segment address is not a real memory address; instead, this field becomes a 16-bit "segment selector". The top 14 bits of the "segment selector" provide an extension to the 16-bit offset address to form the virtual 30-bit address. Associated with each "segment selector" is an 8-byte "segment descriptor" record; all "segment descriptors" for a particular program are contained in a single 64K segment of memory, thus permitting a maximum of 8192 "segment selectors"/"segment descriptors" at any time. The "segment descriptor" contains a 24-bit real memory address field for the segment
The Extended Addresses of the 80386 (and beyond)
- Except for registers used for segment addresses (or segment selectors) all registers where expanded to 32 bits by the addition of 16 high-order bits to each register. When used as offset addresses, these registers can provide addressing for up to 4 Gigabytes of memory (in something called the "linear model").
- Note that "real mode" is still limited to 64K-byte segments (16-bit offsets) and a maximum addressable space of 1 Megabyte.
- In "protected mode" the 14-bit address in the "segment selector" does not contain a real/virtual memory segment address; instead it contains the index of a table of 32-bit segment addresses. A 14-bit index implies up to 16K segments and since each segment can now have an offset of 32-bits (4 Gigabytes of address space), an upper limit of 64 Terabytes is theoretically possible (i.e. the equivalent of a 46-bit address space). This limit is not currently supported by any existing Operating System or software.