Author Topic: About call convention  (Read 931 times)

felipe

  • Member
  • ****
  • Posts: 928
  • Eagles are just great!
Felipe.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 5764
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: About call convention
« Reply #1 on: April 13, 2018, 11:04:06 AM »
 :biggrin:

The reason why you write in assembler, you are not at the mercy of compiler assumptions.  :P
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

AW

  • Member
  • *****
  • Posts: 1486
  • Let's Make ASM Great Again!
Re: About call convention
« Reply #2 on: April 13, 2018, 01:46:17 PM »
Another article from another guy who doesn't see the light at the end of the tunnel but feels comfortable enough to criticize whatever he does not understand.
"Even the inline function calls (the DirectXMath library) have an undocumented parameter … sometimes. It all depends on the function. Typically (but not always), functions returning an XMMATRIX structure require a pointer to the output matrix destination in RCX when the call is made"
I have converted the whole DirectXMath library to ASM and did not notice any  undocumented parameter, it is fully documented what RCX must contain. And of course if a function is inlined it is not function on the ASM code. What a mess.

From MSDN documentation, about returning custom data types over 8 bytes, including structures:
" the caller assumes the responsibility of allocating memory and passing a pointer for the return value as the first argument. Subsequent arguments are then shifted one argument to the right. The same pointer must be returned by the callee in RAX"