inline ASM function calling conventions.

Sjoerd Nijboer dlang at sjoerdnijboer.com
Sun Sep 30 10:46:33 UTC 2018


I'm kinda puzzled.

I'm having trouble getting started with inline asm in D.
Suppowse I have the following:

void Foo(MyStrunct* first_arg, MyStrunct* second_arg)
{
     asm
     {
         naked;
         version(X86)
         {
             /* Do something with the content of I and J. */
         }
         version(X86_64)
         {
             /* Do something with the content of I and J. *?
         }
     }
}

void Bar()
{
     MyStrunct heapStructA, heapStructB;

     // do some initialization.

     Foo(heapStructA, heapStructB);
}

Suppose I would like to pass first_arg and second_arg by register 
to `Foo`, what calling convention should I use? I'm having 
trouble identifying the correct calling convention I should be 
using for X86 and X86_64 in D.

I've tried a couple using https://godbolt.org/ and DMD parameters 
'-g -m32', but I can't seem to find any that will pass by 
register. Is there one? Will it also work for LDC and GDC?


More information about the Digitalmars-d-learn mailing list