From: Paul Brook <paul@codesourcery.com>
To: qemu-devel@nongnu.org
Cc: TAKAGO Daisuke <takago1129@hotmail.com>
Subject: [Qemu-devel] [patch] Arm saturating arithmetic bugs.
Date: Fri, 13 May 2005 17:04:17 +0100 [thread overview]
Message-ID: <200505131704.17413.paul@codesourcery.com> (raw)
The patch below fixes a couple of bugs in the arm saturating arithmetic
instructions. It uses the correct registers, and makes sure the intermediate
result is saturated properly.
Paul
? target-arm/p
Index: target-arm/op.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-arm/op.c,v
retrieving revision 1.13
diff -u -p -r1.13 op.c
--- target-arm/op.c 27 Apr 2005 20:25:20 -0000 1.13
+++ target-arm/op.c 13 May 2005 15:53:51 -0000
@@ -805,6 +805,23 @@ void OPPROTO op_subl_T0_T1_saturate(void
FORCE_RET();
}
+void OPPROTO op_double_T1_saturate(void)
+{
+ int32_t val;
+
+ val = T1;
+ if (val >= 0x40000000) {
+ T1 = 0x7fffffff;
+ env->QF = 1;
+ } else if (val <= (int32_t)0xc0000000) {
+ T1 = 0x80000000;
+ env->QF = 1;
+ } else {
+ T1 = val << 1;
+ }
+ FORCE_RET();
+}
+
/* thumb shift by immediate */
void OPPROTO op_shll_T0_im_thumb(void)
{
Index: target-arm/translate.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-arm/translate.c,v
retrieving revision 1.24
diff -u -p -r1.24 translate.c
--- target-arm/translate.c 27 Apr 2005 20:25:20 -0000 1.24
+++ target-arm/translate.c 13 May 2005 15:53:51 -0000
@@ -1019,20 +1019,15 @@ static void disas_arm_insn(CPUState * en
case 0x5: /* saturating add/subtract */
rd = (insn >> 12) & 0xf;
rn = (insn >> 16) & 0xf;
- gen_movl_T0_reg(s, rn);
- if (op1 & 2) {
- gen_movl_T1_reg(s, rn);
- if (op1 & 1)
- gen_op_subl_T0_T1_saturate();
- else
- gen_op_addl_T0_T1_saturate();
- }
- gen_movl_T1_reg(s, rm);
+ gen_movl_T0_reg(s, rm);
+ gen_movl_T1_reg(s, rn);
+ if (op1 & 2)
+ gen_op_double_T1_saturate();
if (op1 & 1)
gen_op_subl_T0_T1_saturate();
else
gen_op_addl_T0_T1_saturate();
- gen_movl_reg_T0(s, rn);
+ gen_movl_reg_T0(s, rd);
break;
case 0x8: /* signed multiply */
case 0xa:
reply other threads:[~2005-05-13 16:29 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=200505131704.17413.paul@codesourcery.com \
--to=paul@codesourcery.com \
--cc=qemu-devel@nongnu.org \
--cc=takago1129@hotmail.com \
/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).