movl / leal, difference in this case
This question already has an answer here:
They are not similar.
mov ebx, (esp)
lea ecx, (esp)
(in regular assembler, not gas style). The first loads ebx
with the contents of esp
. The second loads ecx
with esp
itself. The similar "regular" expression would have been
mov ecx, esp
but using lea
you can immediately add a constant, a register, or both to ecx
. Eg,
lea ecx, (esp+4*eax+10h)
sets ecx
to esp + 4*eax + 10h
-- using 'mov', you would have to add these with more instructions.
上一篇: movl和leal指令之间的区别