【发布时间】:2011-01-26 15:31:18
【问题描述】:
我是学习一些汇编的初学者,在函数调用之前保留 ESP 寄存器时,通过加法还是减法来做这件事有关系吗?很难解释,考虑以下
mov esi, esp
sub esp, 12 // on 32bit OS this would mean that there are 3 arguments to the function
// push, function call etc
cmp esi, esp // should be the same
或
mov esi, esp
// push, function call etc
add esp, 12
cmp esi, esp // should be the same
此外,如果由于某种原因 cmp 失败,是否可以安全地执行 mov esp, esi 来重新对齐堆栈?
谢谢
编辑:为什么我需要为 sprintf 之类的调用执行此操作,但 MessageBox 似乎为我修复了 ESP?我怎么知道什么功能需要这个,什么不需要?
【问题讨论】: