Home | History | Annotate | Line # | Download | only in sparc32
udiv_nfp.asm revision 1.1
      1 dnl  SPARC v7 __udiv_qrnnd division support, used from longlong.h.
      2 dnl  This is for v7 CPUs without a floating-point unit.
      3 
      4 dnl  Copyright 1993, 1994, 1996, 2000 Free Software Foundation, Inc.
      5 
      6 dnl  This file is part of the GNU MP Library.
      7 
      8 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
      9 dnl  it under the terms of the GNU Lesser General Public License as published
     10 dnl  by the Free Software Foundation; either version 3 of the License, or (at
     11 dnl  your option) any later version.
     12 
     13 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
     14 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     15 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
     16 dnl  License for more details.
     17 
     18 dnl  You should have received a copy of the GNU Lesser General Public License
     19 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
     20 
     21 
     22 include(`../config.m4')
     23 
     24 C INPUT PARAMETERS
     25 C rem_ptr	o0
     26 C n1		o1
     27 C n0		o2
     28 C d		o3
     29 
     30 ASM_START()
     31 PROLOGUE(mpn_udiv_qrnnd)
     32 	tst	%o3
     33 	bneg	L(largedivisor)
     34 	mov	8,%g1
     35 
     36 	b	L(p1)
     37 	addxcc	%o2,%o2,%o2
     38 
     39 L(plop):
     40 	bcc	L(n1)
     41 	addxcc	%o2,%o2,%o2
     42 L(p1):	addx	%o1,%o1,%o1
     43 	subcc	%o1,%o3,%o4
     44 	bcc	L(n2)
     45 	addxcc	%o2,%o2,%o2
     46 L(p2):	addx	%o1,%o1,%o1
     47 	subcc	%o1,%o3,%o4
     48 	bcc	L(n3)
     49 	addxcc	%o2,%o2,%o2
     50 L(p3):	addx	%o1,%o1,%o1
     51 	subcc	%o1,%o3,%o4
     52 	bcc	L(n4)
     53 	addxcc	%o2,%o2,%o2
     54 L(p4):	addx	%o1,%o1,%o1
     55 	addcc	%g1,-1,%g1
     56 	bne	L(plop)
     57 	subcc	%o1,%o3,%o4
     58 	bcc	L(n5)
     59 	addxcc	%o2,%o2,%o2
     60 L(p5):	st	%o1,[%o0]
     61 	retl
     62 	xnor	%g0,%o2,%o0
     63 
     64 L(nlop):
     65 	bcc	L(p1)
     66 	addxcc	%o2,%o2,%o2
     67 L(n1):	addx	%o4,%o4,%o4
     68 	subcc	%o4,%o3,%o1
     69 	bcc	L(p2)
     70 	addxcc	%o2,%o2,%o2
     71 L(n2):	addx	%o4,%o4,%o4
     72 	subcc	%o4,%o3,%o1
     73 	bcc	L(p3)
     74 	addxcc	%o2,%o2,%o2
     75 L(n3):	addx	%o4,%o4,%o4
     76 	subcc	%o4,%o3,%o1
     77 	bcc	L(p4)
     78 	addxcc	%o2,%o2,%o2
     79 L(n4):	addx	%o4,%o4,%o4
     80 	addcc	%g1,-1,%g1
     81 	bne	L(nlop)
     82 	subcc	%o4,%o3,%o1
     83 	bcc	L(p5)
     84 	addxcc	%o2,%o2,%o2
     85 L(n5):	st	%o4,[%o0]
     86 	retl
     87 	xnor	%g0,%o2,%o0
     88 
     89 L(largedivisor):
     90 	and	%o2,1,%o5	C %o5 = n0 & 1
     91 
     92 	srl	%o2,1,%o2
     93 	sll	%o1,31,%g2
     94 	or	%g2,%o2,%o2	C %o2 = lo(n1n0 >> 1)
     95 	srl	%o1,1,%o1	C %o1 = hi(n1n0 >> 1)
     96 
     97 	and	%o3,1,%g2
     98 	srl	%o3,1,%g3	C %g3 = floor(d / 2)
     99 	add	%g3,%g2,%g3	C %g3 = ceil(d / 2)
    100 
    101 	b	L(Lp1)
    102 	addxcc	%o2,%o2,%o2
    103 
    104 L(Lplop):
    105 	bcc	L(Ln1)
    106 	addxcc	%o2,%o2,%o2
    107 L(Lp1):	addx	%o1,%o1,%o1
    108 	subcc	%o1,%g3,%o4
    109 	bcc	L(Ln2)
    110 	addxcc	%o2,%o2,%o2
    111 L(Lp2):	addx	%o1,%o1,%o1
    112 	subcc	%o1,%g3,%o4
    113 	bcc	L(Ln3)
    114 	addxcc	%o2,%o2,%o2
    115 L(Lp3):	addx	%o1,%o1,%o1
    116 	subcc	%o1,%g3,%o4
    117 	bcc	L(Ln4)
    118 	addxcc	%o2,%o2,%o2
    119 L(Lp4):	addx	%o1,%o1,%o1
    120 	addcc	%g1,-1,%g1
    121 	bne	L(Lplop)
    122 	subcc	%o1,%g3,%o4
    123 	bcc	L(Ln5)
    124 	addxcc	%o2,%o2,%o2
    125 L(Lp5):	add	%o1,%o1,%o1	C << 1
    126 	tst	%g2
    127 	bne	L(oddp)
    128 	add	%o5,%o1,%o1
    129 	st	%o1,[%o0]
    130 	retl
    131 	xnor	%g0,%o2,%o0
    132 
    133 L(Lnlop):
    134 	bcc	L(Lp1)
    135 	addxcc	%o2,%o2,%o2
    136 L(Ln1):	addx	%o4,%o4,%o4
    137 	subcc	%o4,%g3,%o1
    138 	bcc	L(Lp2)
    139 	addxcc	%o2,%o2,%o2
    140 L(Ln2):	addx	%o4,%o4,%o4
    141 	subcc	%o4,%g3,%o1
    142 	bcc	L(Lp3)
    143 	addxcc	%o2,%o2,%o2
    144 L(Ln3):	addx	%o4,%o4,%o4
    145 	subcc	%o4,%g3,%o1
    146 	bcc	L(Lp4)
    147 	addxcc	%o2,%o2,%o2
    148 L(Ln4):	addx	%o4,%o4,%o4
    149 	addcc	%g1,-1,%g1
    150 	bne	L(Lnlop)
    151 	subcc	%o4,%g3,%o1
    152 	bcc	L(Lp5)
    153 	addxcc	%o2,%o2,%o2
    154 L(Ln5):	add	%o4,%o4,%o4	C << 1
    155 	tst	%g2
    156 	bne	L(oddn)
    157 	add	%o5,%o4,%o4
    158 	st	%o4,[%o0]
    159 	retl
    160 	xnor	%g0,%o2,%o0
    161 
    162 L(oddp):
    163 	xnor	%g0,%o2,%o2
    164 	C q' in %o2. r' in %o1
    165 	addcc	%o1,%o2,%o1
    166 	bcc	L(Lp6)
    167 	addx	%o2,0,%o2
    168 	sub	%o1,%o3,%o1
    169 L(Lp6):	subcc	%o1,%o3,%g0
    170 	bcs	L(Lp7)
    171 	subx	%o2,-1,%o2
    172 	sub	%o1,%o3,%o1
    173 L(Lp7):	st	%o1,[%o0]
    174 	retl
    175 	mov	%o2,%o0
    176 
    177 L(oddn):
    178 	xnor	%g0,%o2,%o2
    179 	C q' in %o2. r' in %o4
    180 	addcc	%o4,%o2,%o4
    181 	bcc	L(Ln6)
    182 	addx	%o2,0,%o2
    183 	sub	%o4,%o3,%o4
    184 L(Ln6):	subcc	%o4,%o3,%g0
    185 	bcs	L(Ln7)
    186 	subx	%o2,-1,%o2
    187 	sub	%o4,%o3,%o4
    188 L(Ln7):	st	%o4,[%o0]
    189 	retl
    190 	mov	%o2,%o0
    191 EPILOGUE(mpn_udiv_qrnnd)
    192