
Chapter 3: General-Purpose Programming
37
24593—Rev. 3.09—September 2003
AMD 64-Bit Technology
Repeated String Operations.
With the exception of I/O string
instructions, all string operations use rSI as the source-operand
pointer and rDI as the destination-operand pointer. I/O string
instructions use rDX to specify the input-port or output-port
number. For repeated string operations (those preceded with a
repeat-instruction prefix), the rSI and rDI registers are
incremented or decremented as the string elements are moved
from the source location to the destination. Repeat-string
operations also use rCX to hold the string length, and
decrement it as data is moved from one location to the other.
Stack Operations.
Stack operations make implicit use of the rSP
register, and in some cases, the rBP register. The rSP register is
used to hold the top-of-stack pointer (or simply, stack pointer).
rSP is decremented when items are pushed onto the stack, and
incremented when they are popped off the stack. The ENTER
and LEAVE instructions use rBP as a stack-frame base pointer.
Here, rBP points to the last entry in a data structure that is
passed from one block-structured procedure to another.
The use of rSP or rBP as a base register in an address
calculation implies the use of SS (stack segment) as the default
segment. Using any other GPR as a base register without a
segment-override prefix implies the use of the DS data segment
as the default segment.
The push all and pop all instructions (PUSHA, PUSHAD, POPA,
POPAD) implicitly use all of the GPRs.
CPUID Information.
The CPUID instruction makes implicit use of
the EAX, EBX, ECX, and EDX registers. Software loads a
function code into EAX, executes the CPUID instruction, and
then reads the associated processor-feature information in
EAX, EBX, ECX, and EDX.
3.1.4
Flags Register
Figure 3-5 on page 38 shows the 64-bit RFLAGS register and the
flag bits visible to application software. Bits 15–0 are the
FLAGS register (accessed in legacy real and virtual-8086
modes), bits 31–0 are the EFLAGS register (accessed in legacy
protected mode and compatibility mode), and bits 63–0 are the
RFLAGS register (accessed in 64-bit mode). The name
rFLAGS
refers to any of the three register widths, depending on the
current software context.