User Guide
60 General-Purpose Programming
AMD64 Technology 24592—Rev. 3.15—November 2009
Unlike the unconditional jump (JMP), conditional jump instructions have only two forms—near
conditional jumps and short conditional jumps. To create a far-conditional-jump code sequence
corresponding to a high-level language statement like:
IFA=BTHEN GOTO FarLabel
where FarLabel is located in another code segment, use the opposite condition in a conditional short
jump before the unconditional far jump. For example:
cmp A,B ; compare operands
jne NextInstr ; continue program if not equal
jmp far ptr WhenNE ; far jump if operands are equal
NextInstr: ; continue program
Three special conditional jump instructions use the rCX register instead of flags. The JCXZ, JECXZ,
and JRCXZ instructions check the value of the CX, ECX, and RCX registers, respectively, and pass
control to the target instruction when the value of rCX register reaches 0. These instructions are often
used to control safe cycles, preventing execution when the value in rCX reaches 0.
Loop
• LOOPcc—Loop if condition
The LOOPcc instructions include LOOPE, LOOPNE, LOOPNZ, and LOOPZ. These instructions
decrement the rCX register by 1 without changing any flags, and then check to see if the loop condition
is met. If the condition is met, the program jumps to the specified target code.
LOOPE and LOOPZ are synonyms. Their loop condition is met if the value of the rCX register is non-
zero and the zero flag (ZF) is set to 1 w hen the instruction starts. LOOPNE and LOOPNZ are also
synonyms. Their loop condition is met if the value of the rCX register is non-zero and the ZF f lag is
cleared to 0 when the instruction starts. LOOP, unlike the other mnemonics, does not check the ZF
flag. Its loop condition is met if the value of the rCX register is non-zero.
Call
• CALL—Procedure Call
The CALL instruction performs a call to a procedure whose address is specified in the operand. The
return address is placed on the stack by the CALL, and points to the instruction immediately following
JGE
JNL
SF=OF
Jump near if greater or equal
Jump near if not less
JNG
JLE
ZF=1orSF<>OF
Jump near if not greater
Jump near if less or equal
JNLE
JG
ZF = 0 and SF = OF
Jump near if not less or equal
Jump near if greater
Table 3-6. rFLAGS for Jcc Instructions (continued)
Mnemonic Required Flag State Description