This is part of the convention necessary for proper stack unwinding. The %ebp base pointer points to the stack frame of the caller. The calling convention is to save the caller's base pointer by pushing it on the stack. See Chapter 9 Exception handling and stack unwinding in Agner Fog's comprehensive Calling Conventions document
http://www.agner.org/optimize/calling_conventions.pdf.
If you want to use a debugger, such as gdb
to debug your program, and you want it to show you a backtrace
, then you need to follow that calling convention.
http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_42.html
A backtrace is a summary of how your program got where it is. It shows one line per frame, for many frames, starting with the currently executing frame (frame zero), followed by its caller (frame one), and on up the stack.