Changeset 9003 for branches/ia32/level0
 Timestamp:
 Apr 4, 2008, 4:28:14 AM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/ia32/level0/X86/X8632/x8632bignum.lisp
r8827 r9003 8 8 ;;; 9 9 (defx8632lapfunction %bignumref ((bignum arg_y) (i arg_z)) 10 (movl (% esp) (% temp0)) ; .SPvalues wants return addrin temp010 (movl (% esp) (% temp0)) ;ptr to return addr on stack in temp0 11 11 (movzwl (@ (+ 2 x8632::miscdataoffset) (% bignum) (% i)) (% imm0)) 12 12 (boxfixnum imm0 temp1) … … 78 78 (vectorlength bignum imm0) 79 79 (movl (@ ( x8632::miscdataoffset 4) (% bignum) (% imm0)) (% imm0)) 80 (movl ($ x8632::nilvalue) (% temp0))81 (lea (@ x8632::toffset (% temp0)) (% arg_z))80 (movl ($ x8632::nilvalue) (% arg_z)) 81 (lea (@ x8632::toffset (% arg_z)) (% temp0)) 82 82 (testl (% imm0) (% imm0)) 83 (cmov lel (% temp0) (% arg_z))83 (cmovnsl (% temp0) (% arg_z)) 84 84 (singlevaluereturn)) 85 85 … … 87 87 (vectorlength bignum imm0) 88 88 (movl (@ ( x8632::miscdataoffset 4) (% bignum) (% imm0)) (% imm0)) 89 (movl ($ x8632::nilvalue) (% temp0))90 (lea (@ x8632::toffset (% temp0)) (% arg_z))89 (movl ($ x8632::nilvalue) (% arg_z)) 90 (lea (@ x8632::toffset (% arg_z)) (% temp0)) 91 91 (testl (% imm0) (% imm0)) 92 (cmov gl (% temp0) (% arg_z))92 (cmovsl (% temp0) (% arg_z)) 93 93 (singlevaluereturn)) 94 94 … … 690 690 691 691 692 ;;; floor: given x and y, producing q and r, q * y + r = x.693 694 692 ;;; Divide bignum x by single digit y (passed as two halves). 695 693 ;;; The quotient in stored in q, and the remainder is returned 696 ;;; in two halves. 697 (defx8632lapfunction %floorloopquo ((x 8) (q 4) #(ra 0)# (yhi arg_y) (ylo arg_z)) 698 (int ($ 3))) 699 700 (defx8632lapfunction %floorloopnoquo ((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 %floorloopquo ((x 8) (res 4) #(ra 0)# (yhi arg_y) (ylo arg_z)) 696 (int ($ 3)) 697 (composedigit yhi ylo imm0) 698 (movl (% imm0) (@ (% :rcontext) x8632::tcr.unboxed0)) 699 (pop (% temp0)) 700 (pop (% arg_z)) ;res 701 (pop (% arg_y)) ;x 702 (discardreservedframe) 703 (push (% temp0)) 704 (markasimm edx) ;aka temp1 705 (let ((bignum arg_y) ;bignum dividend 706 (result arg_z)) ;bignum result (quotient) 707 (xorl (% edx) (% edx)) 708 (vectorlength bignum temp0) 709 (jmp @next) 710 @loop 711 (movl (@ x8632::miscdataoffset (% bignum) (% temp0)) (% eax)) 712 (divl (@ (% :rcontext) x8632::tcr.unboxed0)) 713 (movl (% eax) (@ x8632::miscdataoffset (% 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 (markasnode edx) 728 (setnargs 2) 729 (jmpsubprim .SPvalues)) 730 731 ;;; For TRUNCATEBYFIXNUM et al. 732 ;;; Doesn't store quotient: just returns rem in 2 halves. 733 ;;; Could avoid using tcr.unboxed0 if it matters... 734 (defx8632lapfunction %floorloopnoquo ((x 4) #(ra 0)# (yhi arg_y) (ylo arg_z)) 735 (int ($ 3)) 736 (composedigit yhi ylo imm0) 737 (movl (% imm0) (@ (% :rcontext) x8632::tcr.unboxed0)) 738 (pop (% temp0)) 739 (pop (% arg_y)) 740 (discardreservedframe) 741 (push (% temp0)) 742 (markasimm edx) ;aka temp1 743 (let ((bignum arg_y) ;bignum dividend 744 (result arg_z)) ;bignum result (quotient) 745 (xorl (% edx) (% edx)) 746 (vectorlength bignum temp0) 747 (jmp @next) 748 @loop 749 (movl (@ x8632::miscdataoffset (% bignum) (% temp0)) (% eax)) 750 (divl (@ (% :rcontext) x8632::tcr.unboxed0)) 751 ;;(movl (% eax) (@ x8632::miscdataoffset (% 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 (markasnode edx) 766 (setnargs 2) 767 (jmpsubprim .SPvalues)) 702 768 703 769 (defx8632lapfunction truncateguessloop ((guessh 16) (guessl 12) (x 8) … … 823 889 (movl (% imm0) (@ x8632::miscdataoffset (% bignum))) 824 890 (singlevaluereturn)) 891 892 (defx8632lapfunction bignumnegateloopreally ((bignum 4) #(ra 0)# 893 (len arg_y) (result arg_z)) 894 (int ($ 3)) 895 (markasimm edx) ;aka %temp1 896 (unboxfixnum arg_y edx) 897 (movl (@ bignum (% esp)) (% arg_y)) 898 (xorl (% temp0) (% temp0)) 899 (stc) 900 @loop 901 (movl (@ x8632::miscdataoffset (% arg_y) (% temp0)) (% imm0)) 902 (not (% imm0)) 903 (adc ($ 0) (% imm0)) 904 (movl (% imm0) (@ x8632::miscdataoffset (% arg_z) (% temp0))) 905 (lea (@ x8632::nodesize (% temp0)) (% temp0)) 906 (decl (% edx)) ;preserves carry flag 907 (jg @loop) 908 ;; return carry 909 (setc (% imm0.b)) 910 (movzbl (% imm0.b) (% imm0)) 911 (boxfixnum imm0 arg_z) 912 (markasnode edx) 913 (singlevaluereturn 3)) 914 915 (defx8632lapfunction %bignumset ((bignum 8) (i 4) #(ra 0)# 916 (high arg_y) (low arg_z)) 917 (composedigit high low imm0) 918 (movl (@ bignum (% esp)) (% arg_z)) 919 (movl (@ i (% esp)) (% arg_y)) 920 (movl (% imm0) (@ x8632::miscdataoffset (% arg_z) (% arg_y))) 921 (singlevaluereturn 4)) 922
Note: See TracChangeset
for help on using the changeset viewer.