3-607
INSTRUCTION SET REFERENCE
REP/REPE/REPZ/REPNE
/REPNZ—Repeat String Operation Prefix
(Continued)
Operation
IF AddressSize = 16
THEN
use CX for CountReg;
ELSE (* AddressSize = 32 *)
use ECX for CountReg;
FI;
WHILE CountReg
?
0
DO
service pending interrupts (if any);
execute associated string instruction;
CountReg
<
CountReg – 1;
IF CountReg = 0
THEN exit WHILE loop
FI;
IF (repeat prefix is REPZ or REPE) AND (ZF=0)
OR (repeat prefix is REPNZ or REPNE) AND (ZF=1)
THEN exit WHILE loop
FI;
OD;
Flags Affected
None; however, the CMPS and SCAS instructions do set the status flags in the EFLAGS register.
Exceptions (All Operating Modes)
None; however, exceptions can be generated by the instruction a repeat prefix is associated with.