Link to home
Start Free TrialLog in
Avatar of shiningram
shiningram

asked on

Atomic operations in assembly

Hi,
I want to write atomic operations (incr, dec, xchg, mod) which should support on almost all architectures.
Can anyone point me to resource available on thsi on net or in EE?

Someone explain what each following line is doing?

int32 func()
{
   int32 val = -1;

    asm volatile ("lock; xaddl %0,%1"
              : "=r" (val), "=m" (*mem)
              : "0" (val), "m" (*mem)
              : "memory", "cc");
 return val;
}

=r
=m
"0"
"m"
"memory"

What all these  above do? Can someone explains all these? I am looking for resource/tutorial to understand these.

Thanks,
Ram
SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shiningram
shiningram

ASKER

Ravenpl you gave a great start and NovaDenizen you are awesome. You will be rewarded points when i close the question.
Can some one help writting increment and decrement atomic operations for linux and windos for 32 and 64 architecture.
Thanks,
Ram
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Another question added to get clear suggestion from experts