summaryrefslogtreecommitdiff
path: root/src/core/arm/interpreter/armsupp.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2014-12-27 21:15:13 -0500
committerGravatar bunnei2014-12-27 21:15:13 -0500
commit3422d81f053578e2a6806dc9ffa33c50f2c0b66d (patch)
tree16621bd2dabe32e4a17f0014392c6c8f597e9a56 /src/core/arm/interpreter/armsupp.cpp
parentMerge pull request #349 from lioncash/uhdync (diff)
parentdyncom: Implement UQADD8, UQADD16, UQSUB8, UQSUB16, UQASX, and UQSAX. (diff)
downloadyuzu-3422d81f053578e2a6806dc9ffa33c50f2c0b66d.tar.gz
yuzu-3422d81f053578e2a6806dc9ffa33c50f2c0b66d.tar.xz
yuzu-3422d81f053578e2a6806dc9ffa33c50f2c0b66d.zip
Merge pull request #350 from lioncash/qops
Implement the rest of the UQ* ops.
Diffstat (limited to 'src/core/arm/interpreter/armsupp.cpp')
-rw-r--r--src/core/arm/interpreter/armsupp.cpp41
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)
469 ASSIGNV (SubOverflow (a, b, result)); 469 ASSIGNV (SubOverflow (a, b, result));
470} 470}
471 471
472/* 8-bit unsigned saturated addition */
473u8 ARMul_UnsignedSaturatedAdd8(u8 left, u8 right)
474{
475 u8 result = left + right;
476
477 if (result < left)
478 result = 0xFF;
479
480 return result;
481}
482
483/* 16-bit unsigned saturated addition */
484u16 ARMul_UnsignedSaturatedAdd16(u16 left, u16 right)
485{
486 u16 result = left + right;
487
488 if (result < left)
489 result = 0xFFFF;
490
491 return result;
492}
493
494/* 8-bit unsigned saturated subtraction */
495u8 ARMul_UnsignedSaturatedSub8(u8 left, u8 right)
496{
497 if (left <= right)
498 return 0;
499
500 return left - right;
501}
502
503/* 16-bit unsigned saturated subtraction */
504u16 ARMul_UnsignedSaturatedSub16(u16 left, u16 right)
505{
506 if (left <= right)
507 return 0;
508
509 return left - right;
510}
511
512
472/* This function does the work of generating the addresses used in an 513/* This function does the work of generating the addresses used in an
473 LDC instruction. The code here is always post-indexed, it's up to the 514 LDC instruction. The code here is always post-indexed, it's up to the
474 caller to get the input address correct and to handle base register 515 caller to get the input address correct and to handle base register