Changeset 9624 for branches/ia32/level-0


Ignore:
Timestamp:
May 30, 2008, 4:22:37 AM (11 years ago)
Author:
rme
Message:

%subtract-with-borrow-1: get it working (I think)

truncate-guess-loop: branched to wrong label

Use same method for extracting and pushing halves of result in several places.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ia32/level-0/X86/X8632/x8632-bignum.lisp

    r9623 r9624  
    247247  (unbox-fixnum b-l temp0)
    248248  (movl (@ b-h (% esp)) (% imm0))
    249   (unbox-fixnum imm0 imm0)
     249  (sarl ($ x8632::fixnumshift) (% imm0))
    250250  (shll ($ 16) (% imm0))
    251   (orl (% imm0) (% temp0))
     251  (orl (% imm0) (% temp0))              ;b in temp0
    252252  (movl (@ a-l (% esp)) (% temp1))
    253   (unbox-fixnum temp1 temp1)
     253  (sarl ($ x8632::fixnumshift) (% temp1))
    254254  (movl (@ a-h (% esp)) (% imm0))
    255   (unbox-fixnum imm0 imm0)
     255  (sarl ($ x8632::fixnumshift) (% imm0))
    256256  (shll ($ 16) (% imm0))
    257   (orl (% imm0) (% temp1))
    258   (cmpl ($ '1) (% borrow))          ;CF = 1 if borrow is 0 else CF = 0
     257  (orl (% imm0) (% temp1))          ;a in temp1
     258
     259  (unbox-fixnum borrow imm0)
     260  (subl ($ 1) (% imm0))                 ;sets carry appropriately
    259261  (sbbl (% temp0) (% temp1))
    260   (movl ($ 1) (% imm0))
    261   (subb ($ 0) (% imm0))
     262  (setae (%b imm0))                     ;resulting borrow (1 for no, 0 for yes)
    262263  (box-fixnum imm0 arg_z)
    263   (movzwl (% temp1.w) (% imm0))
    264   (box-fixnum imm0 imm0)
     264  (movl (% temp1) (% imm0))
     265  (andl ($ (- #x10000)) (% imm0))
     266  (shrl ($ (- 16 x8632::fixnumshift)) (% imm0))
    265267  (popl (% arg_y))                      ;return address
    266268  (addl ($ '5) (% esp))                 ;discard reserved frame & stack args
    267269  (pushl (% arg_y))
    268270  (push (% imm0))                       ;high
    269   (sarl ($ 16) (% temp1))
     271  (andl ($ #xffff) (% temp1))
    270272  (box-fixnum temp1 imm0)
    271273  (mark-as-node temp0)
     
    808810  (push (% arg_y))
    809811  ;; extract and push low half
    810   (shll ($ 16) (% edx))
    811   (shrl ($ (- 16 x8632::fixnumshift)) (% edx))
     812  (andl ($ #xffff) (% edx))
     813  (shll ($ x8632::fixnumshift) (% edx))
    812814  (push (% edx))
    813815  (mark-as-node edx)
     
    845847  (push (% arg_y))
    846848  ;; extract and push low half
    847   (shll ($ 16) (% edx))
    848   (shrl ($ (- 16 x8632::fixnumshift)) (% edx))
     849  (andl ($ #xffff) (% edx))
     850  (shll ($ x8632::fixnumshift) (% edx))
    849851  (push (% edx))
    850852  (mark-as-node edx)
     
    904906  (jg @decrement)
    905907  ;;             (and (= middle-digit high-guess*y2)
    906   (jne @decrement)
     908  (jne @return)
    907909  ;;                  (> low-guess*y2 x-i-2)
    908910  (movd (% mm2) (% eax))                ;low part of y2*guess
     
    919921  (push (% imm0))
    920922  (movd (% mm0) (% imm0))
    921   (shll ($ 16) (% imm0))
    922   (shrl ($ (- 16 x8632::fixnumshift)) (% imm0))
     923  (andl ($ #xffff) (% imm0))
     924  (shll ($ x8632::fixnumshift) (% imm0))
    923925  (push (% imm0))                       ;low half
    924926  (set-nargs 2)
     
    926928  @decrement
    927929  (movd (% mm0) (% imm0))               ;guess
    928   (btl ($ 8) (% temp0))                 ;restore state of carry flag
    929   (sbb ($ 1) (% imm0))
     930  (subl ($ 1) (% imm0))
    930931  (movd (% imm0) (% mm0))
    931932  (jmp @return))
Note: See TracChangeset for help on using the changeset viewer.