title: Assembly AT&T: movq %rdi, %rdx?
body: <p>AT&amp;T x86 prime assembly, </p>
  
  <p>I want to translate assembly</p>
  
  <pre><code>line 1: subq $8, %rsp 
  line 2: movq %r11, (%rsp)
  line 3: movq %rdi, %rdx
  line 4: sarq $63, %rdx
  line 5: movq %rdi,%rax
  line 6: xorq %rdx,%rax
  line 7: subq %rdx,%rax
  line 8: movq (%rsp), %r11
  line 9: add $8, %rsp
  line 10: ret %r11
  </code></pre>
  
  <p>From what I <em>think</em> I understand, %rsp is the stackpointer, and the stackpointer here creates 8 bytes of space for a qword byte. </p>
  
  <p>Could it look like this in C?</p>
  
  <pre><code>int main() {
  
      long x;
  
  return 0:
  }
  </code></pre>
  
  <p>What then happens at line 3 I'm not sure. I think the %rdi register goes into  %rdx. But how would this look like in C code? Nothing is tied to the register as I see it?</p>
  
  <p>Hope someone can help me walk through line 1-3!</p>