The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: James Ladd on September 25, 2006, 11:05:47 PM

Title: raw function prolog/epilog ....
Post by: James Ladd on September 25, 2006, 11:05:47 PM
For my library of functions I am coding without macros in Gnu Assembler.
The functions work, but im interested in feedback on the function prolog/epilog.
Essentially im just asking you if all looks right.

The functions are for a 'C' calling convention and currently do nothing and
return 0.

Rgs, James.


        push ebp
        mov ebp, esp
        push ebx

        xor eax, eax

        pop ebx
        mov esp, ebp
        pop ebp
        ret
Title: Re: raw function prolog/epilog ....
Post by: hutch-- on September 25, 2006, 11:36:17 PM
James,

It looks fine but note that if you pass parameters on the stack like normal, you either balance the stack with RET NUMBER or if its C calling convention, you balance the stack after the function has returned.
Title: Re: raw function prolog/epilog ....
Post by: Tedd on September 26, 2006, 10:23:51 AM
Yep, looks good, assuming a) the function has arguments and/or 'local' variables (otherwise there's no need for the stack frame), and b) ebx will be used. (Yes I'm quite sure you know all of this already - too many people on high horses around here ::) :bdg)
Just depends how picky you want to be :wink