push %ebp
movl %esp, %ebp
是什么意思?有什么作用?为什么要这样做???
迷茫2017-04-17 13:09:07
ebp is the frame pointer and esp is the stack pointer. These two lines of code save the old frame and create a new stack frame. Procedure calls in assembly require this action
天蓬老师2017-04-17 13:09:07
Create a stack frame, which can be optimized. Keeping this is mainly convenient for debugging, and you can trace the function call chain.
unsigned long *p=ebp;
*(p+1) is the return address of the calling function.
p=*p is the frame of the upper-level function
*(p+1) is the return address of the calling function of the upper-level function
You can always trace it back to the top function through this.
阿神2017-04-17 13:09:07
This is related to the function stack frame.
When a process starts, a stack frame will be created for the current process. The machine uses the stack to pass process parameters and store return information. %ebp is the frame pointer and %esp is the stack pointer. The two sentences you mentioned are stack building statements.