Fastcall: What happens to the stack?

I am currently studying x64 build myself and don’t understand what happens to the stack when calling the build procedure from C ++.

From what I now understand from MSDN and Intel , the first 4 integer / floating-point parameters are stored in the rcx / xmm0, rdx / xmm1, r8 / xmm2 and r9 / xmm3 registers, and all the rest will be pushed onto the stack.

I just do not understand why I should access the 5th parameter of 40 bytes from rsp [rsp + 28h] instead of 8, since the first 32 bytes are available in registers.

Can someone explain to me what is really going on?

Thanks.

+7
stack parameter-passing 64bit fastcall
source share
1 answer

The key is in this phrase from the associated MSDN:

X64 Application Binary Interface (ABI) is a 4-register shortcut calling convention with stack support for these registers .

That is, registers are loaded with the first 4 arguments, but nevertheless they are reserved on the stack. As @HansPassant points out in the comments below, the caller does not write to this shadow space, but it is available to the called party if he needs to save registers (for example, to call another function).

+3
source share

All Articles