diff --git a/desmume/src/armcpu.h b/desmume/src/armcpu.h index e5914ed46..26649939b 100644 --- a/desmume/src/armcpu.h +++ b/desmume/src/armcpu.h @@ -45,31 +45,6 @@ inline T SIGNED_OVERFLOW(T a,T b,T c) { return BIT31(((a)&(b)&(~c)) | ((~a)&(~(b template inline T SIGNED_UNDERFLOW(T a,T b,T c) { return BIT31(((a)&(~(b))&(~c)) | ((~a)&(b)&(c))); } -// ============================= CPRS flags funcs -static bool CarryFrom(s32 left, s32 right) -{ - u32 res = (0xFFFFFFFF - (u32)left); - - return ((u32)right > res); -} - -static bool BorrowFrom(s32 left, s32 right) -{ - return ((u32)right > (u32)left); -} - -static bool OverflowFromADD(s32 alu_out, s32 left, s32 right) -{ - return ((left >= 0 && right >= 0) || (left < 0 && right < 0)) - && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0)); -} - -static bool OverflowFromSUB(s32 alu_out, s32 left, s32 right) -{ - return ((left < 0 && right >= 0) || (left >= 0 && right < 0)) - && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0)); -} - //zero 15-feb-2009 - these werent getting used and they were getting in my way //#define EQ 0x0 //#define NE 0x1 diff --git a/desmume/src/thumb_instructions.cpp b/desmume/src/thumb_instructions.cpp index a244d64e4..16a620611 100644 --- a/desmume/src/thumb_instructions.cpp +++ b/desmume/src/thumb_instructions.cpp @@ -38,6 +38,31 @@ #define REG_NUM(i, n) (((i)>>n)&0x7) +// ============================= CPRS flags funcs +static bool CarryFrom(s32 left, s32 right) +{ + u32 res = (0xFFFFFFFF - (u32)left); + + return ((u32)right > res); +} + +static bool BorrowFrom(s32 left, s32 right) +{ + return ((u32)right > (u32)left); +} + +static bool OverflowFromADD(s32 alu_out, s32 left, s32 right) +{ + return ((left >= 0 && right >= 0) || (left < 0 && right < 0)) + && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0)); +} + +static bool OverflowFromSUB(s32 alu_out, s32 left, s32 right) +{ + return ((left < 0 && right >= 0) || (left >= 0 && right < 0)) + && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0)); +} + //----------------------------------------------------------------------------- // Undefined instruction //-----------------------------------------------------------------------------