diff options
| author | 2014-12-29 22:15:15 -0500 | |
|---|---|---|
| committer | 2014-12-29 22:15:15 -0500 | |
| 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.gz yuzu-021fb420752aa34dc3bee70fb2f3fe673176594f.tar.xz yuzu-021fb420752aa34dc3bee70fb2f3fe673176594f.zip | |
dyncom: Implement USAT/SSAT
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) | |||
| 578 | return left - right; | 578 | return left - right; |
| 579 | } | 579 | } |
| 580 | 580 | ||
| 581 | // Signed saturation. | ||
| 582 | u32 ARMul_SignedSatQ(s32 value, u8 shift, bool* saturation_occurred) | ||
| 583 | { | ||
| 584 | const u32 max = (1 << shift) - 1; | ||
| 585 | const s32 top = (value >> shift); | ||
| 586 | |||
| 587 | if (top > 0) { | ||
| 588 | *saturation_occurred = true; | ||
| 589 | return max; | ||
| 590 | } | ||
| 591 | else if (top < -1) { | ||
| 592 | *saturation_occurred = true; | ||
| 593 | return ~max; | ||
| 594 | } | ||
| 595 | |||
| 596 | *saturation_occurred = false; | ||
| 597 | return (u32)value; | ||
| 598 | } | ||
| 599 | |||
| 600 | // Unsigned saturation | ||
| 601 | u32 ARMul_UnsignedSatQ(s32 value, u8 shift, bool* saturation_occurred) | ||
| 602 | { | ||
| 603 | const u32 max = (1 << shift) - 1; | ||
| 604 | |||
| 605 | if (value < 0) { | ||
| 606 | *saturation_occurred = true; | ||
| 607 | return 0; | ||
| 608 | } else if ((u32)value > max) { | ||
| 609 | *saturation_occurred = true; | ||
| 610 | return max; | ||
| 611 | } | ||
| 612 | |||
| 613 | *saturation_occurred = false; | ||
| 614 | return (u32)value; | ||
| 615 | } | ||
| 581 | 616 | ||
| 582 | /* This function does the work of generating the addresses used in an | 617 | /* This function does the work of generating the addresses used in an |
| 583 | LDC instruction. The code here is always post-indexed, it's up to the | 618 | LDC instruction. The code here is always post-indexed, it's up to the |