background image

3-18 Vol. 1

BASIC EXECUTION ENVIRONMENT

For a detailed description of these flags: see Chapter 3, â€śProtected-Mode Memory Management,” in the Intel® 64 
and IA-32 Architectures Software Developer’s Manual, Volume 3A.
 

3.4.3.4  

RFLAGS Register in 64-Bit Mode

In 64-bit mode, EFLAGS is extended to 64 bits and called RFLAGS. The upper 32 bits of RFLAGS register is 
reserved. The lower 32 bits of RFLAGS is the same as EFLAGS.

3.5 INSTRUCTION 

POINTER

The instruction pointer (EIP) register contains the offset in the current code segment for the next instruction to be 
executed. It is advanced from one instruction boundary to the next in straight-line code or it is moved ahead or 
backwards by a number of instructions when executing JMP, Jcc, CALL, RET, and IRET instructions. 
The EIP register cannot be accessed directly by software; it is controlled implicitly by control-transfer instructions 
(such as JMP, Jcc, CALL, and RET), interrupts, and exceptions. The only way to read the EIP register is to execute a 
CALL instruction and then read the value of the return instruction pointer from the procedure stack. The EIP 
register can be loaded indirectly by modifying the value of a return instruction pointer on the procedure stack and 
executing a return instruction (RET or IRET). See Section 6.2.4.2, â€śReturn Instruction Pointer.”
All IA-32 processors prefetch instructions. Because of instruction prefetching, an instruction address read from the 
bus during an instruction load does not match the value in the EIP register. Even though different processor gener-
ations use different prefetching mechanisms, the function of the EIP register to direct program flow remains fully 
compatible with all software written to run on IA-32 processors.

3.5.1 

Instruction Pointer in 64-Bit Mode

In 64-bit mode, the RIP register becomes the instruction pointer. This register holds the 64-bit offset of the next 
instruction to be executed. 64-bit mode also supports a technique called RIP-relative addressing. Using this tech-
nique, the effective address is determined by adding a displacement to the RIP of the next instruction.

3.6 

OPERAND-SIZE AND ADDRESS-SIZE ATTRIBUTES

When the processor is executing in protected mode, every code segment has a default operand-size attribute and 
address-size attribute. These attributes are selected with the D (default size) flag in the segment descriptor for the 
code segment (see Chapter 3, “Protected-Mode Memory Management,” in the Intel® 64 and IA-32 Architectures 
Software Developer’s Manual, Volume 3A)
. When the D flag is set, the 32-bit operand-size and address-size attri-
butes are selected; when the flag is clear, the 16-bit size attributes are selected. When the processor is executing 
in real-address mode, virtual-8086 mode, or SMM, the default operand-size and address-size attributes are always 
16 bits.
The operand-size attribute selects the size of operands. When the 16-bit operand-size attribute is in force, oper-
ands can generally be either 8 bits or 16 bits, and when the 32-bit operand-size attribute is in force, operands can 
generally be 8 bits or 32 bits.
The address-size attribute selects the sizes of addresses used to address memory: 16 bits or 32 bits. When the 16-
bit address-size attribute is in force, segment offsets and displacements are 16 bits. This restriction limits the size 
of a segment to 64 KBytes. When the 32-bit address-size attribute is in force, segment offsets and displacements 
are 32 bits, allowing up to 4 GBytes to be addressed.
The default operand-size attribute and/or address-size attribute can be overridden for a particular instruction by 
adding an operand-size and/or address-size prefix to an instruction. See Chapter 2, â€śInstruction Format,” in the 
Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2A. The effect of this prefix applies only 
to the targeted instruction.
Table 3-4 shows effective operand size and address size (when executing in protected mode or compatibility mode) 
depending on the settings of the D flag and the operand-size and address-size prefixes.