diff options
author | bunnei <bunneidev@gmail.com> | 2014-12-28 03:15:13 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2014-12-28 03:15:13 +0100 |
commit | 3422d81f053578e2a6806dc9ffa33c50f2c0b66d (patch) | |
tree | 16621bd2dabe32e4a17f0014392c6c8f597e9a56 /src/core/arm/interpreter/armsupp.cpp | |
parent | Merge pull request #349 from lioncash/uhdync (diff) | |
parent | dyncom: Implement UQADD8, UQADD16, UQSUB8, UQSUB16, UQASX, and UQSAX. (diff) | |
download | yuzu-3422d81f053578e2a6806dc9ffa33c50f2c0b66d.tar yuzu-3422d81f053578e2a6806dc9ffa33c50f2c0b66d.tar.gz yuzu-3422d81f053578e2a6806dc9ffa33c50f2c0b66d.tar.bz2 yuzu-3422d81f053578e2a6806dc9ffa33c50f2c0b66d.tar.lz yuzu-3422d81f053578e2a6806dc9ffa33c50f2c0b66d.tar.xz yuzu-3422d81f053578e2a6806dc9ffa33c50f2c0b66d.tar.zst yuzu-3422d81f053578e2a6806dc9ffa33c50f2c0b66d.zip |
Diffstat (limited to 'src/core/arm/interpreter/armsupp.cpp')
-rw-r--r-- | src/core/arm/interpreter/armsupp.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/core/arm/interpreter/armsupp.cpp b/src/core/arm/interpreter/armsupp.cpp index 6774f8a74..186b1bd73 100644 --- a/src/core/arm/interpreter/armsupp.cpp +++ b/src/core/arm/interpreter/armsupp.cpp @@ -469,6 +469,47 @@ ARMul_SubOverflow (ARMul_State * state, ARMword a, ARMword b, ARMword result) ASSIGNV (SubOverflow (a, b, result)); } +/* 8-bit unsigned saturated addition */ +u8 ARMul_UnsignedSaturatedAdd8(u8 left, u8 right) +{ + u8 result = left + right; + + if (result < left) + result = 0xFF; + + return result; +} + +/* 16-bit unsigned saturated addition */ +u16 ARMul_UnsignedSaturatedAdd16(u16 left, u16 right) +{ + u16 result = left + right; + + if (result < left) + result = 0xFFFF; + + return result; +} + +/* 8-bit unsigned saturated subtraction */ +u8 ARMul_UnsignedSaturatedSub8(u8 left, u8 right) +{ + if (left <= right) + return 0; + + return left - right; +} + +/* 16-bit unsigned saturated subtraction */ +u16 ARMul_UnsignedSaturatedSub16(u16 left, u16 right) +{ + if (left <= right) + return 0; + + return left - right; +} + + /* This function does the work of generating the addresses used in an LDC instruction. The code here is always post-indexed, it's up to the caller to get the input address correct and to handle base register |