public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH/committed] sim: mn10300: fix incorrect implementation of a few insns
Date: Fri, 15 Dec 2023 21:13:51 -0500	[thread overview]
Message-ID: <20231216021351.22709-1-vapier@gentoo.org> (raw)

Fix a few problems caught by compiler warnings:
* Some of the asr & lsr insns were setting up the c state flag,
  but then forgetting to set it in the PSW.  Add it like the other
  asr & lsr variants.
* Some of the dmulh insns were multiplying one of the source regs
  against itself instead of against the other source reg.
* The sat16_cmp parallel insn was using the wrong register in the
  compare -- the reg1 src/dst pair are used in the sat16 op, and
  the reg2 src/dst pair are used in the add op.
---
 sim/mn10300/am33.igen | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sim/mn10300/am33.igen b/sim/mn10300/am33.igen
index da8f88fa599f..a3a40b78ca6c 100644
--- a/sim/mn10300/am33.igen
+++ b/sim/mn10300/am33.igen
@@ -2706,7 +2706,7 @@
   n = (State.regs[dstreg] & 0x80000000);
 
   PSW &= ~(PSW_Z | PSW_N | PSW_C);
-  PSW |= ((z ? PSW_Z : 0) | ( n ? PSW_N : 0));
+  PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0) | (c ? PSW_C : 0));
 }
 
 // 1111 1011 0101 1101 Rm Rn Rd; lsr Rm,Rn,Rd
@@ -2730,7 +2730,7 @@
   n = (State.regs[dstreg] & 0x80000000);
 
   PSW &= ~(PSW_Z | PSW_N | PSW_C);
-  PSW |= ((z ? PSW_Z : 0) | ( n ? PSW_N : 0));
+  PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0) | (c ? PSW_C : 0));
 }
 
 // 1111 1011 0110 1101 Rm Rn Rd; asl Rm,Rn,Rd
@@ -3252,10 +3252,10 @@
   dstreg2 = translate_rreg (SD_, RD2);
 
   temp = ((int32_t)(State.regs[srcreg1] & 0xffff)
-          * (int32_t)(State.regs[srcreg1] & 0xffff));
+          * (int32_t)(State.regs[srcreg2] & 0xffff));
   State.regs[dstreg2] = temp;
   temp = ((int32_t)((State.regs[srcreg1] >> 16) & 0xffff)
-          * (int32_t)((State.regs[srcreg1] >>16) & 0xffff));
+          * (int32_t)((State.regs[srcreg2] >> 16) & 0xffff));
   State.regs[dstreg1] = temp;
 }
 
@@ -3275,10 +3275,10 @@
   dstreg2 = translate_rreg (SD_, RD2);
 
   temp = ((uint32_t)(State.regs[srcreg1] & 0xffff)
-          * (uint32_t)(State.regs[srcreg1] & 0xffff));
+          * (uint32_t)(State.regs[srcreg2] & 0xffff));
   State.regs[dstreg2] = temp;
   temp = ((uint32_t)((State.regs[srcreg1] >> 16) & 0xffff)
-          * (uint32_t)((State.regs[srcreg1] >>16) & 0xffff));
+          * (uint32_t)((State.regs[srcreg2] >> 16) & 0xffff));
   State.regs[dstreg1] = temp;
 }
 
@@ -8646,7 +8646,7 @@
   dstreg1 = translate_rreg (SD_, RN1);
   dstreg2 = translate_rreg (SD_, RN2);
 
-  genericCmp (State.regs[dstreg2], State.regs[dstreg1]);
+  genericCmp (State.regs[srcreg2], State.regs[dstreg2]);
   if (State.regs[srcreg1] >= 0x7fff)
     State.regs[dstreg1] = 0x7fff;
   else if (State.regs[srcreg1] <= 0xffff8000)
-- 
2.43.0


                 reply	other threads:[~2023-12-16  2:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20231216021351.22709-1-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@sourceware.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).