github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/sparc32/udiv_nfp.asm (about)

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