Why do we always do
pushl %ebp # save the old base pointer
movl %esp, %ebp # set ebp to the current esp
movl %ebp, %esp
popl %ebp
^this, when defining functions in assembly?
Below is my translation of some code without pushes and pops and esp register used to access variables.
asm(
"_calculateA:;"
" movl 8(%esp), %eax;"
" andl 4(%esp), %eax;"
" ret;"
);
It is much shorter and works fine, so what's the deal?