Changeset 9003


Ignore:
Timestamp:
Apr 4, 2008, 4:28:14 AM (11 years ago)
Author:
rme
Message:

Checkpoint work in progress.

File:
1 edited

Legend:

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

    r8827 r9003  
    88;;;
    99(defx8632lapfunction %bignum-ref ((bignum arg_y) (i arg_z))
    10   (movl (% esp) (% temp0))              ;.SPvalues wants return addr in temp0
     10  (movl (% esp) (% temp0))              ;ptr to return addr on stack in temp0
    1111  (movzwl (@ (+ 2 x8632::misc-data-offset) (% bignum) (% i)) (% imm0))
    1212  (box-fixnum imm0 temp1)
     
    7878  (vector-length bignum imm0)
    7979  (movl (@ (- x8632::misc-data-offset 4) (% bignum) (% imm0)) (% imm0))
    80   (movl ($ x8632::nil-value) (% temp0))
    81   (lea (@ x8632::t-offset (% temp0)) (% arg_z))
     80  (movl ($ x8632::nil-value) (% arg_z))
     81  (lea (@ x8632::t-offset (% arg_z)) (% temp0))
    8282  (testl (% imm0) (% imm0))
    83   (cmovlel (% temp0) (% arg_z))
     83  (cmovnsl (% temp0) (% arg_z))
    8484  (single-value-return))
    8585
     
    8787  (vector-length bignum imm0)
    8888  (movl (@ (- x8632::misc-data-offset 4) (% bignum) (% imm0)) (% imm0))
    89   (movl ($ x8632::nil-value) (% temp0))
    90   (lea (@ x8632::t-offset (% temp0)) (% arg_z))
     89  (movl ($ x8632::nil-value) (% arg_z))
     90  (lea (@ x8632::t-offset (% arg_z)) (% temp0))
    9191  (testl (% imm0) (% imm0))
    92   (cmovgl (% temp0) (% arg_z))
     92  (cmovsl (% temp0) (% arg_z))
    9393  (single-value-return))
    9494
     
    690690
    691691
    692 ;;; floor: given x and y, producing q and r, q * y + r = x.
    693 
    694692;;; Divide bignum x by single digit y (passed as two halves).
    695693;;; The quotient in stored in q, and the remainder is returned
    696 ;;; in two halves.
    697 (defx8632lapfunction %floor-loop-quo ((x 8) (q 4) #|(ra 0)|# (yhi arg_y) (ylo arg_z))
    698   (int ($ 3)))
    699 
    700 (defx8632lapfunction %floor-loop-no-quo ((q 4) #|(ra 0)|# (yhi arg_y) (ylo arg_z))
    701   (int ($ 3)))
     694;;; in two halves.  (cf. Knuth, 4.3.1, exercise 16)
     695(defx8632lapfunction %floor-loop-quo ((x 8) (res 4) #|(ra 0)|# (yhi arg_y) (ylo arg_z))
     696  (int ($ 3))
     697  (compose-digit yhi ylo imm0)
     698  (movl (% imm0) (@ (% :rcontext) x8632::tcr.unboxed0))
     699  (pop (% temp0))
     700  (pop (% arg_z))                       ;res
     701  (pop (% arg_y))                       ;x
     702  (discard-reserved-frame)
     703  (push (% temp0))
     704  (mark-as-imm edx)                     ;aka temp1
     705  (let ((bignum arg_y)                  ;bignum dividend
     706        (result arg_z))                 ;bignum result (quotient)
     707    (xorl (% edx) (% edx))
     708    (vector-length bignum temp0)
     709    (jmp @next)
     710    @loop
     711    (movl (@ x8632::misc-data-offset (% bignum) (% temp0)) (% eax))
     712    (divl (@ (% :rcontext) x8632::tcr.unboxed0))
     713    (movl (% eax) (@ x8632::misc-data-offset (% result) (% temp0)))
     714    @next
     715    (subl ($ '1) (% temp0))
     716    (jge @loop))
     717  (movl (% esp) (% temp0))
     718  ;; extract and push high half of remainder
     719  (movl ($ (- #x10000)) (% arg_y))
     720  (andl (% edx) (% arg_y))
     721  (shrl ($ (- 16 x8632::fixnumshift)) (% arg_y))
     722  (push (% arg_y))
     723  ;; extract and push low half
     724  (shll ($ 16) (% edx))
     725  (shrl ($ (- 16 x8632::fixnumshift)) (% edx))
     726  (push (% edx))
     727  (mark-as-node edx)
     728  (set-nargs 2)
     729  (jmp-subprim .SPvalues))
     730
     731;;; For TRUNCATE-BY-FIXNUM et al.
     732;;; Doesn't store quotient: just returns rem in 2 halves.
     733;;; Could avoid using tcr.unboxed0 if it matters...
     734(defx8632lapfunction %floor-loop-no-quo ((x 4) #|(ra 0)|# (yhi arg_y) (ylo arg_z))
     735  (int ($ 3))
     736  (compose-digit yhi ylo imm0)
     737  (movl (% imm0) (@ (% :rcontext) x8632::tcr.unboxed0))
     738  (pop (% temp0))
     739  (pop (% arg_y))
     740  (discard-reserved-frame)
     741  (push (% temp0))
     742  (mark-as-imm edx)                     ;aka temp1
     743  (let ((bignum arg_y)                  ;bignum dividend
     744        (result arg_z))                 ;bignum result (quotient)
     745    (xorl (% edx) (% edx))
     746    (vector-length bignum temp0)
     747    (jmp @next)
     748    @loop
     749    (movl (@ x8632::misc-data-offset (% bignum) (% temp0)) (% eax))
     750    (divl (@ (% :rcontext) x8632::tcr.unboxed0))
     751    ;;(movl (% eax) (@ x8632::misc-data-offset (% result) (% temp0)))
     752    @next
     753    (subl ($ '1) (% temp0))
     754    (jge @loop))
     755  (movl (% esp) (% temp0))
     756  ;; extract and push high half of remainder
     757  (movl ($ (- #x10000)) (% arg_y))
     758  (andl (% edx) (% arg_y))
     759  (shrl ($ (- 16 x8632::fixnumshift)) (% arg_y))
     760  (push (% arg_y))
     761  ;; extract and push low half
     762  (shll ($ 16) (% edx))
     763  (shrl ($ (- 16 x8632::fixnumshift)) (% edx))
     764  (push (% edx))
     765  (mark-as-node edx)
     766  (set-nargs 2)
     767  (jmp-subprim .SPvalues))
    702768
    703769(defx8632lapfunction truncate-guess-loop ((guess-h 16) (guess-l 12) (x 8)
     
    823889  (movl (% imm0) (@ x8632::misc-data-offset (% bignum)))
    824890  (single-value-return))
     891
     892(defx8632lapfunction bignum-negate-loop-really ((bignum 4) #|(ra 0)|#
     893                                                (len arg_y) (result arg_z))
     894  (int ($ 3))
     895  (mark-as-imm edx)                     ;aka %temp1
     896  (unbox-fixnum arg_y edx)
     897  (movl (@ bignum (% esp)) (% arg_y))
     898  (xorl (% temp0) (% temp0))
     899  (stc)
     900  @loop
     901  (movl (@ x8632::misc-data-offset (% arg_y) (% temp0)) (% imm0))
     902  (not (% imm0))
     903  (adc ($ 0) (% imm0))
     904  (movl (% imm0) (@ x8632::misc-data-offset (% arg_z) (% temp0)))
     905  (lea (@ x8632::node-size (% temp0)) (% temp0))
     906  (decl (% edx))                        ;preserves carry flag
     907  (jg @loop)
     908  ;; return carry
     909  (setc (% imm0.b))
     910  (movzbl (% imm0.b) (% imm0))
     911  (box-fixnum imm0 arg_z)
     912  (mark-as-node edx)
     913  (single-value-return 3))
     914
     915(defx8632lapfunction %bignum-set ((bignum 8) (i 4) #|(ra 0)|#
     916                                  (high arg_y) (low arg_z))
     917  (compose-digit high low imm0)
     918  (movl (@ bignum (% esp)) (% arg_z))
     919  (movl (@ i (% esp)) (% arg_y))
     920  (movl (% imm0) (@ x8632::misc-data-offset (% arg_z) (% arg_y)))
     921  (single-value-return 4))
     922
Note: See TracChangeset for help on using the changeset viewer.