Move CPRS flags helpers wheremakes sense to

have them static.
This commit is contained in:
riccardom 2010-04-18 11:51:47 +00:00
parent 5cd32213da
commit 09b06acd47
2 changed files with 25 additions and 25 deletions

View File

@ -45,31 +45,6 @@ inline T SIGNED_OVERFLOW(T a,T b,T c) { return BIT31(((a)&(b)&(~c)) | ((~a)&(~(b
template<typename T>
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

View File

@ -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
//-----------------------------------------------------------------------------