c00lsnoopy
April 9th, 2009, 03:04 PM
Hi everyone,
I want to know if I have converted the following ASM code correctly from gcc ASM to MSV ASM.
Thanks a lot.
rxbagain
April 10th, 2009, 01:41 AM
The conversion works correctly but it can introduce error in case somebody tries to change the structure of oro_atomic_t and add some other members in the beginning of the structure.
To make sure that it always point to oro_atomic_t.counter, you have to explicitly index the counter member. Here's the change in the oro_atomic_add function
lock add dword ptr [eax][oro_atomic_t.counter], ecx
Apply the indexing in all of your functions.
Hope it will help you :)
Edit: It is also better to remove the "dword ptr" so that the compiler validates the variable type against the other operand (ECX in case of your oro_atomic_add). It will show an error in case counter is not a 32 bit variable.
lock add [eax][oro_atomic_t.counter], ecx
c00lsnoopy
April 14th, 2009, 10:26 AM
thanks a llot for your input :)