I am currently reading a book about assembly for x86_64 arch. I am using extern “c” so I am calling a assembly from cpp. The guy is coding in visual studio and he says that cpp is loading the arguments of the function in the eax, edx, R8D, R9D registers. This is the function I am working on
extern “C” integer_add(int a, int b, int c, int d);
// some movs, adds and subs go on in the assembly instructions
My question is: can I assume that cpp loads the parameters in these registers or not? He is using MASM, which I think is for Windows (I have worked with NASM so far, I am on mac in case it means something) and if not, how do I know where I can find my parameters. Technically speaking coming from higher level languages I guess that all this should happen in the stack but he does not seem to push or pop anything. This is what I have found on wikipedia RDI, RSI, RDX, RCX, R8, R9, [XYZ]MM0–7so these seem to be the registers which gcc, Intel C++ linux and MACOS use. Does the order matter, so the first parameter is loaded into rdi, the second in rsi and so on...? thank you for your help