© Jo Van Hoey 2019
J. Van HoeyBeginning x64 Assembly Programminghttps://doi.org/10.1007/978-1-4842-5076-1_41

41. Functions in Windows

Jo Van Hoey1 
(1)
Hamme, Belgium
 

Passing argument to functions is simple when you have four or fewer non-floating-point arguments. You use rcx, rdx, r8, and r9 and provide shadow space on the stack before calling the function. After the call, you re-adjust the stack for the shadow space, and everything is fine. If you have more than four arguments, things are more complicated.

Using More Than Four Arguments

Let’s first see why things get complicated with more than four non-floating-point arguments, as shown in Listing 41-1.
; arguments1.asm
extern printf
section .data
      first      db    "A",0
      second     db    "B",0 ...

Get Beginning x64 Assembly Programming: From Novice to AVX Professional now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.