qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yasmin Beatriz <yasmins@linux.ibm.com>
To: qemu-ppc@nongnu.org
Cc: qemu-devel@nongnu.org, david@gibson.dropbear.id.au, rth@twiddle.net
Subject: [Qemu-devel] [PATCH] target/ppc: bcdsub fix sign when result is zero
Date: Mon, 16 Jul 2018 19:03:12 +0000	[thread overview]
Message-ID: <1531767792-17705-1-git-send-email-yasmins@linux.ibm.com> (raw)

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>
---
 target/ppc/int_helper.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
index 03d37da..fa18e6e 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);
-- 
1.8.3.1

             reply	other threads:[~2018-07-16 19:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16 19:03 Yasmin Beatriz [this message]
2018-07-18  2:22 ` [Qemu-devel] [PATCH] target/ppc: bcdsub fix sign when result is zero David Gibson
2018-07-18 12:48   ` Yasmin Beatriz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1531767792-17705-1-git-send-email-yasmins@linux.ibm.com \
    --to=yasmins@linux.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).