In gcc, you can declare that a local variable should be put in a register using the following syntax.
register int arg asm("eax");
In some old code that I found on the Internet, this syntax was used to declare that function parameters should be passed to the register:
void foo(register int arg asm("eax"))
But when I try this example:
#include <stdio.h> /* Function with argument passed in register */ void foo(register int arg asm("eax") ) { register int loc asm("ebx"); loc = arg; printf("foo() local var: %d\n", loc); } int main(void) { foo(42); return 0; }
And compile with gcc I get an error:
gcc main.c -o test-asm.exe main.c:7:27: error: expected ';', ',' or ')' before 'asm'
Now my questions are:
Is the asm syntax above correct in gcc, i.e. for formal function parameters?
Has it ever been supported by gcc?
If this is not the correct syntax, how can this be done then?
Thanks,
// Yu.K.
c assembly gcc parameter-passing calling-convention
j.karlsson
source share