Index: /branches/ia32/level-0/X86/X8632/x8632-bignum.lisp
===================================================================
--- /branches/ia32/level-0/X86/X8632/x8632-bignum.lisp	(revision 9623)
+++ /branches/ia32/level-0/X86/X8632/x8632-bignum.lisp	(revision 9624)
@@ -247,25 +247,27 @@
   (unbox-fixnum b-l temp0)
   (movl (@ b-h (% esp)) (% imm0))
-  (unbox-fixnum imm0 imm0)
+  (sarl ($ x8632::fixnumshift) (% imm0))
   (shll ($ 16) (% imm0))
-  (orl (% imm0) (% temp0))
+  (orl (% imm0) (% temp0))		;b in temp0
   (movl (@ a-l (% esp)) (% temp1))
-  (unbox-fixnum temp1 temp1)
+  (sarl ($ x8632::fixnumshift) (% temp1))
   (movl (@ a-h (% esp)) (% imm0))
-  (unbox-fixnum imm0 imm0)
+  (sarl ($ x8632::fixnumshift) (% imm0))
   (shll ($ 16) (% imm0))
-  (orl (% imm0) (% temp1))
-  (cmpl ($ '1) (% borrow))	    ;CF = 1 if borrow is 0 else CF = 0
+  (orl (% imm0) (% temp1))	    ;a in temp1
+
+  (unbox-fixnum borrow imm0)
+  (subl ($ 1) (% imm0))			;sets carry appropriately
   (sbbl (% temp0) (% temp1))
-  (movl ($ 1) (% imm0))
-  (subb ($ 0) (% imm0))
+  (setae (%b imm0))			;resulting borrow (1 for no, 0 for yes)
   (box-fixnum imm0 arg_z)
-  (movzwl (% temp1.w) (% imm0))
-  (box-fixnum imm0 imm0)
+  (movl (% temp1) (% imm0))
+  (andl ($ (- #x10000)) (% imm0))
+  (shrl ($ (- 16 x8632::fixnumshift)) (% imm0))
   (popl (% arg_y))			;return address
   (addl ($ '5) (% esp))			;discard reserved frame & stack args
   (pushl (% arg_y))
   (push (% imm0))			;high
-  (sarl ($ 16) (% temp1))
+  (andl ($ #xffff) (% temp1))
   (box-fixnum temp1 imm0)
   (mark-as-node temp0)
@@ -808,6 +810,6 @@
   (push (% arg_y))
   ;; extract and push low half
-  (shll ($ 16) (% edx))
-  (shrl ($ (- 16 x8632::fixnumshift)) (% edx))
+  (andl ($ #xffff) (% edx))
+  (shll ($ x8632::fixnumshift) (% edx))
   (push (% edx))
   (mark-as-node edx)
@@ -845,6 +847,6 @@
   (push (% arg_y))
   ;; extract and push low half
-  (shll ($ 16) (% edx))
-  (shrl ($ (- 16 x8632::fixnumshift)) (% edx))
+  (andl ($ #xffff) (% edx))
+  (shll ($ x8632::fixnumshift) (% edx))
   (push (% edx))
   (mark-as-node edx)
@@ -904,5 +906,5 @@
   (jg @decrement)
   ;;             (and (= middle-digit high-guess*y2)
-  (jne @decrement)
+  (jne @return)
   ;;                  (> low-guess*y2 x-i-2)
   (movd (% mm2) (% eax))		;low part of y2*guess
@@ -919,6 +921,6 @@
   (push (% imm0))
   (movd (% mm0) (% imm0))
-  (shll ($ 16) (% imm0))
-  (shrl ($ (- 16 x8632::fixnumshift)) (% imm0))
+  (andl ($ #xffff) (% imm0))
+  (shll ($ x8632::fixnumshift) (% imm0))
   (push (% imm0))			;low half
   (set-nargs 2)
@@ -926,6 +928,5 @@
   @decrement
   (movd (% mm0) (% imm0))		;guess
-  (btl ($ 8) (% temp0))			;restore state of carry flag
-  (sbb ($ 1) (% imm0))
+  (subl ($ 1) (% imm0))
   (movd (% imm0) (% mm0))
   (jmp @return))
