The function-level inline assembler lets you refer to local variables and function arguments yourself, handles such references for you.
For your own references, you must explicitly save and restore processor registers and local variables when entering and leaving your inline assembly function. You cannot refer to the variables by name, but you can refer to function arguments off the stack pointer. For example, this function moves its argument into d0:
asm void alpha(short n)
{
move.w 4(sp),d0 // n
// . . .
}
To let the inline assembler handle references, use the directives fralloc and frfree, according to these steps:
The code listed below is an example of using local variables and function arguments in function-level inline assembly.
__declspec(register_abi) asm int f(int n) { register int a; // Declaring a as a register variable volatile int b; // and b as a stack variable // Note that you need semicolons after these statements. fralloc + // Allocate space on stack, reserve registers. move.l n,a // Using an argument and local var. add.l a,b move.l a,D0 frfree // Free space that fralloc allocated rts }