explanation about push ebp and pop ebp instruction in assembly

后端 未结 2 1548
Happy的楠姐
Happy的楠姐 2021-01-30 13:22

i used stack in assembly but i didn\'t got idea about push ebp and pop ebp.

.intel_syntax noprefix

.include \"console.i\"

.text

askl:   .asciz  \"Enter l         


        
2条回答
  •  梦谈多话
    2021-01-30 13:44

    ebp is known as the base pointer or the frame pointer. On entry to your function, you push it (to save the value for the calling function). Then, you copy esp, the stack pointer, into ebp, so that ebp now points to your function's stack frame. At the end of your function, you then pop ebp so that the calling function's value is restored.

    For some clarification on exactly what is going on - the push instruction puts the value from the specified register (ebp in this case), onto the stack, and decrements the stack pointer by the appropriate amount. The pop operation is the opposite - it increments the stack pointer and takes a value from the stack and puts it in the specified register.

提交回复
热议问题