ret指令会导致esp寄存器加4吗? [英] Does ret instruction cause esp register added by 4?

查看:287
本文介绍了ret指令会导致esp寄存器加4吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

"ret"指令是否导致"esp"寄存器加4?

Does "ret" instruction cause "esp" register added by 4?

推荐答案

是的,它执行

pop eip

您可以使用

mov eax, [esp]
jmp eax

避免它.

这正是ret的作用.例如,jmp rel_offet就是隐藏的add eip, offset,或者jmp absolute_offsetmov eip, absolute_offset.当然,处理器处理它们的方式有所不同,但是从程序员的角度来看,这都是发生了.

It's exactly what ret does. For example, jmp rel_offet is nothing than a hidden add eip, offset, or jmp absolute_offset is mov eip, absolute_offset. Sure there are differences in the way the processor treats them, but from programmer's point of view it's all that happens.

此外,还有一种特殊形式的ret:ret imm8还将此imm8值添加到esp:例如,__stdcall函数使用它来从堆栈中丢弃其参数.更不用说在16位模式下使用的retf版本,该版本也会从堆栈中弹出cs.

Also, there is a special form of ret : ret imm8 that also adds this imm8 value to esp : for example a __stdcall function uses it to discard its parameters from the stack. Not to mention retf version, used in 16bit mode, that also pops the cs from the stack.

pop register

表示:

mov register, [esp]
add esp, 4

这篇关于ret指令会导致esp寄存器加4吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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