title: How can I solve this compiler error when trying to execute an xchg command in x86 assembly?
body: <p>I'm writing a semaphore and I need to run the following command:</p>
  
  <pre><code>xchg rax, [rdi]
  </code></pre>
  
  <p>However, the compiler tells me that this line produces the error "impossible combination of address sizes"</p>
  
  <p>Makes sense, I tell to myself, since the thing on the right hand is a byte and rax is a dword</p>
  
  <p>So I write the following, that should fix it:</p>
  
  <pre><code>xchg rax, qword [rdi]
  </code></pre>
  
  <p>But it throws the same error</p>
  
  <p>Isn't rax a 64-byte register? Why is it throwing this error then?</p>