inline unsigned char BSS_FASTCALL asmcas(int *pval, int newval, int oldval) { unsigned char rval; __asm { #ifdef BSS_NO_FASTCALL //if we are using fastcall we don't need these instructions mov EDX, newval mov ECX, pval #endif mov EAX, oldval lock cmpxchg [ECX], EDX sete rval // Note that sete sets a 'byte' not the word } return rval; } This was an absolute bitch to get working in VC++, so maybe this will be useful to someone, somewhere, somehow.