我现在正在通过 Youtube 学习汇编语言。在下面代码段的倒数第五行中,我相信它的目的是清除堆栈中的 13 和“HelloWorld”。但是,它不是将这两个弹出堆栈,而是将 esp 中的值加 8。如果是这种情况,当一个新元素被推入堆栈时,esp 会指向错误的数据,因为 13 和“HelloWorld”是没有弹出。还是加入esp会自动改变栈?请帮忙。|ू・ω・` )
.数据 你好世界: acsiz。 “你好世界!/n” .text
.global start_
.type PrintFunction, @function
PrintFunction:
#prepare state
pushl %ebp
movl %esp, ebp
#write
movl $4, %eax
movl $1, %ebx
movl 8(%ebp), %ecx
movl12(%ebp), %edx
int 0x80
#return state
movl $ebp, $esp #clear esp from potential data in the function
pop $ebp
ret
_开始:
nop
push $13
push $HelloWorld
call PrintFunction
addl $8, %esp #issue there
ExistCall:
movl $1, %eax
int 0x80`
我尝试通过gdb反汇编代码,发现堆栈回到了_start之前的点。