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

     1  dnl  HP-PA 2.0 64-bit mpn_udiv_qrnnd_r.
     2  
     3  dnl  Copyright 2001-2003 Free Software Foundation, Inc.
     4  
     5  dnl  This file is part of the GNU MP Library.
     6  dnl
     7  dnl  The GNU MP Library is free software; you can redistribute it and/or modify
     8  dnl  it under the terms of either:
     9  dnl
    10  dnl    * the GNU Lesser General Public License as published by the Free
    11  dnl      Software Foundation; either version 3 of the License, or (at your
    12  dnl      option) any later version.
    13  dnl
    14  dnl  or
    15  dnl
    16  dnl    * the GNU General Public License as published by the Free Software
    17  dnl      Foundation; either version 2 of the License, or (at your option) any
    18  dnl      later version.
    19  dnl
    20  dnl  or both in parallel, as here.
    21  dnl
    22  dnl  The GNU MP Library is distributed in the hope that it will be useful, but
    23  dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    24  dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    25  dnl  for more details.
    26  dnl
    27  dnl  You should have received copies of the GNU General Public License and the
    28  dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
    29  dnl  see https://www.gnu.org/licenses/.
    30  
    31  include(`../config.m4')
    32  
    33  C This runs at about 280 cycles on both PA8000 and PA8500, corresponding to a
    34  C bit more than 4 cycles/bit.
    35  
    36  C INPUT PARAMETERS
    37  define(`n1',`%r26')
    38  define(`n0',`%r25')
    39  define(`d',`%r24')
    40  define(`remptr',`%r23')
    41  
    42  define(`q',`%r28')
    43  define(`dn',`%r29')
    44  
    45  define(`old_divstep',
    46         `add,dc		n0,n0,n0
    47  	add,dc		n1,n1,n1
    48  	sub,*<<		n1,d,%r22
    49  	copy		%r22,n1')
    50  
    51  define(`divstep',
    52         `add		n0,n0,n0
    53  	add,dc		n1,n1,n1
    54  	sub		n1,d,%r1
    55  	add,dc		q,q,q
    56  	cmpclr,*<<	n1,d,%r0
    57  	copy		%r1,n1
    58  ')
    59  
    60  ifdef(`HAVE_ABI_2_0w',
    61  `	.level	2.0w
    62  ',`	.level	2.0
    63  ')
    64  PROLOGUE(mpn_udiv_qrnnd_r)
    65  ifdef(`HAVE_ABI_2_0n',
    66  `	depd		%r25,31,32,%r26
    67  	depd		%r23,31,32,%r24
    68  	copy		%r24,%r25
    69  	ldd		-56(%r30),%r24
    70  	ldw		-60(%r30),%r23
    71  ')
    72  	ldi		0,q
    73  	cmpib,*>=	0,d,L(large_divisor)
    74  	ldi		8,%r31		C setup loop counter
    75  
    76  	sub		%r0,d,dn
    77  LDEF(Loop)
    78  	divstep divstep divstep divstep divstep divstep divstep divstep
    79  	addib,<>	-1,%r31,L(Loop)
    80  	nop
    81  
    82  ifdef(`HAVE_ABI_2_0n',
    83  `	copy		%r28,%r29
    84  	extrd,u		%r28,31,32,%r28
    85  ')
    86  	bve		(%r2)
    87  	std		n1,0(remptr)	C store remainder
    88  
    89  LDEF(large_divisor)
    90  	extrd,u		n0,63,1,%r19	C save lsb of dividend
    91  	shrpd		n1,n0,1,n0	C n0 = lo(n1n0 >> 1)
    92  	shrpd		%r0,n1,1,n1	C n1 = hi(n1n0 >> 1)
    93  	extrd,u		d,63,1,%r20	C save lsb of divisor
    94  	shrpd		%r0,d,1,d	C d = floor(orig_d / 2)
    95  	add,l		%r20,d,d	C d = ceil(orig_d / 2)
    96  
    97  	sub		%r0,d,dn
    98  LDEF(Loop2)
    99  	divstep divstep divstep divstep divstep divstep divstep divstep
   100  	addib,<>	-1,%r31,L(Loop2)
   101  	nop
   102  
   103  	cmpib,*=	0,%r20,L(even_divisor)
   104  	shladd		n1,1,%r19,n1	C shift in omitted dividend lsb
   105  
   106  	add		d,d,d		C restore orig...
   107  	sub		d,%r20,d	C ...d value
   108  	sub		%r0,d,dn	C r21 = -d
   109  
   110  	add,*nuv	n1,q,n1		C fix remainder for omitted divisor lsb
   111  	add,l		n1,dn,n1	C adjust remainder if rem. fix carried
   112  	add,dc		%r0,q,q		C adjust quotient accordingly
   113  
   114  	sub,*<<		n1,d,%r0	C remainder >= divisor?
   115  	add,l		n1,dn,n1	C adjust remainder
   116  	add,dc		%r0,q,q		C adjust quotient
   117  
   118  LDEF(even_divisor)
   119  ifdef(`HAVE_ABI_2_0n',
   120  `	copy		%r28,%r29
   121  	extrd,u		%r28,31,32,%r28
   122  ')
   123  	bve		(%r2)
   124  	std		n1,0(remptr)	C store remainder
   125  EPILOGUE(mpn_udiv_qrnnd_r)