 # Sw_64 __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
 # store difference in a third limb vector.

 # Copyright (C) 1995-2023 Free Software Foundation, Inc.

 # This file is part of the GNU MP Library.

 # The GNU MP Library is free software; you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as published by
 # the Free Software Foundation; either version 2.1 of the License, or (at your
 # option) any later version.

 # The GNU MP Library is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 # License for more details.

 # You should have received a copy of the GNU Lesser General Public License
 # along with the GNU MP Library.  If not, see <http://www.gnu.org/licenses/>.


 # INPUT PARAMETERS
 # res_ptr	$16
 # s1_ptr	$17
 # s2_ptr	$18
 # size		$19

	.set	noreorder
	.set	noat
.text
	.align	3
	.globl	__mpn_sub_n
	.ent	__mpn_sub_n
__mpn_sub_n:
	.frame	$30,0,$26,0

	ldl	$3,0($17)
	ldl	$4,0($18)

	subl	$19,1,$19
	and	$19,4-1,$2	# number of limbs in first loop
	bis	$31,$31,$0
	beq	$2,.L0		# if fmuldiple of 4 limbs, skip first loop

	subl	$19,$2,$19

.Loop0:	subl	$2,1,$2
	ldl	$5,8($17)
	addl	$4,$0,$4
	ldl	$6,8($18)
	cmpult	$4,$0,$1
	subl	$3,$4,$4
	cmpult	$3,$4,$0
	stl	$4,0($16)
	or	$0,$1,$0

	addl	$17,8,$17
	addl	$18,8,$18
	bis	$5,$5,$3
	bis	$6,$6,$4
	addl	$16,8,$16
	bne	$2,.Loop0

.L0:	beq	$19,.Lend

	.align	3
.Loop:	subl	$19,4,$19

	ldl	$5,8($17)
	addl	$4,$0,$4
	ldl	$6,8($18)
	cmpult	$4,$0,$1
	subl	$3,$4,$4
	cmpult	$3,$4,$0
	stl	$4,0($16)
	or	$0,$1,$0

	ldl	$3,16($17)
	addl	$6,$0,$6
	ldl	$4,16($18)
	cmpult	$6,$0,$1
	subl	$5,$6,$6
	cmpult	$5,$6,$0
	stl	$6,8($16)
	or	$0,$1,$0

	ldl	$5,24($17)
	addl	$4,$0,$4
	ldl	$6,24($18)
	cmpult	$4,$0,$1
	subl	$3,$4,$4
	cmpult	$3,$4,$0
	stl	$4,16($16)
	or	$0,$1,$0

	ldl	$3,32($17)
	addl	$6,$0,$6
	ldl	$4,32($18)
	cmpult	$6,$0,$1
	subl	$5,$6,$6
	cmpult	$5,$6,$0
	stl	$6,24($16)
	or	$0,$1,$0

	addl	$17,32,$17
	addl	$18,32,$18
	addl	$16,32,$16
	bne	$19,.Loop

.Lend:	addl	$4,$0,$4
	cmpult	$4,$0,$1
	subl	$3,$4,$4
	cmpult	$3,$4,$0
	stl	$4,0($16)
	or	$0,$1,$0
	ret	$31,($26),1

	.end	__mpn_sub_n
