Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture
3-32 Vol. 1
BASIC EXECUTION ENVIRONMENT
An important special case of this combination is access to parameters in a
procedure activation record. A procedure activation record is the stack frame
created when a procedure is entered. Here, the EBP register is the best choice
for the base register, because it automatically selects the stack segment. This is
a compact encoding for this common function.
• (Index ∗ Scale) + Displacement ⎯ This address mode offers an efficient way
to index into a static array when the element size is 2, 4, or 8 bytes. The
displacement locates the beginning of the array, the index register holds the
subscript of the desired array element, and the processor automatically converts
the subscript into an index by applying the scaling factor.
• Base + Index + Displacement ⎯ Using two registers together supports either
a two-dimensional array (the displacement holds the address of the beginning of
the array) or one of several instances of an array of records (the displacement is
an offset to a field within the record).
• Base + (Index ∗ Scale) + Displacement ⎯ Using all the addressing
components together allows efficient indexing of a two-dimensional array when
the elements of the array are 2, 4, or 8 bytes in size.
3.7.5.1 Specifying an Offset in 64-Bit Mode
The offset part of a memory address in 64-bit mode can be specified directly as a
static value or through an address computation made up of one or more of the
following components:
• Displacement — An 8-bit, 16-bit, or 32-bit value.
• Base — The value in a 32-bit (or 64-bit if REX.W is set) general-purpose register.
• Index — The value in a 32-bit (or 64-bit if REX.W is set) general-purpose
register.
• Scale factor — A value of 2, 4, or 8 that is multiplied by the index value.
The base and index value can be specified in one of sixteen available general-purpose
registers in most cases. See Chapter 2, “Instruction Format,” in the Intel® 64 and
IA-32 Architectures Software Developer’s Manual, Volume 3A.
The following unique combination of address components is also available.
• RIP + Displacement ⎯ In 64-bit mode, RIP-relative addressing uses a signed
32-bit displacement to calculate the effective address of the next instruction by
sign-extend the 32-bit value and add to the 64-bit value in RIP.
3.7.6 Assembler and Compiler Addressing Modes
At the machine-code level, the selected combination of displacement, base register,
index register, and scale factor is encoded in an instruction. All assemblers permit a
programmer to use any of the allowable combinations of these addressing compo-
nents to address operands. High-level language compilers will select an appropriate