1

Was reading about assembly, part about conventions of calling routines in assembly(Linux, especially).

It is said first 8 floating-point parameters are passed via xmm0-xmm15 and other parameters in registers rdi, rsi, rdx, rcx, r8, r9, and other remaining parameters should be pushed to stack in reverse order.

What if I have more than 8 floating-point parameters and more than 6 other parameters, in what order should one push them to stack? First floating-point values that do not fit in 8 fp. registers or other parameters that do not fit in 6 registers?

Bulat M.
  • 680
  • 9
  • 25

1 Answers1

3

What part of the ABI doc is unclear (https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI)?

Are you asking what happens if there's a mix of int and fp args, and you run out of both kinds of arg-passing registers?

IIRC, they just go on the stack in reverse order, with the last arg at the highest address, and the first non-register arg just above the return address. This is just like in 32-bit code where args are always passed on the stack.

See also http://wiki.osdev.org/System_V_ABI, and the tag wiki.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • Is it authorative draft, could it be used for a reference? On title page there are few names written, I have never heard of before. – Bulat M. Sep 06 '16 at 13:58
  • @BulatM. Yes, that page links to the official current version of the standard document. e.g. "*The x86-64 psABI revision 252 can be downloaded from [here](https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-r252.pdf)*". Unfortunately the document doesn't always fully document everything that compilers rely on, but everything it does say is accurate. The only exception I know about is [zero/sign extending narrow integer args to 32-bit](http://stackoverflow.com/questions/36706721/is-a-sign-or-zero-extension-required-when-adding-a-32bit-offset-to-a-pointer-for/36760539#36760539). – Peter Cordes Sep 06 '16 at 14:03
  • A copy of the ABI docs used to be posted on http://www.x86-64.org/documentation.html, but x86-64.org has been dead for a couple weeks now. – Peter Cordes Sep 06 '16 at 14:06