Ignore:
Timestamp:
Oct 17, 2008, 7:01:21 AM (12 years ago)
Author:
rme
Message:

%MULTIPLY-AND-ADD-LOOP: New function, adapted from x8632 code.

MULTIPLY-BIGNUMS: use said new function for inner loop.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-0/X86/X8664/x8664-bignum.lisp

    r8404 r11111  
    3636  (single-value-return))
    3737 
     38;; multiply x[i] by y and add to result starting at digit idx
     39(defx86lapfunction %multiply-and-add-loop
     40    ((x 16) (y 8) #|(ra 0)|# (r arg_x) (idx arg_y) (ylen arg_z))
     41  (let ((cc mm2)
     42        (xx mm3)
     43        (yy mm4)
     44        (rr mm5)
     45        (i imm0)
     46        (j imm1))
     47    (unbox-fixnum idx i)
     48    (movq (@ x (% rsp)) (% temp0))
     49    (movd (@ x8664::misc-data-offset (% temp0) (% i) 4) (% xx)) ;x[i]
     50    (movq (@ y (% rsp)) (% temp0))
     51    (movq (% r) (% temp1))
     52    (pxor (% cc) (% cc))
     53    (xorq (% j) (% j))
     54    @loop
     55    (movd (@ x8664::misc-data-offset (% temp0) (% j) 4) (% yy)) ;y[j]
     56    (pmuludq (% xx) (% yy))
     57    ;; 64-bit product now in %yy
     58    (movd (@ x8664::misc-data-offset (% temp1) (% i) 4) (% rr))
     59    ;; add in digit from r[i]
     60    (paddq (% yy) (% rr))
     61    ;; add in carry
     62    (paddq (% cc) (% rr))
     63    (movd (% rr) (@ x8664::misc-data-offset (% temp1) (% i) 4)) ;update r[i]
     64    (movq (% rr) (% cc))
     65    (psrlq ($ 32) (% cc))               ;get carry digit into low word
     66    (addq ($ 1) (% i))
     67    (addq ($ 1) (% j))
     68    (subq ($ '1) (% ylen))
     69    (jg @loop)
     70    (movd (% cc) (@ x8664::misc-data-offset (% temp1) (% i) 4))
     71    (single-value-return 4)))
    3872
    3973
Note: See TracChangeset for help on using the changeset viewer.