How does the lea instruction interact with esp?
I read that for example "lea eax, [ebp - 120]" essentially means
mov eax, ebp
sub eax, 120
Given the example that the esp is at ebp-200, then later in the function
lea eax, [ebp - 120]
push eax
call xyz
would this mean that the value at ebp-120 is loaded into the eax register, then this 4 byte vaule is pushed onto the stack? Or does it mean that the esp is decremented further by 120, thereby creating a buffer from ebp-200 to ebp-320, with esp now at ebp-320?
What's the purpose of the LEA instruction?
lea looks more fancy than mov, but in reality it only does part of what mov does: mov calculates the address and dereferences memory, lea just calculates the address.
In your example, eax receives the value stored in ebp with 120 subtracted, not the value stored at the address which is stored in ebp with 120 subtracted. This value proceeds to be pushed onto the stack. If this assembly corresponded to C code, eax/stack would contain a pointer to some variable.
There is no direct interaction between lea and esp. Unless esp is one of lea's arguments, lea does not read or modify esp.
链接地址: http://www.djcxy.com/p/72392.html上一篇: 什么是x86最快的虚拟机设计?
下一篇: lea指令如何与esp交互?