This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C/C++ Calling assembler


Hi

I want to call assembler routines from from C/C++ but am very confused at
the variation in calling conventions and how I can
force the complier to put arguments on the stack and not use registers, or a
combination, or do something else that isn't
deterministic that will screw up the assembler code.

I have tried using -mregparm=0 on the command line but that seems to screw
up calls to the standard library.

I have tried using unsigned char myfunction(unsigned char buf),
__attribute__ ((regparm(0))) after the function prototype

I have tried making the function prototype variadic.

An examination of the assembler produced always shows it passes the buffer
pointer in %edi and not on the stack.

Also, I am confused over whether the IP pushed is 32 or 64 bit in size. I
have read that the memory model used on linux limits
code and global data to 2GB each but dynamically allocated data can be as
large as you like, so code can be made more
compact.

What I would really like is some pointers to good documentation about all
this if it exists.

I use the Latest Ubuntu 64bit Linux and latest C++ compilers.

Any help or pointed would be very much appreciated.

Michael






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]