C/C++ Calling assembler

Michael michael.yacc@blueyonder.co.uk
Thu Apr 30 20:46:00 GMT 2009


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

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.


More information about the Gcc-help mailing list