Intel 64 and IA-32 Architectures Software Developers Manual Volume 1, Basic Architecture

7-4 Vol. 1
PROGRAMMING WITH GENERAL-PURPOSE INSTRUCTIONS
to/from Control Registers” and “MOV—Move to/from Debug Registers” in Chapter 3,
“Instruction Set Reference, A-M,” of the Intel® 64 and IA-32 Architectures Software
Developer’s Manual, Volume 2A, for information on moving data to and from the
control and debug registers.)
The MOV instruction cannot move data from one memory location to another or from
one segment register to another segment register. Memory-to-memory moves are
performed with the MOVS (string move) instruction (see Section 7.3.9, “String Oper-
ations”).
Conditional move instructions — The CMOVcc instructions are a group of instruc-
tions that check the state of the status flags in the EFLAGS register and perform a
move operation if the flags are in a specified state. These instructions can be used to
move a 16-bit or 32-bit value from memory to a general-purpose register or from
one general-purpose register to another. The flag state being tested is specified with
a condition code (cc) associated with the instruction. If the condition is not satisfied,
a move is not performed and execution continues with the instruction following the
CMOVcc instruction.
Table 7-2 shows mnemonics for CMOVcc instructions and the conditions being tested
for each instruction. The condition code mnemonics are appended to the letters
“CMOV” to form the mnemonics for CMOVcc instructions. The instructions listed in
Table 7-2 as pairs (for example, CMOVA/CMOVNBE) are alternate names for the
same instruction. The assembler provides these alternate names to make it easier to
read program listings.
CMOVcc instructions are useful for optimizing small IF constructions. They also help
eliminate branching overhead for IF statements and the possibility of branch mispre-
dictions by the processor.
Table 7-1. Move Instruction Operations
Type of Data Movement Source Destination
From memory to a register Memory location General-purpose register
Memory location Segment register
From a register to memory General-purpose register Memory location
Segment register Memory location
Between registers General-purpose register General-purpose register
General-purpose register Segment register
Segment register General-purpose register
General-purpose register Control register
Control register General-purpose register
General-purpose register Debug register
Debug register General-purpose register
Immediate data to a register Immediate General-purpose register
Immediate data to memory Immediate Memory location