DSPLLE added carry and overflow now we (lordmark) should add them in

the right ops ;) 


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4222 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2009-09-07 10:46:22 +00:00
parent 4c36a5280c
commit 49601e0af2
2 changed files with 36 additions and 5 deletions

View File

@ -26,7 +26,7 @@
namespace DSPInterpreter { namespace DSPInterpreter {
void Update_SR_Register64(s64 _Value) void Update_SR_Register64(s64 _Value, bool carry, bool overflow)
{ {
// TODO: Should also set 0x10 and 0x01 (also 0x02?) // TODO: Should also set 0x10 and 0x01 (also 0x02?)
g_dsp.r[DSP_REG_SR] &= ~SR_CMP_MASK; g_dsp.r[DSP_REG_SR] &= ~SR_CMP_MASK;
@ -41,6 +41,16 @@ void Update_SR_Register64(s64 _Value)
g_dsp.r[DSP_REG_SR] |= SR_ARITH_ZERO; g_dsp.r[DSP_REG_SR] |= SR_ARITH_ZERO;
} }
if (carry)
{
g_dsp.r[DSP_REG_SR] |= SR_CARRY;
}
if (overflow)
{
g_dsp.r[DSP_REG_SR] |= SR_OVERFLOW;
}
// Checks if top bits are equal, what is it good for? // Checks if top bits are equal, what is it good for?
if (((_Value >> 62) == 0) || (_Value >> 62 == 3)) if (((_Value >> 62) == 0) || (_Value >> 62 == 3))
{ {
@ -49,11 +59,10 @@ void Update_SR_Register64(s64 _Value)
} }
void Update_SR_Register16(s16 _Value) void Update_SR_Register16(s16 _Value, bool carry, bool overflow)
{ {
g_dsp.r[DSP_REG_SR] &= ~SR_CMP_MASK; g_dsp.r[DSP_REG_SR] &= ~SR_CMP_MASK;
// Only sets those 3 bits
if (_Value < 0) if (_Value < 0)
{ {
@ -65,6 +74,16 @@ void Update_SR_Register16(s16 _Value)
g_dsp.r[DSP_REG_SR] |= SR_ARITH_ZERO; g_dsp.r[DSP_REG_SR] |= SR_ARITH_ZERO;
} }
if (carry)
{
g_dsp.r[DSP_REG_SR] |= SR_CARRY;
}
if (overflow)
{
g_dsp.r[DSP_REG_SR] |= SR_OVERFLOW;
}
// Checks if top bits are equal, what is it good for? // Checks if top bits are equal, what is it good for?
if (((_Value >> 14) == 0) || ((_Value >> 14) == 3)) if (((_Value >> 14) == 0) || ((_Value >> 14) == 3))
{ {

View File

@ -30,10 +30,22 @@ bool CheckCondition(u8 _Condition);
int GetMultiplyModifier(); int GetMultiplyModifier();
void Update_SR_Register16(s16 _Value); void Update_SR_Register16(s16 _Value, bool carry = false, bool overflow = false);
void Update_SR_Register64(s64 _Value); void Update_SR_Register64(s64 _Value, bool carry = false, bool overflow = false);
void Update_SR_LZ(s64 value); void Update_SR_LZ(s64 value);
inline bool isAddCarry(u64 val, u64 result) {
return (val > result);
}
inline bool isSubCarry(u64 val, u64 result) {
return (val < result);
}
inline bool isOverflow(s64 val1, s64 val2, s64 res) {
return ((val1 ^ res) & (val2 ^ res)) < 0;
}
} // namespace } // namespace
#endif // _GDSP_CONDITION_CODES_H #endif // _GDSP_CONDITION_CODES_H