title: Inline Aseembly What do I do about an "Illegal instruction (core dumped)"
body: <p>Are there anything wrong with below inline assembly code?
  I encountered "Illegal instruction (core dumped)" when running the function spinlock_lock.</p>
  
  <pre><code>void spinlock_lock(struct spinlock * lock) {
  
      int a;
      __asm__ __volatile__("movl %0, %%eax;"
                           "test %%eax, %%eax;"
                           "jnz spinlock_lock;"
                           :"=r"(a)
                           :"r"(lock-&gt;cmos_lock)
                           :"eax");
  
      __asm__ __volatile__ ("lock; cmpxchg %%edx, %0\n"
                            :"=r"(a)
                            :"r"(lock-&gt;cmos_lock)
                            :"edx", "memory");
  </code></pre>