Skip to content

Commit

Permalink
target/ppc: bcdsub fix sign when result is zero
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Yasmin Beatriz authored and dgibson committed Aug 21, 2018
1 parent 86c0cab commit 56e0e96
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions target/ppc/int_helper.c
Expand Up @@ -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);
Expand Down

0 comments on commit 56e0e96

Please sign in to comment.