User Guide
General-Purpose Programming 29
24592—Rev. 3.15—November 2009 AMD64 Technology
Default Operand Size. For most instructions, the default operand size in 64-bit mode is 32 bits. To
access 16-bit operand sizes, an instruction must contain an operand-size prefix (66h), as described in
Section 3.2.2, “Operand Sizes and Overrides,” on page 39. To access the full 64-bit operand size, most
instructions must contain a REX prefix.
For details on operand size, see Section 3.2.2, “Operand Sizes and Overrides,” on page 39.
Byte Registers. 64-bit mode provides a uniform set of low-byte, low-word, low-doubleword, and
quadword registers that is well-suited for register allocation by compilers. Access to the four new low-
byte registers in the legacy-GPR range (SIL, DIL, BPL, SPL), or any of the low-byte registers in the
extended registers (R8B–R15B), requires a REX instruction prefix. However, the legacy high-byte
registers (AH, BH, CH, DH) are not accessible when a REX prefix is used.
Zero-Extension of 32-Bit Results. As Figure 3-3 on page 27 and Figure 3-4 on page 28 show, when
performing 32-bit operations with a GPR destination in 64-bit mode, the processor zero-extends the
32-bit result into the full 64-bit destination. 8-bit and 16-bit operations on GPRs preserve all unwritten
upper bits of the destination GPR. This is consistent with legacy 16-bit and 32-bit semantics for
partial-width results.
Software should explicitly sign-extend the results of 8-bit, 16-bit, and 32-bit operations to the full 64-
bit width before using the results in 64-bit address calculations.
The following four code examples show how 64-bit, 32-bit, 16-bit, and 8-bit ADDs work. In these
examples, “48” is a REX prefix specifying 64-bit operand size, and “01C3” and “00C3” are the opcode
and ModRM bytes of each instruction (see “Opcode Syntax” in Volume 3 for details on the opcode and
ModRM encoding).
Example 1: 64-bit Add:
Before:RAX =0002_0001_8000_2201
RBX =0002_0002_0123_3301
48 01C3 ADD RBX,RAX ;48 is a REX prefix for size.
Result:RBX = 0004_0003_8123_5502
Example 2: 32-bit Add:
Before:RAX = 0002_0001_8000_2201
RBX = 0002_0002_0123_3301
01C3 ADD EBX,EAX ;32-bit add
Result:RBX = 0000_0000_8123_5502
(32-bit result is zero extended)
Example 3: 16-bit Add:
Before:RAX = 0002_0001_8000_2201
RBX = 0002_0002_0123_3301