我需要一些帮助来理解堆栈寄存器是如何在x86程序集中工作的。下面的代码片段来自我正在学习的引导加载器。
打印函数采用三个“参数”。因为我把这三个都推到堆栈中,所以我希望sp在0xfff9。bp在打印函数中一次接受相同的地址。
为什么我要做[bp+4]而不是[bp+2]呢?因为我在位置0xfffd、0xfffb和0xfff9上推出的变量不是吗?然后,当我从print函数返回时,我会添加add sp, 6,以便在打印之前将sp还原到相同的位置。
; stack initialization
mov ax, 0x0000
mov ss, ax
mov sp, 0xffff
mov bp, 0xffff编辑忘记了函数返回地址。
发布于 2014-03-19 10:43:21
BP points to where the previous BP value was pushed
BP + 2 points to the return address pushed by `call PRINTMESSAGE`
BP + 4 points to the last argument pushed
and so onhttps://stackoverflow.com/questions/22502817
复制相似问题