title: Correct way to implement inline assembler in c++ for xor operations on variables
body: <p>I've recently seen an article on how the swap operation can be performed using xor'ing instead of using a temporary variable. When I compile code using <code>int a ^= b;</code> the result won't simply be(for at&amp;t syntax)</p>
  
  <pre><code>xor b, a
  etc.
  </code></pre>
  
  <p>instead it will load the raw values into registers, xor it and write it back.
  To optimize this i want to write this in inline assembly so it only uses three ticks to do the entire thing and not 15 like it does normally.</p>
  
  <p>I've tried multiple keywords like:</p>
  
  <pre><code>asm(...);
  asm("...");
  asm{...};
  asm{"..."};
  asm ...
  __asm ...
  </code></pre>
  
  <p>None of that worked, either giving me a syntax error, gcc doesn't seem to accept all of that syntax or else saying</p>
  
  <pre><code>main.cpp: Assembler messages:
  main.cpp:12: Error: too many memory references for `xor'
  </code></pre>
  
  <p>Basically, I want to use the variables defined in my c++ code used in the assembler block, using three lines to xor them and then have my swapped variables basically like this:</p>
  
  <pre><code>int main() {
      volatile int a = 5;
      volatile int b = 6;
      asm {
          xor a,b
          xor b,a
          xor a,b
      };
      //a should now be 6, b should be 5
  }
  </code></pre>
  
  <p>To clarify:
  I want to avoid using the compiler generated mov operations since they take more cpu cycles than just doing three xor operations which would take three cycles. How could I accomplish this?</p>