In this statement, is the value pointed to by edi
the one that compares byte by byte, with the value pointed to by eax
?
rep scasb byte [edi]
See https://www.felixcloutier.com/x86/scas:scasb:scasw:scasd and https://www.felixcloutier.com/x86/rep:repe:repz:repne:repnz .
But note that rep scasb
is not encodeable .
With scasb
, the two rep
prefixes are repe
and repne
. The prefix byte that means rep
with stos
/ movs
means repe
with scas
and cmps
.
REPE keeps repeating while ECX.=0 and ZF==1. ie repeat while equal.
repne scasb
implements memchr
: find the first occurrence (if any) in a fixed-size buffer.
repe scasb
finds the first byte,= AL. or stops at the limit set by ECX. So it's a bit like strspn
, but still for an explicit size buffer, not a zero terminated C-string.
rep
means repeat until ecx
is 0. scasb
means 'scan byte', ie: compare al
with the byte at memory location edi
, increment edi
and decrement ecx
.
What this means in effect is that before this line is run ecx
has been set to a value that dictates how many times the rep
will run for and if the characters match the zero flag ZF
(which is also used for determining equality, hence why je
and jz
are equivalent) will be set.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.