vectorcall.md
June 27, 2024 ยท View on GitHub
Asmc Macro Assembler Reference
VECTORCALL
Microsoft __vectorcall Convention.
Registers are assigned to arguments in the order ECX/EDX or RCX/RDX/R8/R9. Arguments are assigned from right to left.
In addition vectorcall support passing 6 SIMD registers. In 64-bit the arguments are fixed (max 6) but "floating" in 32-bit (max 8).
| vectorcall | param | max | min | clean-up | mangle |
| 16-bit | - | - | - | - | - |
| 32-bit | reg | 4 | 4 | callee | foo@@n |
| 64-bit | stack | 16 | 4 | caller | foo@@n |
Register param are sign-extended to min and register-pair are allowed up to max.
The caller allocates stack for arguments in 64-bit, so parameter refer to the stack-position rather than the register. If the callee uses (touch) any of these parameters a stack-frame is created and the register is saved to the stack:
option win64:auto save
foo proc vectorcall a1:word, a2:dword
mov si,a1 ; use parameter
ret
foo endp
0000 mov [rsp+8H], rcx
0005 push rbp
0006 mov rbp, rsp
0009 mov si, [rbp+10H]
000D leave
000E ret
...
mov si,cx ; use register
0000 mov si, cx
0003 ret