summaryrefslogtreecommitdiffstats
path: root/src/core/arm/interpreter
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2014-12-28 17:57:25 +0100
committerbunnei <bunneidev@gmail.com>2014-12-28 17:57:25 +0100
commit762f16c4ad84d50490c7a1db9d636e6c41c8aa09 (patch)
treebc8c7c383f85f593b1a30cb6e7c857ddc19c91ff /src/core/arm/interpreter
parentMerge pull request #350 from lioncash/qops (diff)
parentarmemu: Fix underflows in USAD8/USADA8 (diff)
downloadyuzu-762f16c4ad84d50490c7a1db9d636e6c41c8aa09.tar
yuzu-762f16c4ad84d50490c7a1db9d636e6c41c8aa09.tar.gz
yuzu-762f16c4ad84d50490c7a1db9d636e6c41c8aa09.tar.bz2
yuzu-762f16c4ad84d50490c7a1db9d636e6c41c8aa09.tar.lz
yuzu-762f16c4ad84d50490c7a1db9d636e6c41c8aa09.tar.xz
yuzu-762f16c4ad84d50490c7a1db9d636e6c41c8aa09.tar.zst
yuzu-762f16c4ad84d50490c7a1db9d636e6c41c8aa09.zip
Diffstat (limited to 'src/core/arm/interpreter')
-rw-r--r--src/core/arm/interpreter/armemu.cpp8
-rw-r--r--src/core/arm/interpreter/armsupp.cpp9
2 files changed, 13 insertions, 4 deletions
diff --git a/src/core/arm/interpreter/armemu.cpp b/src/core/arm/interpreter/armemu.cpp
index 5d26456c7..2873da897 100644
--- a/src/core/arm/interpreter/armemu.cpp
+++ b/src/core/arm/interpreter/armemu.cpp
@@ -6672,10 +6672,10 @@ L_stm_s_takeabort:
const u32 rm_val = state->Reg[rm_idx];
const u32 rn_val = state->Reg[rn_idx];
- const u8 diff1 = (u8)std::labs((rn_val & 0xFF) - (rm_val & 0xFF));
- const u8 diff2 = (u8)std::labs(((rn_val >> 8) & 0xFF) - ((rm_val >> 8) & 0xFF));
- const u8 diff3 = (u8)std::labs(((rn_val >> 16) & 0xFF) - ((rm_val >> 16) & 0xFF));
- const u8 diff4 = (u8)std::labs(((rn_val >> 24) & 0xFF) - ((rm_val >> 24) & 0xFF));
+ const u8 diff1 = ARMul_UnsignedAbsoluteDifference(rn_val & 0xFF, rm_val & 0xFF);
+ const u8 diff2 = ARMul_UnsignedAbsoluteDifference((rn_val >> 8) & 0xFF, (rm_val >> 8) & 0xFF);
+ const u8 diff3 = ARMul_UnsignedAbsoluteDifference((rn_val >> 16) & 0xFF, (rm_val >> 16) & 0xFF);
+ const u8 diff4 = ARMul_UnsignedAbsoluteDifference((rn_val >> 24) & 0xFF, (rm_val >> 24) & 0xFF);
u32 finalDif = (diff1 + diff2 + diff3 + diff4);
diff --git a/src/core/arm/interpreter/armsupp.cpp b/src/core/arm/interpreter/armsupp.cpp
index 186b1bd73..8f158e2c8 100644
--- a/src/core/arm/interpreter/armsupp.cpp
+++ b/src/core/arm/interpreter/armsupp.cpp
@@ -392,6 +392,15 @@ ARMul_NthReg (ARMword instr, unsigned number)
return (bit - 1);
}
+/* Unsigned sum of absolute difference */
+u8 ARMul_UnsignedAbsoluteDifference(u8 left, u8 right)
+{
+ if (left > right)
+ return left - right;
+
+ return right - left;
+}
+
/* Assigns the N and Z flags depending on the value of result. */
void