Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture

Vol. 1 3-31
BASIC EXECUTION ENVIRONMENT
the possible ways that these components can be combined to create an effective
address in the selected segment.
The uses of general-purpose registers as base or index components are restricted in
the following manner:
The ESP register cannot be used as an index register.
When the ESP or EBP register is used as the base, the SS segment is the default
segment. In all other cases, the DS segment is the default segment.
The base, index, and displacement components can be used in any combination, and
any of these components can be NULL. A scale factor may be used only when an
index also is used. Each possible combination is useful for data structures commonly
used by programmers in high-level languages and assembly language.
The following addressing modes suggest uses for common combinations of address
components.
Displacement A displacement alone represents a direct (uncomputed) offset
to the operand. Because the displacement is encoded in the instruction, this form
of an address is sometimes called an absolute or static address. It is commonly
used to access a statically allocated scalar operand.
Base A base alone represents an indirect offset to the operand. Since the
value in the base register can change, it can be used for dynamic storage of
variables and data structures.
Base + Displacement A base register and a displacement can be used
together for two distinct purposes:
As an index into an array when the element size is not 2, 4, or 8 bytes—The
displacement component encodes the static offset to the beginning of the
array. The base register holds the results of a calculation to determine the
offset to a specific element within the array.
To access a field of a record: the base register holds the address of the
beginning of the record, while the displacement is a static offset to the field.
Figure 3-11. Offset (or Effective Address) Computation
Offset = Base + (Index * Scale) + Displacement
Base
EAX
EBX
ECX
EDX
ESP
EBP
ESI
EDI
EAX
EBX
ECX
EDX
EBP
ESI
EDI
1
None
2
4
8
8-bit
16-bit
32-bit
Index Scale Displacement
*
++