qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add/subtract


From: Daniel Jacobowitz
Subject: Re: [Qemu-devel] [PATCH] Fix overflow conditions for MIPS add/subtract
Date: Mon, 1 May 2006 15:18:11 -0400
User-agent: Mutt/1.5.8i

On Mon, May 01, 2006 at 08:42:08PM +0200, Stefan Weil wrote:
> >- if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) {
> >+ if (~(T0 ^ T1) & (T0 ^ tmp) & 0x80000000) {

> Hello Dirk,
> 
> which additions / subtractions are handled incorrectly by the current code?
> Here is the result of a test which shows that the current code (which is
> based on my patch)
> raises an exception for 0x80000000 + 0x80000000.
> 
> Daniel, perhaps you could sent the code you used to check overflow
> conditions?

I used GDB.

(gdb) set $T0 = 0x80000000
(gdb) set $T1 = 0x80000000
(gdb) set $tmp = $T0 + $T1
(gdb) p (($tmp ^ $T1 ^ (-1)) & ($T0 ^ $T1)) >> 31
$1 = 0

I see no reason why it should be wrong.  $tmp is of course zero.
The high bit of tmp is not the same as the high bit of T1, therefore
$tmp ^ $T1 ^ (-1) == 0.  Therefore the if is false.  I even compiled
and ran the sample -> no exception.

Oh, damn!  tmp is not the result, T0 is the result.  No wonder this
didn't make any sense.  I apologize, I'm really batting zero today.


-- 
Daniel Jacobowitz
CodeSourcery




reply via email to

[Prev in Thread] Current Thread [Next in Thread]