User Guide
18 Memory Model
AMD64 Technology 24592—Rev. 3.15—November 2009
2.2.5 RIP-Relative Addressing
RIP-relative addressing—that is, addressing relative to the 64-bit instruction pointer (also called
program counter)—is available in 64-bit mode. The effective address is formed by adding the
displacement to the 64-bit RIP of the next instruction.
In the legacy x86 architecture, addressing relative to the instruction pointer (IP or EIP) is available
only in control-transfer instructions. In the 64-bit mode, any instruction that uses ModRM addressing
(see “ModRM and SIB Bytes” in Volume 3) can use RIP-relative addressing. The feature is
particularly useful for addressing data in position-independent code and for code that addresses global
data.
Programs usually have many references to data, especially global data, that are not register-based. To
load such a program, the loader typically selects a location for the program in memory and then adjusts
the program’s references to global data based on the load location. RIP-relative addressing of data
makes this adjustment unnecessary.
Range of RIP-Relative Addressing. Without RIP-relative addressing, instructions encoded with a
ModRM byte address memory relative to zero. With RIP-relative addressing, instructions with a
ModRM byte can address memory relative to the 64-bit RIP using a signed 32-bit displacement. This
provides an offset range of ±2 GBytes from the RIP.
Effect of Address-Size Prefix on RIP-Relative Addressing. RIP-relative addressing is enabled by
64-bit mode, not by a 64-bit address-size. Conversely, use of the address-size prefix does not disable
Table 2-1. Address-Size Prefixes
Operating Mode
Default
Address
Size (Bits)
Effective
Address Size
(Bits)
Address-
Size Prefix
(67h)
1
Required?
Long Mode
64-Bit Mode 64
64 no
32 yes
Compatibility Mode
32
32 no
16 yes
16
32 yes
16 no
Legacy Mode
(Protected, Virtual-8086, or Real
Mode)
32
32 no
16 yes
16
32 yes
16 no
Note:
1. “No” indicates that the default address size is used.