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


_______________________________________________
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Reply via email to