10 September 2014

Resources

Related parts in GCC manual:

Tips

lea respests AT&T syntax

asm ("leal (%1,%1,4), %0"
     : "=r" (x)   /* %0 allocated for it */
     : "0" (x));  /* %1 allocated for it. And use the same register as %0*/

Multiply x by 5.

asm volatile("lock; xchgl %0, %1" :
             "+m" (*addr) /* %0 allocated for it */, "=a" (result) /* %1 allocated for it */:
             "1" (newval) /* Use the same register as %1. And no %n token is allocated for it*/:
             "cc");