
Instruction Set
4-193
RE PE
RE PZ
Repeat While Equal
Repeat While Zero
REPE
What It Does
REPE and REPZ repeatedly execute a single string comparisoninstruction; an unsigned
number in CX tells the microcontroller the maximum number of times to execute the
instruction. Once the instruction compares two components and finds they are not equal,
the instruction is no longer executed.
S yntax
Desc ription
REPE is a prefix that repeatedly executes a single string comparisoninstruction (CMPS or
SCAS). While CX is not 0 and ZF is 1, the microcontroller repeats the following sequence
of operations:
1. Acknowledges and services any pending interrupts
2. Executes the string comparison instruction
3. Subtracts 1 from the unsigned number in CX
4. Compares ZF with 0
When CX is 0 or ZF is 0, the microcontroller begins executing the next instruction.
REPZ is a synonym for REPE.
Form
Prefix
Opcode
Description
Clocks
Am186 Am188
REPE CMPS m8,m8
F3
A6
Find nonmatching bytes in ES:[DI] and segment:[SI]
5+22n
5+22n
REPE CMPS m16,m16
F3
A7
Find nonmatching words in ES:[DI] and segment:[SI]
5+22n
9+22n
REPE SCAS m8
F3
AE
Find non-AL byte starting at ES:[DI]
5+15n
5+15n
REPE SCAS m16
F3
AF
Find non-AX word starting at ES:[DI]
5+15n
9+15n
REPZ CMPS m8,m8
F3
A6
Find nonmatching bytes in ES:DI and segment:[SI]
5+22n
5+22n
REPZ CMPS m16,m16
F3
A7
Find nonmatching words in ES:DI and segment:[SI]
5+22n
9+22n
REPZ SCAS m8
F3
AE
Find non-AL byte starting at ES:DI
5+15n
5+15n
REPZ SCAS m16
F3
AF
Find non-AX word starting at ES:DI
5+15n
9+15n
To repeat a string comparison instruction
until CX is 0 or two components are not
equal, use REPE or its synonym, REPZ.
Both forms perform the same operation.
REPE instruction
REPZ instruction