inline ASM function calling conventions.

Sjoerd Nijboer dlang at sjoerdnijboer.com
Sun Sep 30 14:48:28 UTC 2018


On Sunday, 30 September 2018 at 12:32:08 UTC, kinke wrote:
> 1) `asm {}` is supported by DMD and LDC, but not by GDC.

Good to know.
Guess I will be targeting DMD and LDC then.

> 4) For x86_64, there are 2 (completely different) ABIs, Win64 
> and the System V one. Specs can be found online.
>
> In your case:
>
> void Foo(MyStrunct* first_arg, MyStrunct* second_arg)
> {
>     asm { naked; }
>     version (D_InlineAsm_X86)
>     {
>         // first_arg is on the stack, at [ESP+4]
>         // second_arg is in EAX
>     }
>     else version (D_InlineAsm_X86_64)
>     {
>         version (Win64)
>         {
>             // first_arg is in RDX
>             // second_arg is in RCX
>         }
>         else
>         {
>             // first_arg is in RSI
>             // second_arg is in RDI
>         }
>     }
> }

So in X86 asm, if I want to pas two parameters to a function I 
can have one in a register, but not two. The second will go via 
the stack. But on X86_64 it won't?
Guess I'll just have to live with that.
Thank you!


More information about the Digitalmars-d-learn mailing list