asm ---expressing asm language
volatile----telling complier not to optimize my asm coding
lock-------asm instruction, expressing synchronous operation
xchg-------asm insturction, expressing to exchange the values in *ptr and val varible
%0---------expressing *ptr variable
%1---------expressing val variable
"r"(val)--------expressing to input val variable into common register in system
"m"(*ptr)------expressing that the data pointed by the pointer of ptr varable are stored in memory
"=r"(val) and "=m"(*ptr)----expressing that the data exchanged will be store val and *ptr variable ,
"m" expresses to use memory to store the data of *ptr variable
"r" expresssed to use common register to store the data of val variable
以上是汇编板块的回答,还有一些搞不清楚的如下:
1、
%0---------expressing *ptr variable
%1---------expressing val variable
传入的是ptr,%0为什么不表示ptr