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

D. Stimits stimits at idcomm.com
Thu Jan 10 17:42:49 MST 2002


Kelly Brock wrote:
> 
> Hi All,
> 
> > I'm going to be at the BLUG meeting this evening, maybe
> > someone can give
> > me some hints while there. I'm trying to find out what is
> > needed for g++
> > using recent g++ releases will need to add inline asm with
> > C++ linkage?
> > If wrapped extern "C", I know it won't be an issue, but if for example
> > one wants to create asm based functions that are overloaded
> > or within a
> > separate namespace, what hoops must be jumped through? Is
> > there asm name
> > mangling that must be dealt with, or can g++ take care of it? My asm
> > abilities are rather limited, maybe someone has a URL with samples of
> > basic C++ linkage asm. Now if the asm requires some sort of name
> > mangling scheme that g++ itself does not take care of, I assume one
> > version is required for g++ 2.95 or below, another for redhat's 2.96,
> > and yet one more for 3.x versions of g++? The name mangling scheme is
> > apparently one of the reasons one can't mix binary object files across
> > these compiler versions (among many reasons), I certainly hope it is
> > possible to handle this without detailed knowledge of the actual
> > mangling.
> 
>         Just want to add something to this since it's part of a discussion Dan and
> I are having.
> 
>         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.

D. Stimits, stimits at idcomm.com

> 
> void __declspec(naked) Function(void)
> {
>   __asm
>   {
>     .. yada yada ..
>   }
> }
> 
>         Is there a variation of this usable in GCC?  I tried the __attribute__
> (naked) thing but couldn't get it to work.  An answer to either case would
> be wonderful.
> 
>         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