Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "push ebp" mean in x86 assemby? [duplicate]

Tags:

x86

assembly

I disassembled an .exe file and got this as its first line.

push ebp
  • What does it mean?
  • Why ebp?
  • Does it have anything to do with pop command? even though I don't see it in the disassembly!
like image 242
David Weng Avatar asked Jul 31 '10 14:07

David Weng


People also ask

What happens when you push EBP?

push ebp preserves ESP, the previous stack frame pointer, this is so it can be returned to at the end of the function. A stack frame is used to store local variables and each function will have its own stack frame in memory. mov ebp, esp moves the current stack position into EBP which is the base of the stack.

What does EBP do in assembly?

Normally EBP is used to backup ESP, so if ESP is changed by the code in a function, all it takes to restore ESP is mov ESP, EBP. Also since EBP is normally left unchanged by the code in a function, it can be used to access passed parameters or local variables without having to adjust the offsets.

What is meaning of push %RBP?

push rbp instruction pushes the value of the register rbp onto the stack. Because it “pushes” onto the stack, now the value of rsp is the memory address of the new top of the stack.

What is EBP register in x86?

A frame pointer (the ebp register on intel x86 architectures, rbp on 64-bit architectures) contains the base address of the function's frame. The code to access local variables within a function is generated in terms of offsets to the frame pointer.


1 Answers

push ebp just means pushing whatever is in register ebp onto the stack. ebp stores the stack pointer by convention.

This is generally used to establish a stack frame, followed by

mov     ebp, esp
like image 150
NullUserException Avatar answered Sep 28 '22 09:09

NullUserException