Given:
#include <iostream>
extern "C" int AddAsm(int a, int b, int c, int d, int e, int f);
int main()
{
std::cout << AddAsm(1, 2, 3, 4, 5, 6);
}
I want to implemet the AddAsm function in x64 masm like this:
.code
AddAsm proc
mov rax, 0
add rax, rcx
add rax, rdx
add rax, r8
add rax, r9
add rax, qword ptr [rsp + 32]
add rax, qword ptr [rsp + 40]
add rax, qword ptr [rsp + 48]
add rax, qword ptr [rsp + 56]
ret
AddAsm endp
end
Now everything is clear for the first 4 parameters, but I can't manage to understand/find a practical example on how the rest of the parameters are put on the stack, what does the rbp and rsp register values actually represent and what are the offsets from one parameter to another.
Can somebody please shed some light with an example, please?