I've read the "Mixing assembly and C" guide and I wonder why ebp is used.
The following code is from the guide:
_myfunc: push ebp
mov ebp,esp
sub esp,0x40 ; 64 bytes of local stack space
mov ebx,[ebp+8] ; first parameter to function
; some more code
leave ; mov esp,ebp / pop ebp
ret
So my questions are
1: Is ebp needed at all?, can't I just use esp
2: If ebp is not needed, why does it show up in all code examples?
I guess it is somewhat easier for an assembly programmer to use it, but why does DJGPP use it?
Why use ebp in c calling convention?
RE:Why use ebp in c calling convention?
This is what ebp was designed for, and it simply makes things easier.
esp will change values throughout your proceedure, no doubt; any push or pop will effect all your locations, and make it difficult to code.
Jeff
esp will change values throughout your proceedure, no doubt; any push or pop will effect all your locations, and make it difficult to code.
Jeff