Calling convention for ASM on Linux AMD64
Sean O'Connor
sean.c4s.vn at gmail.com
Sat Aug 18 04:16:11 UTC 2018
What calling convention is used for assembly language in Linux
AMD64?
Normally the parameters go in fixed order into designated
registers.
import std.stdio;
// Linux AMD64
float* test(float *x,ulong y){
asm{
naked;
align 16;
mov RAX,RDI;
ret;
}
}
void main(){
float[] f=new float[16];
writeln(&f[0]);
float* a=test(&f[0],7);
writeln(a);
}
If the ulong y parameter is removed from the function definition
the pointer x goes into RDI as expected. When y is added it all
goes wrong. According to AMD64 the pointer should stay in RDI and
the ulong go into RSI.
More information about the Digitalmars-d-learn
mailing list