Reputation: 513
I found this code:
lea 0x10(%edi),%esi
mov %esi,0x4(%edi)
but I really don't understand this combination.
Upvotes: 0
Views: 691
Reputation: 18217
The use of lea
vs. mov
in x86 assembly is the same kind of thing as, in C/C++, saying:
char *ptr;
...
ptr = &val;
vs.
char *ptr;
...
*ptr = val;
lea
calculates the address, mov
(or other instructions with memory operands) dereferences (accesses) it.
So lea
does in x86 assembly what's called "pointer arithmetics" in C/C++ - no memory access is involved.
Upvotes: 0
Reputation: 224844
mov
supports at most one memory operand. Anyway, your example appears to have different semantics (as mentioned by @zch below).You can grab a copy of the Intel Software Developers Manuals and read all you want about it.
Edit: Regarding your questions "what value is written in %esi ? lea is calculation the offset? of which address?"
esi
gets edi + 0x10
; that's what that 0x10(%edi)
means. lea
stands for "load effective address". That is, it interprets edi
as a pointer, and increments it by 0x10, storing the result in esi
.
Upvotes: 2