summaryrefslogtreecommitdiff
path: root/target/ppc/int_helper.c
diff options
context:
space:
mode:
authorYasmin Beatriz <yasmins@linux.ibm.com>2018-07-16 19:03:12 +0000
committerDavid Gibson <david@gibson.dropbear.id.au>2018-08-21 14:28:45 +1000
commit56e0e961ec14f7f89f9d5f20e12b61b9510ed1ad (patch)
tree0e3de82a4e1a87dada31ea99f4b4f6394c6dc912 /target/ppc/int_helper.c
parent86c0cab11aabb0c2a5cc76825bc05dfe2b367412 (diff)
downloadqemu-56e0e961ec14f7f89f9d5f20e12b61b9510ed1ad.zip
target/ppc: bcdsub fix sign when result is zero
When the result of bcdsub is equal to zero, the result sign may be set to negative in some cases, and this does not follow the Power ISA specifications as to decimal integer arithmetic instructions. Signed-off-by: Yasmin Beatriz <yasmins@linux.ibm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'target/ppc/int_helper.c')
-rw-r--r--target/ppc/int_helper.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
index d52338ed71..ac7f92d7ae 100644
--- a/target/ppc/int_helper.c
+++ b/target/ppc/int_helper.c
@@ -2747,6 +2747,9 @@ uint32_t helper_bcdadd(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps)
result.u8[BCD_DIG_BYTE(0)] = bcd_preferred_sgn(sgna, ps);
zero = bcd_sub_mag(&result, a, b, &invalid, &overflow);
cr = (sgna > 0) ? CRF_GT : CRF_LT;
+ } else if (bcd_cmp_mag(a, b) == 0) {
+ result.u8[BCD_DIG_BYTE(0)] = bcd_preferred_sgn(0, ps);
+ zero = bcd_sub_mag(&result, b, a, &invalid, &overflow);
} else {
result.u8[BCD_DIG_BYTE(0)] = bcd_preferred_sgn(sgnb, ps);
zero = bcd_sub_mag(&result, b, a, &invalid, &overflow);