The only method I know of is using the fastcall attribute:
(GCC Manual section 6.30) http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Function-Attributes.html#Function-Attributes
fastcall
On the Intel 386, the fastcall attribute causes the compiler to pass the first argument (if of integral type) in the register ECX and the second argument (if of integral type) in the register EDX. Subsequent and other typed arguments are passed on the stack. The called function will pop the arguments off the stack. If the number of arguments is variable all arguments are pushed on the stack.
Using it in on the following example code:
__attribute__((fastcall,noinline)) int add (int a, int b)
{
return a + b;
}
int main () {
return add (1, 2);
}
will result in:
.file "main.c"
.text
.globl add
.type add, @function
add:
pushl %ebp
movl %esp, %ebp
leal (%edx,%ecx), %eax
popl %ebp
ret
.size add, .-add
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
movl $2, %edx
movl $1, %ecx
call add
popl %ebp
ret
.size main, .-main
Don't forget to mention the fastcall attribute in any declaration in other translation units, otherwise rather strange things might happen.