lea指令如何与esp交互? [英] How does the lea instruction interact with esp?

查看:150
本文介绍了lea指令如何与esp交互?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到例如"lea eax,[ebp-120]"从本质上讲是

I read that for example "lea eax, [ebp - 120]" essentially means

mov    eax, ebp
sub     eax, 120

以esp处于ebp-200的示例为例,然后再在函数中使用

Given the example that the esp is at ebp-200, then later in the function

lea eax, [ebp - 120]
push eax
call xyz

这是否意味着将ebp-120处的值加载到eax寄存器中,然后将这4字节的有效值压入堆栈?还是意味着esp进一步递减120,从而创建了一个从ebp-200到ebp-320的缓冲区,而esp现在位于ebp-320?

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?

推荐答案

什么是LEA指令的目的是什么?

lea看起来比mov更花哨,但实际上它只是mov的一部分:mov计算地址并取消引用内存,lea只是计算地址.

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.

在您的示例中,eax接收到的eem存储在 中的值减去了120,而不是存储在地址中的 存储在ebp中的值减去了120.该值继续被推入堆栈.如果此程序集对应于C代码,则eax/stack将包含指向某个变量的指针.

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.

lea和esp之间没有直接交互.除非esp是lea的论据之一,否则lea不会读取或修改esp.

There is no direct interaction between lea and esp. Unless esp is one of lea's arguments, lea does not read or modify esp.

这篇关于lea指令如何与esp交互?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆