I have a X64 ASM routine assembled with MASM64/ML64. Its a stand alone leaf function, and not inline assembly. It is used in a C/C++ program within a Visual Studio solution.
I found two references on preserving registers on MSDN:
The first is for inline assembly, but it specifically states to preserve ECX when using __fastcall
. It also appears to lack a treatment of X64 because it refers to 32-bit registers.
The second tells us "RAX, RCX, RDX, R8, R9, R10, R11 are considered volatile and must be considered destroyed on function calls". Unfortunately, it does not clearly state whether they need to be preserved. (If you look closely, its using misdirection rather than stating the action to take).
I think the second article is controlling in this case, but I want to be clear to avoid confusion... Does CX/ECX/RCX need be be preserved for X64 Fastcall Leaf Functions?