Jump to navigation Jump to search
|You are here:|
Repeat string-operation until tested-condition
- rep: repeat while equal
- repnz: repeat while nonzero
- repz: repeat while zero
Each prefix causes the associated string instruction to repeat until the count register (CX) or the zero flag (ZF) matches a tested condition.
- rep movsb
- Repeat while equal: Copy the 8-bit byte from the DS:[(E)SI] to the ES:[(E)DI] register.
- repnz scasl
- Repeat while not zero: Compare the memory byte double-word addressed in the destination register EDL, relative to the ES segment, with the contents of the EAX register.
- repz stosl
- Repeat while zero:Transfer the contents of the EAX register to the memory double-word addressed in the destination register EDL, relative to the ES segment.
- rep stosb
.text:004013E0 mov edi, offset user_id ; memory location 0x40D020 (empty) .text:004013E5 mov ecx, 20h ; size: 32 .text:004013EA mov al, 4Fh ; fill with value 0x4F .text:004013EC rep stosb ; fill 32 bytes with 0x4F at memory location 0x40D020
- rep movsd
- At 0x0040127C, the mapped location of the file (named lpBaseAddress) is moved into EDI and adjusted by some offset using var_28. Next, ECX is loaded with 0x4E, the number of DWORDs to write (movsd). Therefore, the total number of bytes is 0x4E * 4 = 312 bytes in decimal. Finally, byte_409030 is moved into ESI at 0x401287, and rep movsd copies the data at byte_409030 into the mapped file.
.text:0040127C mov edi, [ebp+lpBaseAddress] .text:0040127F add edi, [ebp+var_28] .text:00401282 mov ecx, 4Eh .text:00401287 mov esi, offset byte_409030 .text:0040128C rep movsd