Calling assembly in GCC????

Posted by rbr200 on Stack Overflow See other posts from Stack Overflow or by rbr200
Published on 2010-03-22T03:08:28Z Indexed on 2010/03/22 3:11 UTC
Read the original article Hit count: 211

Filed under:
|
|

include

static inline uint xchg(volatile unsigned int *addr, unsigned int newval)

{ uint result;

asm volatile("lock; xchgl %0, %1" : "+m" (*addr), "=a" (result) : "1" (newval) : "cc");

return result;

}

Can some one tell me what this code does exactly. I mean I have an idea or the parts of this command. "1" newval is the input, "=a" is to flush out its previous value and update it. "m" is for the memory operation but I am confused about the functionality of this function. What does the "+m" sign do? Does this function do sumthing like m=a; m = newval; return a

© Stack Overflow or respective owner

Related posts about c

    Related posts about x86