Scratch

Convención para AMD64 architecture (also known as x86-64)

First 4 parameters – RCX, RDX, R8, R9. Others passed on stack.

https://msdn.microsoft.com/en-us/library/9b372w95.aspx

https://blogs.msdn.microsoft.com/oldnewthing/20040114-00/?p=41053/

The first four parameters to a function are passed in rcx, rdx, r8 and r9. Any further parameters are pushed on the stack. Furthermore, space for the register parameters is reserved on the stack, in case the called function wants to spill them; this is important if the function is variadic.

Parameters that are smaller than 64 bits are not zero-extended; the upper bits are garbage, so remember to zero them explicitly if you need to. Parameters that are larger than 64 bits are passed by address.

The return value is placed in rax. If the return value is larger than 64 bits, then a secret first parameter is passed which contains the address where the return value should be stored.

All registers must be preserved across the call, except for rax, rcx, rdx, r8, r9, r10, and r11, which are scratch.

The callee does not clean the stack. It is the caller’s job to clean the stack.

The stack must be kept 16-byte aligned. Since the “call” instruction pushes an 8-byte return address, this means that every non-leaf function is going to adjust the stack by a value of the form 16n+8 in order to restore 16-byte alignment.