From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FadfH-0006Uo-Lo for qemu-devel@nongnu.org; Mon, 01 May 2006 15:02:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FadfH-0006US-0K for qemu-devel@nongnu.org; Mon, 01 May 2006 15:02:35 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FadfG-0006UJ-Lm for qemu-devel@nongnu.org; Mon, 01 May 2006 15:02:34 -0400 Received: from [84.96.92.60] (helo=Smtp.neuf.fr) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fadj8-0001gh-Hx for qemu-devel@nongnu.org; Mon, 01 May 2006 15:06:34 -0400 Received: from [84.102.211.147] by sp604001mt.gpm.neuf.ld (Sun Java System Messaging Server 6.2-5.05 (built Feb 16 2006)) with ESMTP id <0IYL008O7OVKFDF0@sp604001mt.gpm.neuf.ld> for qemu-devel@nongnu.org; Mon, 01 May 2006 21:02:08 +0200 (CEST) Date: Mon, 01 May 2006 21:01:24 +0200 From: Fabrice Bellard Subject: Re: [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add/subtract In-reply-to: <44563AEC.8070903@gmail.com> Message-id: <44565B04.9070601@bellard.org> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: <44563AEC.8070903@gmail.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org OK. I hope this is correct now :-) Just a note : there is already a lot of code in QEMU to compute correctly the overflow and carry flags (for example in the i386 target)... don't spend your time on reinventing them ! Fabrice. Dirk Behme wrote: > > 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 > > > ------------------------------------------------------------------------ > > --- 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); > } > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Qemu-devel mailing list > Qemu-devel@nongnu.org > http://lists.nongnu.org/mailman/listinfo/qemu-devel