您如何解释该程序集?

| 从nginx中提取:
static ngx_inline ngx_atomic_uint_t
ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
ngx_atomic_uint_t set)
{
    u_char res;
    __asm__ volatile (
    NGX_SMP_LOCK
    \" cmpxchgl %3, %1; \"
    \" sete %0; \"
    : \"=a\" (res) : \"m\" (*lock), \"a\" (old), \"r\" (set) : \"cc\", \"memory\");
    return res;
}
我不理解汇编指令被组合的语法(它使用的语法与
printf
使用的语法不同),它到底在做什么?     
已邀请:
鉴于此并忽略了操作的原子性,函数等效于:
 static ngx_inline ngx_atomic_uint_t
 ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
 ngx_atomic_uint_t set)
 {
     u_char res;
     if (*lock == old){
         *lock = set;
         res = 1;
     } else{
         res = *lock
     }
     return res;
  }
    

要回复问题请先登录注册