6-22
INSTRUCTION SET SUMMARY
exchanged with 16 through 23. Executing this instruction twice in a row leaves the register with
the same value as before. The BSWAP instruction is useful for converting between big-endian
and little-endian data formats. This instruction also speeds execution of decimal arithmetic.
(The XCHG instruction can be used two swap the bytes in a word.)
The XADD (exchange and add) instruction swaps two operands and then stores the sum of the
two operands in the destination operand. The status flags in the EFLAGS register indicate the
result of the addition. This instruction can be combined with the LOCK prefix (refer to
LOCKAssert LOCK# Signal Prefix in Chapter 3, Instruction Set Reference of the Intel
Architecture Software Developers Manual, Volume 2) in a multiprocessing system to allow
multiple processors to execute one DO loop.
The CMPXCHG (compare and exchange) and CMPXCHG8B (compare and exchange 8 bytes)
instructions are used to synchronize operations in systems that use multiple processors. The
CMPXCHG instruction requires three operands: a source operand in a register, another source
operand in the EAX register, and a destination operand. If the values contained in the destination
operand and the EAX register are equal, the destination operand is replaced with the value of
the other source operand (the value not in the EAX register). Otherwise, the original value of the
destination operand is loaded in the EAX register. The status flags in the EFLAGS register
Table 6-2. Conditional Move Instructions
Instruction Mnemonic
Status Flag States
Condition Description
Unsigned Conditional Moves
CMOVA/CMOVNBE
(CF or ZF)=0
Above/not below or equal
CMOVAE/CMOVNB
CF=0
Above or equal/not below
CMOVNC
CF=0
Not carry
CMOVB/CMOVNAE
CF=1
Below/not above or equal
CMOVC
CF=1
Carry
CMOVBE/CMOVNA
(CF or ZF)=1
Below or equal/not above
CMOVE/CMOVZ
ZF=1
Equal/zero
CMOVNE/CMOVNZ
ZF=0
Not equal/not zero
CMOVP/CMOVPE
PF=1
Parity/parity even
CMOVNP/CMOVPO
PF=0
Not parity/parity odd
Signed Conditional Moves
CMOVGE/CMOVNL
(SF xor OF)=0
Greater or equal/not less
CMOVL/CMOVNGE
(SF xor OF)=1
Less/not greater or equal
CMOVLE/CMOVNG
((SF xor OF) or ZF)=1
Less or equal/not greater
CMOVO
OF=1
Overflow
CMOVNO
OF=0
Not overflow
CMOVS
SF=1
Sign (negative)
CMOVNS
SF=0
Not sign (non-negative)