Fix qemu SIGFPE caused by division-by-zero due to underflow.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2673 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index 576787d..14696aa 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -216,6 +216,17 @@
 }
 #endif
 
+#if HOST_LONG_BITS < 64
+void do_div (void)
+{
+    /* 64bit datatypes because we may see overflow/underflow. */
+    if (T1 != 0) {
+        env->LO = (int32_t)((int64_t)(int32_t)T0 / (int32_t)T1);
+        env->HI = (int32_t)((int64_t)(int32_t)T0 % (int32_t)T1);
+    }
+}
+#endif
+
 #ifdef TARGET_MIPS64
 void do_dmult (void)
 {