I am doing some cross-platform work, porting code from Linux to Win32, but when it comes to some assembly code, I cannot get it to work.
This code compiles normally in Linux gcc, but will not work in VS2008 –win32.
Some of my code is below. What do I need to do if I want to compile it using VS2008 –win32 platform:
static inline void spin_wait(int n)
{
int tmp = n;
while(tmp > 0) { tmp--; asm("" ::: "memory", "cc"); }
}
__asm__ __volatile__(
"xorq %%rdx, %%rdx \n"
"xorq %%rax, %%rax \n"
"incq %%rdx \n"
"lock cmpxchgq %%rdx, (%1) \n"
"decq %%rax \n"
: "=a" (not_set) : "r" (n) : "%rdx");
If your question is about the use of inline assembly, you can still use it in Visual Studio (MSDN link) although you may need to tweak it for the platform of course.
For example: