Commit c0b24a1dd67495dec07fb4740face382f471f9c4

Authored by bellard
1 parent de758150

div64 fix (aka ssh bug)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1570 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 3 additions and 2 deletions
target-i386/helper.c
... ... @@ -3261,7 +3261,7 @@ static void imul64(uint64_t *plow, uint64_t *phigh, int64_t a, int64_t b)
3261 3261 static int div64(uint64_t *plow, uint64_t *phigh, uint64_t b)
3262 3262 {
3263 3263 uint64_t q, r, a1, a0;
3264   - int i, qb;
  3264 + int i, qb, ab;
3265 3265  
3266 3266 a0 = *plow;
3267 3267 a1 = *phigh;
... ... @@ -3275,8 +3275,9 @@ static int div64(uint64_t *plow, uint64_t *phigh, uint64_t b)
3275 3275 return 1;
3276 3276 /* XXX: use a better algorithm */
3277 3277 for(i = 0; i < 64; i++) {
  3278 + ab = a1 >> 63;
3278 3279 a1 = (a1 << 1) | (a0 >> 63);
3279   - if (a1 >= b) {
  3280 + if (ab || a1 >= b) {
3280 3281 a1 -= b;
3281 3282 qb = 1;
3282 3283 } else {
... ...