REP
REPEAT
REP
REPE/REPZ
REPE/REPZ
REPEAT WHILE EQUAL/
REPEAT
WHILE ZERO
REPNE/REPNZREPNE/REPNZ
REPEAT WHILE NOT EQUAL/
REPEAT
WHILE NOT ZERO
Description:
REP/REPE/REPZ/REPNE/REPNZ
Repeat, Repeat While Equal, Repeat While
Zero, Repeat While Not Equal and Repeat
While Not
Zero are mnemonics for two forms
of the prefix byte that controls subsequent
string instruction repetition. The different
mnemonics are provided to improve program
clarity. The repeat prefixes do not affect the
flags.
REP
is
used in conjunction with the MOVS
(Move String) and STOS (Store String)
instructions
and
is
interpreted as
"repeat
while
not
end-of-string" (CX not 0). REPE and
REPZ operate identically and are physically
the same prefix byte as
REP. These instruc-
tions are used with the
CMPS (Compare
String) and SCAS (Scan String) instructions
and require
ZF
(posted by these instructions)
to
be
set before initiating the next repetition.
REPNE and
REPNZ
are mnemonics for the
same prefix byte. These instructions function
the same as
REPE
and REPZ except that the
zero flag must be cleared or the repetition
is
terminated. ZF does not need to be initial-
ized
before executing the repeated string
instruction.
Repeated string sequences are interruptable;
the processor will recognize the interrupt
before processing the next string element.
System interrupt processing
is
not affected in
any way.
Upon return from the interrupt, the
repeated operation
is
resumed from the point
of
interruption. However, execution does
not
resume properly if a second or third prefix
(i.e., segment override
or
LOCK) has been
specified in addition to any
of
the repeat
prefixes.
At
interrupt time, the processor
"remembers"
only the prefix that immediately
precedes the string instruction. After returning
from the interrupt, processing resumes, but
any additional prefixes specified are not in
effect.
If
more than one prefix must
be
used
with a string instruction, interrupts may be
disabled for the duration
of
the repeated exe-
cution. However, this will not prevent a non-
maskable interrupt from being recognized.
Also, the time
that
the system
is
unable to
respond to interrupts may be unacceptable if
long strings are being processed.
2-136