qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Dirk Behme <dirk.behme@googlemail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add/subtract
Date: Mon, 01 May 2006 18:44:28 +0200	[thread overview]
Message-ID: <44563AEC.8070903@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 165 bytes --]


Fix overflow conditions for MIPS add/subtract as proposed by
Daniel Jacobowitz.

http://lists.gnu.org/archive/html/qemu-devel/2006-04/msg00538.html

Regards

Dirk


[-- Attachment #2: qemu-mips-overflow.txt --]
[-- Type: text/plain, Size: 765 bytes --]

--- target-mips/op.c_orig	2006-04-30 09:40:46.000000000 +0200
+++ target-mips/op.c	2006-04-30 09:41:52.000000000 +0200
@@ -206,7 +206,7 @@ void op_addo (void)
 
     tmp = T0;
     T0 += T1;
-    if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) {
+    if (~(T0 ^ T1) & (T0 ^ tmp) & 0x80000000) {
        /* operands of same sign, result different sign */
         CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW);
     }
@@ -225,7 +225,7 @@ void op_subo (void)
 
     tmp = T0;
     T0 = (int32_t)T0 - (int32_t)T1;
-    if (((tmp ^ T1) & (tmp ^ T0)) >> 31) {
+    if ((T0 ^ T1) & (T0 ^ tmp) & 0x80000000) {
        /* operands of different sign, first operand and result different sign */
         CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW);
     }



             reply	other threads:[~2006-05-01 16:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-01 16:44 Dirk Behme [this message]
2006-05-01 19:01 ` [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add/subtract Fabrice Bellard
  -- strict thread matches above, loose matches on Subject: below --
2006-05-01 18:42 Stefan Weil
2006-05-01 19:18 ` Daniel Jacobowitz
2006-05-01 21:40 ` Fabrice Bellard

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=44563AEC.8070903@gmail.com \
    --to=dirk.behme@googlemail.com \
    --cc=qemu-devel@nongnu.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 NNTP newsgroup(s).