
Instruction Set
4-146
LOOP
Loop While CX Register Is Not Zero
LOOP
What It Does
LOOP repeatedly executes a sequence of instructions; an unsigned number in CX tells the
microcontroller how many times to execute the sequence.
Syntax
Description
At the bottom of a loop, LOOP subtracts 1 from CX, and then performs a short jump to the
label at the top of the loop if CX is not 0. The label must be in the range from 128 bytes
before LOOP to 127 bytes after LOOP. The microcontroller performs the following sequence
of operations:
1. Executes the instructions between
label and LOOP label.
2. Subtracts 1 from the unsigned number in CX.
3. Performs a short jump to the label if CX is not 0.
When CX is 0, the microcontroller begins executing the instruction following LOOP.
Operation It Performs
Flag Settings After Instruction
Form
Opcode
Description
Clocks
Am186 Am188
LOOP
rel8
E2
Decrement count; jump short if CX
≠
0
16,6
16,6
LOOP
label
/* decrement counter */
CX = CX - 1;
if (CX != 0)
{
/* extend sign of label */
if (
label < 0)
displacement = 0xFF00 |
label;
else
displacement = 0x00FF &
label;
/* loop */
IP = IP + displacement;
}
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
Processor Status
Flags Register
reserved
OF DF
IF TF SF ZF
AF
PF
CF
? = undefined; – = unchanged
–
–
–
–
–
– res – res – res –
Содержание 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...