title: Does RCX need be be preserved for X64 Fastcall Leaf Functions?
body: <p>I have a X64 ASM routine assembled with MASM64/ML64. Its a stand alone leaf function, and <strong><em>not</em></strong> inline assembly. It is used in a C/C++ program within a Visual Studio solution.</p>
  
  <p>I found two references on preserving registers on MSDN:</p>
  
  <ul>
  <li><a href="https://msdn.microsoft.com/en-us/library/k1a8ss06.aspx" rel="nofollow">Using and Preserving Registers in Inline Assembly</a></li>
  <li><a href="https://msdn.microsoft.com/en-us/library/6t169e9c.aspx" rel="nofollow">Caller/Callee Saved Registers</a>.</li>
  </ul>
  
  <p>The first is for inline assembly, but it specifically states to preserve ECX when using <code>__fastcall</code>. It also appears to lack a treatment of X64 because it refers to 32-bit registers.</p>
  
  <p>The second tells us <em>"RAX, RCX, RDX, R8, R9, R10, R11 are considered volatile and must be considered destroyed on function calls"</em>. Unfortunately, it does not <em>clearly</em> state whether they need to be preserved. (If you look closely, its using misdirection rather than stating the action to take).</p>
  
  <p>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?</p>