I'm learning assembly language via Youtube now. In the penultimate fifth line of the code segment below, I believe it aims to clear the 13 and "HelloWorld" in the stack. However, instead of poping these two out of the stack, it add the value in esp by 8. If that is the case, when a new element is pushed into the stack, would esp point to wrong data as 13 and "HelloWorld" are not popped out. Or the addition of esp will automatically change the stack? Please help.|ू・ω・` )
.data HelloWorld: acsiz. "HelloWorld!/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
_start:
nop
push $13
push $HelloWorld
call PrintFunction
addl $8, %esp #issue there
ExistCall:
movl $1, %eax
int 0x80`
I have tried to disassemble the code through gdb, and find that the stack go back to the point before the _start.