summaryrefslogtreecommitdiffstats
path: root/src/core/arm/interpreter/armsupp.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2014-12-29 20:53:04 +0100
committerbunnei <bunneidev@gmail.com>2014-12-29 20:53:04 +0100
commit2d2aa2c0beae1bc7913e043444dadfab509afa8c (patch)
treef5428b3fd197cf3f7f00002b71cc7fdc754bd890 /src/core/arm/interpreter/armsupp.cpp
parentMerge pull request #363 from lioncash/label (diff)
parentdyncom: Implement QADD8/QSUB8 (diff)
downloadyuzu-2d2aa2c0beae1bc7913e043444dadfab509afa8c.tar
yuzu-2d2aa2c0beae1bc7913e043444dadfab509afa8c.tar.gz
yuzu-2d2aa2c0beae1bc7913e043444dadfab509afa8c.tar.bz2
yuzu-2d2aa2c0beae1bc7913e043444dadfab509afa8c.tar.lz
yuzu-2d2aa2c0beae1bc7913e043444dadfab509afa8c.tar.xz
yuzu-2d2aa2c0beae1bc7913e043444dadfab509afa8c.tar.zst
yuzu-2d2aa2c0beae1bc7913e043444dadfab509afa8c.zip
Diffstat (limited to 'src/core/arm/interpreter/armsupp.cpp')
-rw-r--r--src/core/arm/interpreter/armsupp.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/core/arm/interpreter/armsupp.cpp b/src/core/arm/interpreter/armsupp.cpp
index 8f158e2c8..8b3661c8f 100644
--- a/src/core/arm/interpreter/armsupp.cpp
+++ b/src/core/arm/interpreter/armsupp.cpp
@@ -478,6 +478,66 @@ ARMul_SubOverflow (ARMul_State * state, ARMword a, ARMword b, ARMword result)
ASSIGNV (SubOverflow (a, b, result));
}
+/* 8-bit signed saturated addition */
+u8 ARMul_SignedSaturatedAdd8(u8 left, u8 right)
+{
+ u8 result = left + right;
+
+ if (((result ^ left) & 0x80) && ((left ^ right) & 0x80) == 0) {
+ if (left & 0x80)
+ result = 0x80;
+ else
+ result = 0x7F;
+ }
+
+ return result;
+}
+
+/* 8-bit signed saturated subtraction */
+u8 ARMul_SignedSaturatedSub8(u8 left, u8 right)
+{
+ u8 result = left - right;
+
+ if (((result ^ left) & 0x80) && ((left ^ right) & 0x80) != 0) {
+ if (left & 0x80)
+ result = 0x80;
+ else
+ result = 0x7F;
+ }
+
+ return result;
+}
+
+/* 16-bit signed saturated addition */
+u16 ARMul_SignedSaturatedAdd16(u16 left, u16 right)
+{
+ u16 result = left + right;
+
+ if (((result ^ left) & 0x8000) && ((left ^ right) & 0x8000) == 0) {
+ if (left & 0x8000)
+ result = 0x8000;
+ else
+ result = 0x7FFF;
+ }
+
+ return result;
+}
+
+/* 16-bit signed saturated subtraction */
+u16 ARMul_SignedSaturatedSub16(u16 left, u16 right)
+{
+ u16 result = left - right;
+
+ if (((result ^ left) & 0x8000) && ((left ^ right) & 0x8000) != 0) {
+ if (left & 0x8000)
+ result = 0x8000;
+ else
+ result = 0x7FFF;
+ }
+
+ return result;
+}
+
/* 8-bit unsigned saturated addition */
u8 ARMul_UnsignedSaturatedAdd8(u8 left, u8 right)
{