我目前正在学习英特尔处理器的组装.由于堆栈"渐渐减少",为什么我们必须添加才能访问特定元素
[ebp + 8] ;; This will access the first param
Run Code Online (Sandbox Code Playgroud)
我知道我们必须跳过旧的ebp值和返回地址,这就是我们使用8的原因(因为每个都是4个字节长).这有点奇怪.
另外,如果ebp是esp的备份副本,那么主函数Ex中的ebp值是多少:
_start:
;; what's ebp value here ?
push eax
push ebx
call someFunction ;; this will create a stack frame
+-----------+
| param1 |
+-----------+
| param0 | <--- this is [ebp + 8] ( assuming mov ebp, esp )
+-----------+
|ret_address|
+-----------+
| ebp |
+-----------+ <--- esp
Run Code Online (Sandbox Code Playgroud)
而且当我们为本地人分配内存时,我们必须从ebp中减去...请给出一个非模棱两可的答案.谢谢!