Everywhere I looked ("Programming from the ground up", Wikipedia x86 Calling Convention, ...), it was said that C passes arguments through the stack. Yet, in the following C code
int func(int);
int main() {
func(5);
return 0;
}
int func(int a) {
return a;
}
Argument a is passed through register %edi (used gcc -S ex.c
to compile on Ubuntu 64 bit machine). I passed more arguments, the caller just uses more registers to pass the values.
Is that normal? Are the online resources I visited somehow outdated?
Thanks in advance.