inline ASM function calling conventions.
Sjoerd Nijboer
dlang at sjoerdnijboer.com
Sun Sep 30 14:45:27 UTC 2018
On Sunday, 30 September 2018 at 12:07:53 UTC, Basile B. wrote:
> On Sunday, 30 September 2018 at 11:53:17 UTC, Basile B. 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:
Thank you for the link, very informative!
I'm spitting it through right now.
>
> 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);
> }
In X86_64 it works beautiful!
But in X86 it will pass them via the stack, and I'm trying to get
rid of that.
More information about the Digitalmars-d-learn
mailing list