I mean need to fix documentation and add some samples that shows which registers will be used for it in Linux, Windows, _x64, ARM...
like Linux/x64 convention uses RDI, RSI, RDX, RCX, R8, R9 for args left-to-right
but D uses same registers for args right-to-left:
extern (C) func( long a, long b, long c ) => C/Linux: RDI, RSI, RDX
extern (D) func( long a, long b, long c ) => C/Linux: RDX, RSI, RDI
Comment #2 by dlang-bot — 2021-11-09T18:01:57Z
@ljmf00 created dlang/dlang.org pull request #3120 "spec: abi: clarify calling convention for other architectures other t…" fixing this issue:
- spec: abi: clarify calling convention for other architectures other than x86
Observing the assembly generated by the following source file in either DMD and
LDC:
```d
extern (C) void ccall( size_t a, size_t b, size_t c );
extern (D) void dcall( size_t a, size_t b, size_t c );
//...
ccall( a, b, c ); // RDI, RSI, RDX
dcall( a, b, c ); // RDX, RSI, RDI
```
The parameters are passed in the reverse order in functions with `extern(D)`
linkage. Furthermore, on x86 the calling convention seems to be what is
described by the current subsections, not only matching Windows x86, but also
appears to be the same behaviour on System V ABI.
Fixes #20204 .
Signed-off-by: Luís Ferreira <[email protected]>
https://github.com/dlang/dlang.org/pull/3120
Comment #3 by duser — 2022-02-17T03:21:54Z
*** Issue 20993 has been marked as a duplicate of this issue. ***
Comment #4 by robert.schadek — 2024-12-15T15:25:20Z