Introducing SM_ASM_X86, a compiler-agnostic inline assembly macro

This commit is contained in:
Ben "root" Anderson
2013-10-25 18:05:56 -05:00
parent 469260911a
commit 3a730b3c3c
4 changed files with 25 additions and 21 deletions
+5 -5
View File
@@ -364,7 +364,7 @@ long __stdcall CrashHandler::ExceptionHandler( EXCEPTION_POINTERS *pExc )
int iSize = 1024*32;
char *pStack = (char *) VirtualAlloc( NULL, iSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE );
pStack += iSize;
_asm mov esp, pStack;
SM_ASM_X86(mov esp, pStack);
return MainExceptionHandler( pExc );
}
@@ -532,10 +532,10 @@ void CrashHandler::do_backtrace( const void **buf, size_t size,
static void NORETURN debug_crash()
{
__try {
__asm xor ebx,ebx
__asm mov eax,dword ptr [ebx]
// __asm mov dword ptr [ebx],eax
// __asm lock add dword ptr cs:[00000000h], 12345678h
SM_ASM_X86(xor ebx,ebx);
SM_ASM_X86(mov eax,dword ptr [ebx]);
// SM_ASM_X86(mov dword ptr [ebx],eax);
// SM_ASM_X86(lock add dword ptr cs:[00000000h], 12345678h);
} __except( CrashHandler::ExceptionHandler((EXCEPTION_POINTERS*)_exception_info()) ) {
}
}
+7 -10
View File
@@ -145,8 +145,8 @@ inline long int lrintf( float f )
{
int retval;
_asm fld f;
_asm fistp retval;
SM_ASM_X86(fld f);
SM_ASM_X86(fistp retval);
return retval;
}
@@ -175,21 +175,19 @@ inline long int lrintf( float f )
inline uint32_t ArchSwap32( uint32_t n )
{
__asm
{
SM_ASM_X86(
mov eax, n
xchg al, ah
ror eax, 16
xchg al, ah
mov n, eax
};
);
return n;
}
inline uint32_t ArchSwap24( uint32_t n )
{
__asm
{
SM_ASM_X86(
mov eax, n
xchg al, ah
ror eax, 16
@@ -202,12 +200,11 @@ inline uint32_t ArchSwap24( uint32_t n )
inline uint16_t ArchSwap16( uint16_t n )
{
__asm
{
SM_ASM_X86(
mov ax, n
xchg al, ah
mov n, ax
};
);
return n;
}
#endif