title: What do the instructions mov %edi and mov %rsi do?
body: <p>I've written a basic C program that defines an integer variable x, sets it to zero and returns the value of that variable:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char **argv) {
      int x;
      x = 0;
      return x;
  }
  </code></pre>
  
  <p>When I dump the object code using objdump (compiled on Linux X86-64 with gcc):</p>
  
  <pre><code>0x0000000000400474 &lt;main+0&gt;:    push   %rbp
  0x0000000000400475 &lt;main+1&gt;:    mov    %rsp,%rbp
  0x0000000000400478 &lt;main+4&gt;:    mov    %edi,-0x14(%rbp)
  0x000000000040047b &lt;main+7&gt;:    mov    %rsi,-0x20(%rbp)
  0x000000000040047f &lt;main+11&gt;:   movl   $0x0,-0x4(%rbp)
  0x0000000000400486 &lt;main+18&gt;:   mov    -0x4(%rbp),%eax
  0x0000000000400489 &lt;main+21&gt;:   leaveq 
  0x000000000040048a &lt;main+22&gt;:   retq
  </code></pre>
  
  <p>I can see the function prologue, but before we set x to 0 at address <code>0x000000000040047f</code> there are two instructions that move %edi and %rsi onto the stack. What are these for?</p>
  
  <p>In addition, unlike where we set x to 0, the mov instruction as shown in GAS syntax does not have a suffix.</p>
  
  <blockquote>
    <p>If the suffix is not specified, and there are no memory operands for the instruction, GAS infers the operand size from the size of the destination register operand.</p>
  </blockquote>
  
  <p>In this case, are <code>-0x14(%rsbp)</code> and <code>-0x20(%rbp)</code> both memory operands and what are their sizes? Since %edi is a 32 bit register, are 32 bits moved to <code>-0x14(%rsbp)</code> whereas since %rsi is a 64 bit register, 64 bits are moved to <code>%rsi,-0x20(%rbp)</code>?</p>