title: Write System Call Argument Registers
body: <p>I have a piece of assembly code which does a <a href="https://en.wikipedia.org/wiki/Write_(system_call)" rel="nofollow">write system call</a> (is that correct?) via</p>
  
  <pre><code>call write@plt
  </code></pre>
  
  <p>Before doing so, the values of <code>rax</code>, address <code>rsp</code>, <code>edi</code>, <code>rsi</code> and <code>rdx</code> are set/modified.</p>
  
  <p>How do I know which registers are used as arguments for write or system function calls in general?</p>
  
  <p>My guess is that for write it's <code>rsp</code>, <code>edi</code> and <code>rsi</code> since in <a href="https://en.wikipedia.org/wiki/C_(programming_language)" rel="nofollow"><code>C</code></a> it takes 3 arguments:</p>
  
  <pre><code>ssize_t write(int fd, const void *buf, size_t nbytes);
  </code></pre>