You can read about the 64-bit calling convention here. x64 functions are supposed to clean up after themselves however, when I call malloc from .asm, it overwrites the value at RSP and RSP+8. This seems very wrong. Any suggestions?
public TestMalloc extern malloc : near .CODE align 8 TestMalloc proc mov rcx, 100h 000000018000BDB8 48 C7 C1 00 01 00 00 mov rcx,100h call malloc 000000018000BDBF E8 CC AC 06 00 call malloc (180076A90h) ret 000000018000BDC4 C3 ret 000000018000BDC5 66 66 90 xchg ax,ax TestMalloc endp END
For the x64 calling convention, even if the parameters are passed in the registers the caller is required to save space for them on the stack:
http://msdn.microsoft.com/en-us/library/ew5tede7.aspx