aboutsummaryrefslogtreecommitdiff
path: root/target-mips
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-04-23 15:18:58 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-04-23 15:18:58 +0000
commit76e050c2e62995f1d6905e28674dea3a7fcff1a5 (patch)
tree8f6cfef72ba11a7506b7a00b997a10d5e51a88b0 /target-mips
parentda2414e9335d2116687fdc914daf12f443d9b87c (diff)
Fix overflow conditions for MIPS add / subtract (Stefan Weil)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1828 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'target-mips')
-rw-r--r--target-mips/op.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/target-mips/op.c b/target-mips/op.c
index 71abd95bea..e0d3463be1 100644
--- a/target-mips/op.c
+++ b/target-mips/op.c
@@ -206,7 +206,8 @@ void op_addo (void)
tmp = T0;
T0 += T1;
- if ((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31)) {
+ if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) {
+ /* operands of same sign, result different sign */
CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW);
}
RETURN();
@@ -224,7 +225,8 @@ void op_subo (void)
tmp = T0;
T0 = (int32_t)T0 - (int32_t)T1;
- if (!((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31))) {
+ if (((tmp ^ T1) & (tmp ^ T0)) >> 31) {
+ /* operands of different sign, first operand and result different sign */
CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW);
}
RETURN();