Martin Sustrik wrote:
Andrew Haley wrote:
Please don't top-post.
Martin Sustrik wrote:
Andrew,
Thanks for prompt response. However, I am not sure how to use the
earlyclobber modifier - this is actually the first gcc inline asembly
code I've ever written.
Do you mean that I should add '&' sign to every operand in input
operand list, or should I add the sign when using the operands or what?
Use "=&a" on the first operand.
Ok, I've modified the code this way:
__asm__ volatile (
"lock; cmpxchgl %1, %3\n\t"
"jz 1f\n\t"
"mov %2, %%eax\n\t"
"lock; xchgl %%eax, %3\n\t"
"1:\n\t"
: "=&a" (oldval)
: "r" (thenval_), "r" (elseval_), "m" (value), "0" (0)
Ah, maybe I told you wrong: I see that Opernad 0 is also an input. Sorry.
: "memory", "cc");
However, the generated code is exactly the same as before.
I certainly don't get that. Please post a complete test case, with
assembly output. We also need to know exactly your version of gcc.
Andrew.