I forget where it is documented. I have the following two register
lists taped on the bottom bezel of one of my CRT's, because I debug a
lot of C++ code in assembler view and this key part of the calling
convention is important whenever you debug C++ in assembler view:
1) Parameters passed in registers, left to right: rdi, rsi, rdx, rcx,
r8, r9
2) registers preserved by call: rbp, rbx, r12-r15
so in your example, assuming foo was NOT optimized to be inline, "a"
would be passed in rdi, "b" would be passed in rsi and "c" would be
passed in rdx.
Obviously it gets more complicated when you mix in data types other than
pointers and integers. Also, I hope obvious, in member functions "this"
is passed in as if it were the leftmost parameter.
If you understand the 32-bit and you can read the AMD manuals, I don't
see what else might be confusing you (actually even the above register
lists were in one of the AMD manuals).
What is confusing about the use of local labels by the compiler?
Yang Zhang wrote:
Are there any good resources for learning about gcc's x86_64 assembly
output? When I run `gcc -S a.c` for a simple test C program like the
one below, I can completely understand the resulting go.s on a 32-bit
x86, but as soon as I run that on a 64-bit machine, I'm lost. I know
what the instructions are (i.e. I know how to use the AMD manuals),
but I'd like to learn about gcc's assembly output: the exact new
calling conventions (registers seem to be more liberally used over the
stack now even without opt), all these
.LFB/.LCFI/.LFE/.Lframe/.LSCIE/.LSFDE/.LASFDE/... labels, and so on.
Thanks in advance for any guidance.
void foo(int a, int b, int c) { char xs[5]; char ys[10]; }
int main() { foo(1,2,3); return 0; }