Cogman
Lifer
Just wondering, is it considered bad practice not to setup the stack frame pointer when you enter a function? When writing straight ASM (IE Im using MASM to assemble, not some C compiler). I will usually only setup the stack frame pointer if I actually use the stack, (and really, that is only when I am loading variables off the stack after using the stack).
With GCC, MSVC, ect, the stack frame pointer is ALWAYS setup. For me however, a function like
doesn't really need the whole stack setup. It would do fine with
I can see the use if a function is overly complex with lots of stack references and multiple references to the passed in variables, I just don't see the point when the stack is rarely/not used.
With GCC, MSVC, ect, the stack frame pointer is ALWAYS setup. For me however, a function like
Code:
func:
push ebp
mov ebp, esp
xor eax, [ebp + 8]
pop ebp
ret
doesn't really need the whole stack setup. It would do fine with
Code:
func:
xor eax, [esp + 4]
ret
I can see the use if a function is overly complex with lots of stack references and multiple references to the passed in variables, I just don't see the point when the stack is rarely/not used.