Windows x64 function call Convention)

Source: Internet
Author: User
Tags windows x64
Windows x64 function call Convention posted on December 28,200 9 by openwares

Using the PC processor architecture to transition from x86 to x64, Ms cleans up the function call conventions on Windows x64 platform, from the original several types including stdcall, thiscall, fastcall, cdecl, Pascal, etc, unified as a new fastcall call method. This call method is benefited from the increase in the number of registers on the x64 platform.

The main features of the fastcall call Convention on Windows x64 are as follows:

  • The first four integer or pointer type parameters are passed in sequence by RCX, RDX, R8, and R9, and the first four floating point type parameters are passed in sequence by xmm0, xmm1, xmm2, and xmm3.
  • The called function retains the corresponding space on the call stack for the first four parameters, called Shadow space or spill slot. Even if the called party has no or less than four parameters, the called function retains so much stack space, which helps simplify the call conventions in some special circumstances.
  • Any other parameter except the first four parameters is passed through the stack, from right to left.
  • The call function is responsible for clearing the call stack.
  • The return values of integer or pointer type smaller than or equal to 64 bits are transmitted by Rax.
  • The floating point return value is transmitted by xmm0.
  • For larger return values (such as struct), the caller allocates space on the stack, and rcX holds the pointer to the space and passes it to the called function, therefore, the registers used by Integer Parameters are shifted one by one to the right. In fact, only three registers can be used, and other parameters are included in the stack. After the function is called, Rax returns the pointer to the space.
  • In addition to rcX, RDX, R8, and R9, rax, R10, R11, xmm4, and xmm5 are also volatile registers.
  • The RBx, RBP, RDI, RSI, R12, R14, R14, and r15 registers must be protected during use.
  • In registers, all parameters are right aligned. Parameters smaller than 64 bits are not highly zero-scaling, that is, high levels are unpredictable junk data.
X64 call conventions
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.