6-38
INSTRUCTION SET SUMMARY
Table 6-4 shows the mnemonics for the Jcc instructions and the conditions being tested for each
instruction. The condition code mnemonics are appended to the letter J to form the mnemonic
for a Jcc instruction. The instructions are divided into two groups: unsigned and signed condi-
tional jumps. These groups correspond to the results of operations performed on unsigned and
signed integers, respectively. Those instructions listed as pairs (for example, JA/JNBE) are alter-
nate names for the same instruction. The assembler provides these alternate names to make it
easier to read program listings.
The JCXZ and JECXZ instructions test the CX and ECX registers, respectively, instead of one
or more status flags. Refer to Section 6.9.2.3., Jump If Zero Instructions for more informa-
tion about these instructions.
6.9.2.2.LOOP INSTRUCTIONS
The LOOP, LOOPE (loop while equal), LOOPZ (loop while zero), LOOPNE (loop while not
equal), and LOOPNZ (loop while not zero) instructions are conditional jump instructions that
use the value of the ECX register as a count for the number of times to execute a loop. All the
loop instructions decrement the count in the ECX register each time they are executed and termi-
nate a loop when zero is reached. The LOOPE, LOOPZ, LOOPNE, and LOOPNZ instructions
also accept the ZF flag as a condition for terminating the loop before the count reaches zero.
The LOOP instruction decrements the contents of the ECX register (or the CX register, if the
address-size attribute is 16), then tests the register for the loop-termination condition. If the
count in the ECX register is non-zero, program control is transferred to the instruction address
specified by the destination operand. The destination operand is a relative address (that is, an
offset relative to the contents of the EIP register), and it generally points to the first instruction
in the block of code that is to be executed in the loop. When the count in the ECX register
reaches zero, program control is transferred to the instruction immediately following the
LOOP instruction, which terminates the loop. If the count in the ECX register is zero when the
LOOP instruction is first executed, the register is pre-decremented to FFFFFFFFH, causing the
loop to be executed 2
32
times.
The LOOPE and LOOPZ instructions perform the same operation (they are mnemonics for the
same instruction). These instructions operate the same as the LOOP instruction, except that they
also test the ZF flag. If the count in the ECX register is not zero and the ZF flag is set, program
control is transferred to the destination operand. When the count reaches zero or the ZF flag is
clear, the loop is terminated by transferring program control to the instruction immediately
following the LOOPE/LOOPZ instruction.
The LOOPNE and LOOPNZ instructions (mnemonics for the same instruction) operate the
same as the LOOPE/LOOPPZ instructions, except that they terminate the loop if the ZF flag
is set.
6.9.2.3.JUMP IF ZERO INSTRUCTIONS
The JECXZ (jump if ECX zero) instruction jumps to the location specified in the destination
operand if the ECX register contains the value zero. This instruction can be used in combination
with a loop instruction (LOOP, LOOPE, LOOPZ, LOOPNE, or LOOPNZ) to test the ECX
register prior to beginning a loop. As described in Section 6.9.2.2., Loop Instructions, the loop