c - What's the meaning of the following code? -
there cas code below can handle int type,i know function of cas don't know details shown below.
inline int cas(unsigned long *mem,unsigned long newval,unsigned long oldval) { __typeof (*mem) ret; __asm __volatile ("lock; cmpxchgl %2, %1" : "=a" (ret), "=m" (*mem) : "r" (newval), "m" (*mem), "0" (oldval)); return (int) ret; }
i know there should 5 parameters mapped %0,%1,%2,%3,%4 because there 5 parameters in input/output field
i know "=a"
means using eax
register,"=m"
means using memory address,"r"
means using register
but don't understand "0" means.
i don't understand why "cmpxchgl" use 2 parameters %2, %1 instead of three?
it should use 3 params cas function.
where can infimation inline c asm?i need complete tutorial.
Comments
Post a Comment