From c0b24a1dd67495dec07fb4740face382f471f9c4 Mon Sep 17 00:00:00 2001 From: bellard Date: Thu, 8 Sep 2005 19:26:14 +0000 Subject: [PATCH] div64 fix (aka ssh bug) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1570 c046a42c-6fe2-441c-8c8c-71466251a162 --- target-i386/helper.c | 5 +++-- 1 file 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 {