doc: some more documentation on 64-bit programming

Some more information about 64-bit programming and its quirks.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
H. Peter Anvin 2018-02-07 12:28:42 -08:00
parent ddea5fc0cd
commit cb7b097b3e

View File

@ -7704,10 +7704,15 @@ platforms pass arguments in registers rather than on the stack.
Furthermore, 64-bit platforms use SSE2 by default for floating point. Furthermore, 64-bit platforms use SSE2 by default for floating point.
Please see the ABI documentation for your platform. Please see the ABI documentation for your platform.
64-bit platforms differ in the sizes of the fundamental datatypes, not 64-bit platforms differ in the sizes of the C/C++ fundamental
just from 32-bit platforms but from each other. If a specific size datatypes, not just from 32-bit platforms but from each other. If a
data type is desired, it is probably best to use the types defined in specific size data type is desired, it is probably best to use the
the Standard C header \c{<inttypes.h>}. types defined in the standard C header \c{<inttypes.h>}.
All known 64-bit platforms except some embedded platforms require that
the stack is 16-byte aligned at the entry to a function. In order to
enforce that, the stack pointer (\c{RSP}) needs to be aligned on an
\c{odd} multiple of 8 bytes before the \c{CALL} instruction.
In 64-bit mode, the default instruction size is still 32 bits. When In 64-bit mode, the default instruction size is still 32 bits. When
loading a value into a 32-bit register (but not an 8- or 16-bit loading a value into a 32-bit register (but not an 8- or 16-bit
@ -7815,9 +7820,11 @@ calls, and thus are available for use by the function without saving.
Integer return values are passed in \c{RAX} and \c{RDX}, in that order. Integer return values are passed in \c{RAX} and \c{RDX}, in that order.
Floating point is done using SSE registers, except for \c{long Floating point is done using SSE registers, except for \c{long
double}. Floating-point arguments are passed in \c{XMM0} to \c{XMM7}; double}, which is 80 bits (\c{TWORD}) on most platforms (Android is
return is \c{XMM0} and \c{XMM1}. \c{long double} are passed on the one exception; there \c{long double} is 64 bits and treated the same
stack, and returned in \c{ST0} and \c{ST1}. as \c{double}.) Floating-point arguments are passed in \c{XMM0} to
\c{XMM7}; return is \c{XMM0} and \c{XMM1}. \c{long double} are passed
on the stack, and returned in \c{ST0} and \c{ST1}.
All SSE and x87 registers are destroyed by function calls. All SSE and x87 registers are destroyed by function calls.