Introduction to 48-bit Addressing
I thought the Intel (AMD, Cyrix, etc) chipset was a 32-bit processor?
It is in the sense that the register width is 32-bits, the integer math
is limited to 32-bits (64-bit result), and it has a 32-bit instruction set.
48-bit addressing refers to how the PC handles memory. The Intel processor has
three modes which control, among other things, how memory is addressed. They
are:
- Protected Mode
This is the native state of the processor. Intel recommends that this is the mode
that all new applications and operating systems should target.
- Real mode
This mode provides the programming environment of the 8086, with a few
extensions, such as being able to control aspects of the processor state.
- System Management Mode
SMM is a standard architectural feature that has been implemented beginning
with the Intel386 SL processor. This mode is entered through activation of
an external interrupt pin (SMI#), which switches the CPU to a separate
address space while saving the entire context of the CPU. SMM-specific code
may then be executed transparently to the OS and any application currently
running. This mode is how green PCs and laptops are able to enter a
sleep state.
Memory Organization
The memory on the bus of the PC is called physical memory. Each byte is
assigned a unique address, called a physical address, which ranges from
zero to a maximum of 232-1 bytes. With segmentation, however, it is
possible to have multiple, independent address spaces. Segments can be
assigned specifically for holding a program's code, data, or stack. The PC is
limited to 16,383 segments of up to 4 gigabytes each, or a total as large as
246 bytes (64 Terabytes). Each segment has a segment descriptor,
which holds its base address and size limit. Borland Pascal limits each segment
to 64K. Borland wanted to keep compatibility with the 286, which lacks 32-bit
addressing. Therefore, the indexing done by the compiler uses 16-bit operands
instead of 32-bit ones (ie, using DI instead of EDI, or SI instead of ESI).
This doesn't mean that one cannot do 32-bit indexing in Borland Pascal. It
does mean, however, that you must use assembler to do so.
32-bit Addressing
32-bit addressing is commonly referred to as the "flat" memory model. This is
a misnomer, since there isn't a mode bit or control register which turns off
the segmentation mechanism. Instead, all of the segment registers are mapped
to the same address space (usually the base of memory), and only the 32-bit
offset is used. This mode has the benefit of not needing to load segment
registers.
48-bit Addressing
48-bit addressing uses the 16-bit segment selector, and a 32-bit offset to
access memory. Because Borland Pascal allows you to allocate a selector, all
that is required to do 48-bit addressing is to set the limit to however big
the memory is. How to do this is covered later in the tutorial.