Skip to content

Instantly share code, notes, and snippets.

@riking
Forked from FioraAeterna/gist:0329ce18a51d734b6a54
Last active August 29, 2015 14:12
Show Gist options
  • Save riking/db685f82ff7acb16993f to your computer and use it in GitHub Desktop.
Save riking/db685f82ff7acb16993f to your computer and use it in GitHub Desktop.
// u8 xer_so_ov; // format: (SO << 1) | OV
diff --git a/Source/Core/Core/PowerPC/PowerPC.h b/Source/Core/Core/PowerPC/PowerPC.h
index 69eb0da..071582d 100644
--- a/Source/Core/Core/PowerPC/PowerPC.h
+++ b/Source/Core/Core/PowerPC/PowerPC.h
@@ -306,6 +306,20 @@ inline int GetXER_SO()
inline void SetXER_SO(int value)
{
+ PowerPC::ppcState.xer_so_ov &= ~2;
PowerPC::ppcState.xer_so_ov |= value << 1;
+}
+
+inline int GetOverflow()
+{
+ return PowerPC::ppcState.xer_so_ov & 1;
+}
+
+inline int GetSummaryOverflow()
+{
+ return (PowerPC::ppcState.xer_so_ov & 2) >> 1;
+}
+
+/**
+ * Update the OV and SO bits with the result of an operation.
+ *
+ * OV is set to the parameter, and SO is turned on if the parameter is 1.
+ */
+inline void SetOverflow(int value)
+{
+ PowerPC::ppcState.xer_so_ov &= 2; // keep SO
+ // set OV and SO
+ PowerPC::ppcState.xer_so_ov |= (value | (value << 1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment