Skip to content
Permalink
Browse files
Merge pull request #6470 from lioncash/ov-flag
Interpreter: Handle setting the overflow flag when the OE bit is set in divw, divwu, and neg
  • Loading branch information
degasus committed Mar 20, 2018
2 parents 5a4b59c + 2fa0cb9 commit 35bfa64
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
@@ -499,8 +499,7 @@ void Interpreter::divwx(UGeckoInstruction inst)
{
if (inst.OE)
{
// should set OV
PanicAlert("OE: divwx");
SetXER_OV(true);
}

if (((u32)a & 0x80000000) && b == 0)
@@ -526,8 +525,7 @@ void Interpreter::divwux(UGeckoInstruction inst)
{
if (inst.OE)
{
// should set OV
PanicAlert("OE: divwux");
SetXER_OV(true);
}

rGPR[inst.RD] = 0;
@@ -582,16 +580,15 @@ void Interpreter::mullwx(UGeckoInstruction inst)

void Interpreter::negx(UGeckoInstruction inst)
{
rGPR[inst.RD] = (~rGPR[inst.RA]) + 1;
const u32 a = rGPR[inst.RA];

if (rGPR[inst.RD] == 0x80000000)
{
if (inst.OE)
PanicAlert("OE: negx");
}
rGPR[inst.RD] = (~a) + 1;

if (inst.Rc)
Helper_UpdateCR0(rGPR[inst.RD]);

if (inst.OE && a == 0x80000000)
SetXER_OV(true);
}

void Interpreter::subfx(UGeckoInstruction inst)
@@ -417,14 +417,25 @@ inline void SetXER(UReg_XER new_xer)
PowerPC::ppcState.xer_so_ov = (new_xer.SO << 1) + new_xer.OV;
}

inline int GetXER_SO()
inline u32 GetXER_SO()
{
return PowerPC::ppcState.xer_so_ov >> 1;
}

inline void SetXER_SO(int value)
inline void SetXER_SO(bool value)
{
PowerPC::ppcState.xer_so_ov |= value << 1;
PowerPC::ppcState.xer_so_ov |= static_cast<u32>(value) << 1;
}

inline u32 GetXER_OV()
{
return PowerPC::ppcState.xer_so_ov & 1;
}

inline void SetXER_OV(bool value)
{
PowerPC::ppcState.xer_so_ov |= static_cast<u32>(value);
SetXER_SO(value);
}

void UpdateFPRF(double dvalue);

0 comments on commit 35bfa64

Please sign in to comment.