title: x86_64 assembly conventions saving argument registers
body: <p>I'm writing some x86_64 assembly to call a C function. My C function takes in 1 argument, so the assembly places the argument in <code>%rdi</code>. The ABI pdf (linked below) says that the other 6 argument registers (rsi, rdx, rcx, r8, r9) are not preserved across function calls. However, since my C function only takes one <code>long</code> argument, do I have any guarantees about whether or not the C function will clobber the other 5 registers? My assumption was that the argument registers are only clobbered if an argument's value is changed:</p>
  
  <pre><code>void foo(int a, int b) {
      a++; /* %rdi will be changed, but %rsi won't be changed when control returns. */
  }
  </code></pre>
  
  <p>I'm asking because I'd like to preserve the values of the other 5 argument registers across my C function call (without having to explicitly push/pop them from the stack manually).</p>
  
  <p>x86_64 ABI - <a href="http://www.x86-64.org/documentation/abi-0.99.pdf" rel="nofollow">http://www.x86-64.org/documentation/abi-0.99.pdf</a></p>