Blame sysdeps/i386/sub_n.S

Packit 6c4009
/* i80386 __mpn_sub_n -- Add two limb vectors of the same length > 0 and store
Packit 6c4009
   sum in a third limb vector.
Packit 6c4009
   Copyright (C) 1992-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU MP Library.
Packit 6c4009
Packit 6c4009
   The GNU MP Library is free software; you can redistribute it and/or modify
Packit 6c4009
   it under the terms of the GNU Lesser General Public License as published by
Packit 6c4009
   the Free Software Foundation; either version 2.1 of the License, or (at your
Packit 6c4009
   option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU MP Library is distributed in the hope that it will be useful, but
Packit 6c4009
   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
Packit 6c4009
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
Packit 6c4009
   License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public License
Packit 6c4009
   along with the GNU MP Library; see the file COPYING.LIB.  If not,
Packit 6c4009
   see <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
#include "asm-syntax.h"
Packit 6c4009
Packit 6c4009
#define PARMS	4+8		/* space for 2 saved regs */
Packit 6c4009
#define RES	PARMS
Packit 6c4009
#define S1	RES+4
Packit 6c4009
#define S2	S1+4
Packit 6c4009
#define SIZE	S2+4
Packit 6c4009
Packit 6c4009
	.text
Packit 6c4009
ENTRY (__mpn_sub_n)
Packit 6c4009
Packit 6c4009
	pushl %edi
Packit 6c4009
	cfi_adjust_cfa_offset (4)
Packit 6c4009
	pushl %esi
Packit 6c4009
	cfi_adjust_cfa_offset (4)
Packit 6c4009
Packit 6c4009
	movl	RES(%esp),%edi
Packit 6c4009
	cfi_rel_offset (edi, 4)
Packit 6c4009
	movl	S1(%esp),%esi
Packit 6c4009
	cfi_rel_offset (esi, 0)
Packit 6c4009
	movl	S2(%esp),%edx
Packit 6c4009
	movl	SIZE(%esp),%ecx
Packit 6c4009
Packit 6c4009
#if IBT_ENABLED
Packit 6c4009
	pushl	%ebx
Packit 6c4009
	cfi_adjust_cfa_offset (4)
Packit 6c4009
	cfi_rel_offset (ebx, 0)
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
	movl	%ecx,%eax
Packit 6c4009
	shrl	$3,%ecx			/* compute count for unrolled loop */
Packit 6c4009
	negl	%eax
Packit 6c4009
	andl	$7,%eax			/* get index where to start loop */
Packit 6c4009
	jz	L(oop)			/* necessary special case for 0 */
Packit 6c4009
	incl	%ecx			/* adjust loop count */
Packit 6c4009
	shll	$2,%eax			/* adjustment for pointers... */
Packit 6c4009
	subl	%eax,%edi		/* ... since they are offset ... */
Packit 6c4009
	subl	%eax,%esi		/* ... by a constant when we ... */
Packit 6c4009
	subl	%eax,%edx		/* ... enter the loop */
Packit 6c4009
	shrl	$2,%eax			/* restore previous value */
Packit 6c4009
#if defined __CET__ && (__CET__ & 1) != 0
Packit 6c4009
	leal	-4(,%eax,4),%ebx	/* Count for 4-byte endbr32 */
Packit 6c4009
#endif
Packit 6c4009
#ifdef PIC
Packit 6c4009
/* Calculate start address in loop for PIC.  Due to limitations in some
Packit 6c4009
   assemblers, Loop-L0-3 cannot be put into the leal */
Packit 6c4009
	call	L(0)
Packit 6c4009
	cfi_adjust_cfa_offset (4)
Packit 6c4009
L(0):	leal	(%eax,%eax,8),%eax
Packit 6c4009
	addl	(%esp),%eax
Packit 6c4009
	addl	$(L(oop)-L(0)-3),%eax
Packit 6c4009
	addl	$4,%esp
Packit 6c4009
	cfi_adjust_cfa_offset (-4)
Packit 6c4009
#else
Packit 6c4009
/* Calculate start address in loop for non-PIC.  */
Packit 6c4009
 	leal	(L(oop) - 3)(%eax,%eax,8),%eax
Packit 6c4009
#endif
Packit 6c4009
#if defined __CET__ && (__CET__ & 1) != 0
Packit 6c4009
	addl	%ebx,%eax		/* Adjust for endbr32 */
Packit 6c4009
#endif
Packit 6c4009
	jmp	*%eax			/* jump into loop */
Packit 6c4009
	ALIGN (3)
Packit 6c4009
L(oop):	movl	(%esi),%eax
Packit 6c4009
	sbbl	(%edx),%eax
Packit 6c4009
	movl	%eax,(%edi)
Packit 6c4009
	_CET_ENDBR
Packit 6c4009
	movl	4(%esi),%eax
Packit 6c4009
	sbbl	4(%edx),%eax
Packit 6c4009
	movl	%eax,4(%edi)
Packit 6c4009
	_CET_ENDBR
Packit 6c4009
	movl	8(%esi),%eax
Packit 6c4009
	sbbl	8(%edx),%eax
Packit 6c4009
	movl	%eax,8(%edi)
Packit Bot ca5608
	_CET_ENDBR
Packit 6c4009
	movl	12(%esi),%eax
Packit 6c4009
	sbbl	12(%edx),%eax
Packit 6c4009
	movl	%eax,12(%edi)
Packit 6c4009
	_CET_ENDBR
Packit 6c4009
	movl	16(%esi),%eax
Packit 6c4009
	sbbl	16(%edx),%eax
Packit 6c4009
	movl	%eax,16(%edi)
Packit 6c4009
	_CET_ENDBR
Packit 6c4009
	movl	20(%esi),%eax
Packit 6c4009
	sbbl	20(%edx),%eax
Packit 6c4009
	movl	%eax,20(%edi)
Packit 6c4009
	_CET_ENDBR
Packit 6c4009
	movl	24(%esi),%eax
Packit 6c4009
	sbbl	24(%edx),%eax
Packit 6c4009
	movl	%eax,24(%edi)
Packit 6c4009
	_CET_ENDBR
Packit 6c4009
	movl	28(%esi),%eax
Packit 6c4009
	sbbl	28(%edx),%eax
Packit 6c4009
	movl	%eax,28(%edi)
Packit 6c4009
	leal	32(%edi),%edi
Packit 6c4009
	leal	32(%esi),%esi
Packit 6c4009
	leal	32(%edx),%edx
Packit 6c4009
	decl	%ecx
Packit 6c4009
	jnz	L(oop)
Packit 6c4009
Packit 6c4009
	sbbl	%eax,%eax
Packit 6c4009
	negl	%eax
Packit 6c4009
Packit 6c4009
#if defined __CET__ && (__CET__ & 1) != 0
Packit 6c4009
	popl	%ebx
Packit 6c4009
	cfi_adjust_cfa_offset (-4)
Packit 6c4009
	cfi_restore (ebx)
Packit 6c4009
#endif
Packit 6c4009
	popl %esi
Packit 6c4009
	cfi_adjust_cfa_offset (-4)
Packit 6c4009
	cfi_restore (esi)
Packit 6c4009
	popl %edi
Packit 6c4009
	cfi_adjust_cfa_offset (-4)
Packit 6c4009
	cfi_restore (edi)
Packit 6c4009
Packit 6c4009
	ret
Packit 6c4009
END (__mpn_sub_n)