REP
Usage: REP Instruction Modifies flags: None
Repeats a string instruction the number of times specified in the count register (E)CX or until the indicated condition of the ZF flag is no longer met.
Repeat String Operation Prefix. REPE REPNE REPZ REPNZ
REP instruction ; oF3 ... [386]
REPE instruction ; oF3 ... [386]
REPZ instruction ; oF3 ... [386]
REPNE instruction ; oF2 ... [386]
REPNZ instruction ; oF2 ... [386]
Repeats the 'Instruction' ECX times which may be: CMPSB MOVSB LODSB STOSB SCASB INSB OUTSB , and other Words and dWords forms of these Mnemonics.
The 'E' and 'Z' forms of REP are equivalent (The 'E' and 'Z' Flags are one and same), standing both for 'Equal' and 'Zeroed'. The instruction is repeated ECX times, unless the Flag condition is not matched. Zero flag inicates equal or zero.
The 'NE' and 'NZ' forms of REP are also equivalent. 'N' stands for 'Not' and the instruction is repeated ECX times, unless the negative condition of the Flag is not matched. Zero flag inicates not equal or not zero.
The behavior of the REP prefix is undefined when used with non-string instructions
Example:
mov edi SourcePointer
mov ecx MAX_POSSIBLE_LENGTH
mov al 'A'
repne scasb | je Found
; Not found = repeat
Found:
.