Next:Variables in Specified Registers, Previous:C++11 Constant Expressions instead of String Literals, Up:How to Use Inline Assembly Language in C Code [Contents][Index]
You can specify the name to be used in the assembler code for a Cfunction or variable by writing theasm (or__asm__)keyword after the declarator.It is up to you to make sure that the assembler names you choose do notconflict with any other assembler symbols, or reference registers.
This sample shows how to specify the assembler name for data:
int foo asm ("myfoo") = 2;This specifies that the name to be used for the variablefoo inthe assembler code should be ‘myfoo’ rather than the usual‘_foo’.
On systems where an underscore is normally prepended to the name of a Cvariable, this feature allows you to define names for thelinker that do not start with an underscore.
GCC does not support using this feature with a non-static local variable since such variables do not have assembler names. If you aretrying to put the variable in a particular register, seeVariables in Specified Registers.
To specify the assembler name for functions, write a declaration for the function before its definition and putasm there, like this:
int func (int x, int y) asm ("MYFUNC"); int func (int x, int y){ /*… */This specifies that the name to be used for the functionfunc inthe assembler code should beMYFUNC.
Next:Variables in Specified Registers, Previous:C++11 Constant Expressions instead of String Literals, Up:How to Use Inline Assembly Language in C Code [Contents][Index]