aboutsummaryrefslogtreecommitdiff
path: root/target-i386
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2005-09-08 19:26:14 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2005-09-08 19:26:14 +0000
commitc0b24a1dd67495dec07fb4740face382f471f9c4 (patch)
tree8c6ca512a6ea809623b73423199006a18c5817ff /target-i386
parentde7581500691999629a35a9752c6a830ce520ca6 (diff)
div64 fix (aka ssh bug)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1570 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'target-i386')
-rw-r--r--target-i386/helper.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/target-i386/helper.c b/target-i386/helper.c
index c7fea9553e..e2f6fba2ef 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -3261,7 +3261,7 @@ static void imul64(uint64_t *plow, uint64_t *phigh, int64_t a, int64_t b)
static int div64(uint64_t *plow, uint64_t *phigh, uint64_t b)
{
uint64_t q, r, a1, a0;
- int i, qb;
+ int i, qb, ab;
a0 = *plow;
a1 = *phigh;
@@ -3275,8 +3275,9 @@ static int div64(uint64_t *plow, uint64_t *phigh, uint64_t b)
return 1;
/* XXX: use a better algorithm */
for(i = 0; i < 64; i++) {
+ ab = a1 >> 63;
a1 = (a1 << 1) | (a0 >> 63);
- if (a1 >= b) {
+ if (ab || a1 >= b) {
a1 -= b;
qb = 1;
} else {