
Instruction Set
4-148
LOOPE Loop If Equal
LOOPE
LOOPZ Loop If Zero
What It Does
LOOPE and LOOPZ repeatedly execute a sequence of instructions in which two
components are compared; an unsigned number in CX tells the microcontroller the
maximum number of times to execute the sequence. Once the microcontroller compares
two components and finds they are not equal, the loop is no longer executed.
Syntax
Description
At the bottom of a loop, LOOPE subtracts 1 from CX, and then performs a short jump to
the label at the top of the loop if the following conditions are met: CX is not 0, and the two
components that were just compared are equal. The label must be in the range from 128
bytes before LOOPE to 127 bytes after LOOPE. The microcontroller performs the following
sequence of operations:
1. Executes the instructions between
label and LOOPE label.
2. Subtracts 1 from the unsigned number in CX.
3. Performs a short jump to the label if CX is not 0 and the Zero Flag (ZF) is 1.
When CX is 0 or ZF is 0, the microcontroller begins executing the instruction following
LOOPE. LOOPZ is a synonym for LOOPE.
Operation It Performs
Form
Opcode
Description
Clocks
Am186 Am188
LOOPE
rel8
E1
cb
Decrement count; jump short if CX
≠
0 and ZF=1
16,6
16,6
LOOPZ
rel8
E1
cb
Decrement count; jump short if CX
≠
0 and ZF=1
16,6
16,6
LOOPE
label
LOOPZ
label
To repeat a loop until CX is 0 or two
components compared inside the
loop are not equal, use LOOPE or its
synonym, LOOPZ. Both forms
perform the same operation.
/* decrement counter */
CX = CX - 1;
if ((CX != 0) && (ZF == 1))
/* equal */
{
/* extend sign of label */
if (
label < 0)
displacement = 0xFF00 |
label;
else
displacement = 0x00FF &
label;
/* loop */
IP = IP + displacement;
}
Содержание Am186 Series
Страница 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Страница 10: ...Table of Contents x...
Страница 18: ...Programming 1 8...
Страница 40: ...Instruction Set Listing 3 14...