In other words, is there any case I might need this instruction?
From Intel Instructions Manual, this is what the instruction do:
Load (E)CX bytes from DS:[(E)SI] to AL.
Take the following example in NASM:
section .data
src: db 0, 1, 2, 3
section .code
mov esi, src
mov ecx, 4
rep lodsb ; mov al, byte[esi + ecx -1]; ecx++
While the instruction rep lodsb
is executing, I don't have any control over the value loaded in al
. All I can do is waiting, until the instruction terminates to get the last value of al
, which, of course I can get directly, without the loop.
The same question goes for the rest of the family: REP LODS AX
, REP LODS EAX
and REP LODS RAX
.
Reading from memory can have side effects in some cases. For example, this can happen if the memory is mapped to hardware registers. The exact side effect would depend on the hardware. So rep lodsb
can be useful in very rare cases where you need the side-effect to happen, but don't need the values that were read.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With