1 /* i80386 __mpn_sub_n -- Add two limb vectors of the same length > 0 and store
2 sum in a third limb vector.
3 Copyright (C) 1992,1994,1995,1997,1998,2000,2005
4 Free Software Foundation, Inc.
5 This file is part of the GNU MP Library.
7 The GNU MP Library is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or (at your
10 option) any later version.
12 The GNU MP Library is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with the GNU MP Library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 MA 02111-1307, USA. */
23 #include "asm-syntax.h"
27 #define PARMS LINKAGE+8 /* space for 2 saved regs */
29 #define S1 RES+PTR_SIZE
30 #define S2 S1+PTR_SIZE
31 #define SIZE S2+PTR_SIZE
34 ENTRY (BP_SYM (__mpn_sub_n))
38 cfi_adjust_cfa_offset (4)
40 cfi_adjust_cfa_offset (4)
43 cfi_rel_offset (edi, 4)
45 cfi_rel_offset (esi, 0)
48 #if __BOUNDED_POINTERS__
49 shll $2, %ecx /* convert limbs to bytes */
50 CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %ecx)
51 CHECK_BOUNDS_BOTH_WIDE (%esi, S1(%esp), %ecx)
52 CHECK_BOUNDS_BOTH_WIDE (%edx, S2(%esp), %ecx)
56 shrl $3,%ecx /* compute count for unrolled loop */
58 andl $7,%eax /* get index where to start loop */
59 jz L(oop) /* necessary special case for 0 */
60 incl %ecx /* adjust loop count */
61 shll $2,%eax /* adjustment for pointers... */
62 subl %eax,%edi /* ... since they are offset ... */
63 subl %eax,%esi /* ... by a constant when we ... */
64 subl %eax,%edx /* ... enter the loop */
65 shrl $2,%eax /* restore previous value */
67 /* Calculate start address in loop for PIC. Due to limitations in some
68 assemblers, Loop-L0-3 cannot be put into the leal */
70 cfi_adjust_cfa_offset (4)
71 L(0): leal (%eax,%eax,8),%eax
73 addl $(L(oop)-L(0)-3),%eax
75 cfi_adjust_cfa_offset (-4)
77 /* Calculate start address in loop for non-PIC. */
78 leal (L(oop) - 3)(%eax,%eax,8),%eax
80 jmp *%eax /* jump into loop */
82 L(oop): movl (%esi),%eax
116 cfi_adjust_cfa_offset (-4)
119 cfi_adjust_cfa_offset (-4)
124 END (BP_SYM (__mpn_sub_n))