diff options
author | bunnei <bunneidev@gmail.com> | 2014-12-30 04:15:15 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2014-12-30 04:15:15 +0100 |
commit | 021fb420752aa34dc3bee70fb2f3fe673176594f (patch) | |
tree | c5b620ccf025845e87e81f8079dc9438f052dae7 /src/core/arm/interpreter/armsupp.cpp | |
parent | Merge pull request #253 from purpasmart96/mem_map (diff) | |
download | yuzu-021fb420752aa34dc3bee70fb2f3fe673176594f.tar yuzu-021fb420752aa34dc3bee70fb2f3fe673176594f.tar.gz yuzu-021fb420752aa34dc3bee70fb2f3fe673176594f.tar.bz2 yuzu-021fb420752aa34dc3bee70fb2f3fe673176594f.tar.lz yuzu-021fb420752aa34dc3bee70fb2f3fe673176594f.tar.xz yuzu-021fb420752aa34dc3bee70fb2f3fe673176594f.tar.zst yuzu-021fb420752aa34dc3bee70fb2f3fe673176594f.zip |
Diffstat (limited to 'src/core/arm/interpreter/armsupp.cpp')
-rw-r--r-- | src/core/arm/interpreter/armsupp.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/core/arm/interpreter/armsupp.cpp b/src/core/arm/interpreter/armsupp.cpp index 8b3661c8f..426b67831 100644 --- a/src/core/arm/interpreter/armsupp.cpp +++ b/src/core/arm/interpreter/armsupp.cpp @@ -578,6 +578,41 @@ u16 ARMul_UnsignedSaturatedSub16(u16 left, u16 right) return left - right; } +// Signed saturation. +u32 ARMul_SignedSatQ(s32 value, u8 shift, bool* saturation_occurred) +{ + const u32 max = (1 << shift) - 1; + const s32 top = (value >> shift); + + if (top > 0) { + *saturation_occurred = true; + return max; + } + else if (top < -1) { + *saturation_occurred = true; + return ~max; + } + + *saturation_occurred = false; + return (u32)value; +} + +// Unsigned saturation +u32 ARMul_UnsignedSatQ(s32 value, u8 shift, bool* saturation_occurred) +{ + const u32 max = (1 << shift) - 1; + + if (value < 0) { + *saturation_occurred = true; + return 0; + } else if ((u32)value > max) { + *saturation_occurred = true; + return max; + } + + *saturation_occurred = false; + return (u32)value; +} /* 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 |