summaryrefslogtreecommitdiff
path: root/src/core/arm/interpreter/armsupp.cpp
diff options
context:
space:
mode:
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