[lug] C++ inline asm on g++

D. Stimits stimits at idcomm.com
Thu Jan 10 21:43:59 MST 2002


Kelly Brock wrote:
> 
> Hi,
> 
> > >         The reason that this came up is not because using
> > the inline assembly is a
> > > problem, it's because I can't figure out how to turn off
> > the prolog and
> > > epilog code for the function in question.  I need the
> > function to do it's
> > > own stack manipulation because it's a rather exotic little
> > thing.  In VC I
> > > do this quite simply with the following:
> >
> > By turning off prolog and epilog, is this therefore a question of the
> > calling convention being done manually? Or is the prolog and
> > epilog not
> > part of the calling convention, e.g., not part of who cleans
> > up or what
> > order arguments are placed on the call stack? I have a feeling the
> > prolog and epilog are something different than calling convention, but
> > closely related.
> 
>         They are very closely related but since it's a void/void function that's
> really not a major issue.  In the particular function, because it's
> expecting a specific stack layout at the time it's called in order to do
> it's work, the prolog/epilog code will cause problems.  I can probably work
> around this but it's a lot more prone to be buggy since the prolog/epilog
> code could change from compiler to compiler and if it's anything like VC, it
> can/does change between debug and release.  The 'naked' ability in VC allows
> me to avoid such issues.
> 
>         Anyway, this is not an insurmountable problem even if I have to use a "C"
> version of the function.  It's just a lot cleaner the VC way and it would be
> really nice to be able to do maintain the code as similiar on both platforms
> as possible.
> 
>         Just a thought, what would happen with the following?
> 
> namespace something
> {
>   extern void function(void);
> };
> 
>         Is name mangling still an issue and/or will the function be imported into
> the namespace?  Hmm, don't think I've ever tried this one, I'll dig out the
> bible and see..

I believe this should work just fine. So long as it can find the void
function itself (meaning the namespace can add proper mangling around
it, provided "it" can be found in the first place). As for particular
registers and such that have to be preserved or restored, I don't think
*that* part changes with version of g++, I think that 2.91 of redhat 6.2
and 2.96 of RH 7.x, or even g++ versions 3.x+ should all have the same
requirements on registers to save and restore. Someone here no doubt
knows more about this and can verify it, only mangling schemes should
change between those versions. I definitely need someone at BLUG that
can say this is right or wrong.

D. Stimits, stimits at idcomm.com

> 
>         Regards,
> 
>         Kelly Brock
>         The Sims Online
>         Maxis - Electronic Arts
> 
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug



More information about the LUG mailing list