summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2014-12-18 23:46:10 +0100
committerbunnei <bunneidev@gmail.com>2014-12-18 23:46:10 +0100
commit24b5e872794f71b099c2fa967886c1c47b604395 (patch)
tree72abdfbf2503c01a175b7b67762ea564f25bc9e1 /src
parentMerge pull request #307 from lioncash/usat16 (diff)
parentarmemu: Set GE flags correctly for SSUB16, SADD16, SSAX, and SASX. (diff)
downloadyuzu-24b5e872794f71b099c2fa967886c1c47b604395.tar
yuzu-24b5e872794f71b099c2fa967886c1c47b604395.tar.gz
yuzu-24b5e872794f71b099c2fa967886c1c47b604395.tar.bz2
yuzu-24b5e872794f71b099c2fa967886c1c47b604395.tar.lz
yuzu-24b5e872794f71b099c2fa967886c1c47b604395.tar.xz
yuzu-24b5e872794f71b099c2fa967886c1c47b604395.tar.zst
yuzu-24b5e872794f71b099c2fa967886c1c47b604395.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/arm/interpreter/armemu.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/core/arm/interpreter/armemu.cpp b/src/core/arm/interpreter/armemu.cpp
index 99fc6c45d..07d205755 100644
--- a/src/core/arm/interpreter/armemu.cpp
+++ b/src/core/arm/interpreter/armemu.cpp
@@ -5839,21 +5839,46 @@ L_stm_s_takeabort:
const s16 rm_lo = (state->Reg[rm_idx] & 0xFFFF);
const s16 rm_hi = ((state->Reg[rm_idx] >> 16) & 0xFFFF);
+ s32 lo_result;
+ s32 hi_result;
+
// SSUB16
if ((instr & 0xFF0) == 0xf70) {
- state->Reg[rd_idx] = ((rn_lo - rm_lo) & 0xFFFF) | (((rn_hi - rm_hi) & 0xFFFF) << 16);
+ lo_result = (rn_lo - rm_lo);
+ hi_result = (rn_hi - rm_hi);
}
// SADD16
else if ((instr & 0xFF0) == 0xf10) {
- state->Reg[rd_idx] = ((rn_lo + rm_lo) & 0xFFFF) | (((rn_hi + rm_hi) & 0xFFFF) << 16);
+ lo_result = (rn_lo + rm_lo);
+ hi_result = (rn_hi + rm_hi);
}
// SSAX
else if ((instr & 0xFF0) == 0xf50) {
- state->Reg[rd_idx] = ((rn_lo + rm_hi) & 0xFFFF) | (((rn_hi - rm_lo) & 0xFFFF) << 16);
+ lo_result = (rn_lo + rm_hi);
+ hi_result = (rn_hi - rm_lo);
}
// SASX
else {
- state->Reg[rd_idx] = ((rn_lo - rm_hi) & 0xFFFF) | (((rn_hi + rm_lo) & 0xFFFF) << 16);
+ lo_result = (rn_lo - rm_hi);
+ hi_result = (rn_hi + rm_lo);
+ }
+
+ state->Reg[rd_idx] = (lo_result & 0xFFFF) | ((hi_result & 0xFFFF) << 16);
+
+ if (lo_result >= 0) {
+ state->Cpsr |= (1 << 16);
+ state->Cpsr |= (1 << 17);
+ } else {
+ state->Cpsr &= ~(1 << 16);
+ state->Cpsr &= ~(1 << 17);
+ }
+
+ if (hi_result >= 0) {
+ state->Cpsr |= (1 << 18);
+ state->Cpsr |= (1 << 19);
+ } else {
+ state->Cpsr &= ~(1 << 18);
+ state->Cpsr &= ~(1 << 19);
}
return 1;
} else {