Functions return results in the following registers:
Table F–21 Registers Used by x86 Functions to Return Types
Register |
Type Returned |
---|---|
int |
%eax |
%edx and %eax |
|
float, double, and long double |
%st(0) |
float _Complex |
%eax for the real part and %edx for the imaginary part |
double _Complex and long double _Complex |
The same as a struct that contains two elements of the corresponding floating point type. |
All arguments except structs, unions, long longs, doubles and long doubles are passed as four-byte values; a long long is passed as an eight-byte value, a double is passed as an eight-byte value, and a long double is passed as a 12-byte value.
structs and unions are copied onto the stack. The size is rounded up to a multiple of four bytes. Functions returning structs and unions are passed a hidden first argument, pointing to the location into which the returned struct or union is stored.
Upon return from a function, it is the responsibility of the caller to pop arguments from the stack, except for the extra argument for struct and union returns that is popped by the called function.