Blame sysdeps/i386/rshift.S

Packit 6c4009
/* i80386 __mpn_rshift --
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+12		/* space for 3 saved regs */
Packit 6c4009
#define RES	PARMS
Packit 6c4009
#define S	RES+4
Packit 6c4009
#define SIZE	S+4
Packit 6c4009
#define CNT	SIZE+4
Packit 6c4009
Packit 6c4009
	.text
Packit 6c4009
ENTRY (__mpn_rshift)
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
	pushl	%ebx
Packit 6c4009
	cfi_adjust_cfa_offset (4)
Packit 6c4009
Packit 6c4009
	movl	RES(%esp),%edi
Packit 6c4009
	cfi_rel_offset (edi, 8)
Packit 6c4009
	movl	S(%esp),%esi
Packit 6c4009
	cfi_rel_offset (esi, 4)
Packit 6c4009
	movl	SIZE(%esp),%edx
Packit 6c4009
	movl	CNT(%esp),%ecx
Packit 6c4009
	leal	-4(%edi,%edx,4),%edi
Packit 6c4009
	leal	(%esi,%edx,4),%esi
Packit 6c4009
	negl	%edx
Packit 6c4009
Packit 6c4009
	movl	(%esi,%edx,4),%ebx	/* read least significant limb */
Packit 6c4009
	cfi_rel_offset (ebx, 0)
Packit 6c4009
	cfi_remember_state
Packit 6c4009
	xorl	%eax,%eax
Packit 6c4009
	shrdl	%cl,%ebx,%eax		/* compute carry limb */
Packit 6c4009
	incl	%edx
Packit 6c4009
	jz	L(end)
Packit 6c4009
	pushl	%eax			/* push carry limb onto stack */
Packit 6c4009
	cfi_adjust_cfa_offset (4)
Packit 6c4009
	testb	$1,%dl
Packit 6c4009
	jnz	L(1)			/* enter loop in the middle */
Packit 6c4009
	movl	%ebx,%eax
Packit 6c4009
Packit 6c4009
	ALIGN (3)
Packit 6c4009
L(oop):	movl	(%esi,%edx,4),%ebx	/* load next higher limb */
Packit 6c4009
	shrdl	%cl,%ebx,%eax		/* compute result limb */
Packit 6c4009
	movl	%eax,(%edi,%edx,4)	/* store it */
Packit 6c4009
	incl	%edx
Packit 6c4009
L(1):	movl	(%esi,%edx,4),%eax
Packit 6c4009
	shrdl	%cl,%eax,%ebx
Packit 6c4009
	movl	%ebx,(%edi,%edx,4)
Packit 6c4009
	incl	%edx
Packit 6c4009
	jnz	L(oop)
Packit 6c4009
Packit 6c4009
	shrl	%cl,%eax		/* compute most significant limb */
Packit 6c4009
	movl	%eax,(%edi)		/* store it */
Packit 6c4009
Packit 6c4009
	popl	%eax			/* pop carry limb */
Packit 6c4009
	cfi_adjust_cfa_offset (-4)
Packit 6c4009
Packit 6c4009
	popl	%ebx
Packit 6c4009
	cfi_adjust_cfa_offset (-4)
Packit 6c4009
	cfi_restore (ebx)
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
Packit 6c4009
	cfi_restore_state
Packit 6c4009
L(end):	shrl	%cl,%ebx		/* compute most significant limb */
Packit 6c4009
	movl	%ebx,(%edi)		/* store it */
Packit 6c4009
Packit 6c4009
	popl	%ebx
Packit 6c4009
	cfi_adjust_cfa_offset (-4)
Packit 6c4009
	cfi_restore (ebx)
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_rshift)