Intel x86比较交换指令cmpxchg的作用与原理 - 掘金 https://juejin.cn/post/6905287769006800903
lock.ppt https://heather.cs.ucdavis.edu/~matloff/50/PLN/lock.pdf
https://github.com/torvalds/linux/blob/master/arch/x86/include/asm/cmpxchg.h
cmpxchg dest,src
将AL、AX、EAX或RAX寄存器中的值与第一个操作数dest(目标操作数)进行比较。
如果两个值相等,则将第二个操作数src(源操作数)加载到目标操作数中。
如果不相等,则目标操作数被加载到AL、AX、EAX或RAX寄存器中。 RAX寄存器仅在64位模式下可用。
Instruction format • Intel’s assembly language syntax differs from the GNU/Linux syntax (known as ‘AT&T syntax’ with roots in UNIX history) • When AT&T syntax is used, the ‘cmpxchg’ instruction has this layout: [lock] cmpxchg reg, reg/mem optional ‘prefix’ (used for SMP) mnemonic opcode source operand destination operand
An instruction-instance • In our recent disassembly of Linux’s kernel function ‘rtc_cmos_read()’ , this ‘cmpxchg’ instruction-instance was used: lock cmpxchg %edx, cmos_lock prefix opcode source-operand destination-operand Note: Keep in mind that the accumulator %eax will affect what happens! So we need to consider this instruction within it’s surrounding context
标签:操作数,lock,instruction,交换,syntax,指令,cmpxchg,operand From: https://www.cnblogs.com/rsapaper/p/17218404.html