the*_*ian 1 x86 assembly stack-frame fasm
关于在x86汇编语言中设置堆栈帧的ebp和esp的使用,我有点混淆.在以下代码中:
section '.code' code readable executable ; define the code section of the file
main: ;main label is where execution begins
push ebp
mov ebp,esp ;set up the base ptr
sub ebp,4 ;subtract 4 from ebp
mov dword [esp],msg
call [printf]
mov dword [esp],p ; pass pause>nul cmd to system to hold the box open
call [system]
mov dword [esp],0 ;pass NULL to exit
call [exit]
Run Code Online (Sandbox Code Playgroud)
程序员从ebp中减去了4,但我不确定原因.通常,我在这里看到ESP减去而不是EBP.在这里从EBP中减去的目的是什么?
这肯定是一个bug:
push ebp ; 1
mov ebp,esp ; 2
sub ebp,4 ; 3
mov dword [esp],msg ; 4
Run Code Online (Sandbox Code Playgroud)
因为指令2和3仅修改ebp寄存器(但不是esp),指令4将覆盖指令1中推送的值.
我怀疑程序员的意图.
| 归档时间: |
|
| 查看次数: |
254 次 |
| 最近记录: |