On Sunday, 30 September 2018 at 11:53:17 UTC, Basile B. wrote:
On Sunday, 30 September 2018 at 10:46:33 UTC, Sjoerd Nijboer wrote:
[...]

Hello, i think this should be here (https://dlang.org/spec/abi.html) because myself i never remember them correctly without playing a bit with a disassembler.
After playing a bit:


Without all the save/restore BS:

module runnable;

import std.stdio;

alias write4Int = writeln!(int,int,int,int);

struct MyStruct{int i;}

extern(D) void foo(ref MyStruct s1, ref MyStruct s2, ref MyStruct s3, ref MyStruct s4)
{
    asm
    {
        naked;
        mov     RCX, MyStruct.i.offsetof[RCX];
        mov     RDX, MyStruct.i.offsetof[RDX];
        mov     RSI, MyStruct.i.offsetof[RSI];
        mov     RDI, MyStruct.i.offsetof[RDI];
        call    write4Int;
        ret;
    }
}

void main()
{
    MyStruct s1 = MyStruct(1);
    MyStruct s2 = MyStruct(2);
    MyStruct s3 = MyStruct(3);
    MyStruct s4 = MyStruct(4);
    foo(s1, s2, s3, s4);
}

Reply via email to