为什么离开做“mov esp,ebp"?在 x86 汇编中? [英] Why does leave do "mov esp,ebp" in x86 assembly?

查看:31
本文介绍了为什么离开做“mov esp,ebp"?在 x86 汇编中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据说leave 指令与:

mov esp,ebp
pop ebp

但是 mov esp,ebp 在这里做什么?这对我来说似乎无效...

But what is mov esp,ebp here for? It doesn't seem valid to me...

推荐答案

mov esp,ebp 将堆栈指针设置为基帧地址,有效地释放整个帧.(不要忘记这是 Intel 语法,目标在前.)如果你没有这样做,一旦你调用 ret,你仍然会在调用时使用被调用函数的堆栈帧功能,后果不堪设想.

mov esp,ebp sets the stack pointer to the base frame address, effectively releasing the whole frame. (Don't forget that this is Intel syntax, the destination comes first.) If you didn't do it, once you call ret, you would still be using the called function's stack frame with your calling function, with crashtastic consequences.

这篇关于为什么离开做“mov esp,ebp"?在 x86 汇编中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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