I knew in the common calling convention of integer argument it’s rdi rsi ...
, but what about the double
s? As the argument in the test is actually a struct
, am I supposed to use rdi
as the address of the struct
? But I’ve seen from other’s solutions they are just using rsp+8
rsp+16
rsp+24
…
You’d use rdi
if the struct was passed as a pointer. In this case, however, it is passed by value and thus would be pushed on the stack. In System V AMD64 ABI, ignoring floating point arguments, the first integer/pointer arguments are passed to the corresponding 6 registers (rdi
, rsi
, rdx
, rcx
, r8
, r9
) and the rest are pushed on the stack in reverse order.
Also, it might be useful to see what GCC outputs in different cases.