1 /* Add two limb vectors of the same length > 0 and store sum in a third
3 Copyright (C) 1992,94,95,97,98,2000,2005 Free Software Foundation, Inc.
4 This file is part of the GNU MP Library.
6 The GNU MP Library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or (at your
9 option) any later version.
11 The GNU MP Library is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with the GNU MP Library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19 MA 02111-1307, USA. */
22 #include "asm-syntax.h"
26 #define PARMS LINKAGE+8 /* space for 2 saved regs */
28 #define S1 RES+PTR_SIZE
29 #define S2 S1+PTR_SIZE
30 #define SIZE S2+PTR_SIZE
34 L(1): addl (%esp), %eax
37 ENTRY (BP_SYM (__mpn_add_n))
41 cfi_adjust_cfa_offset (4)
43 cfi_adjust_cfa_offset (4)
46 cfi_rel_offset (edi, 4)
48 cfi_rel_offset (esi, 0)
51 #if __BOUNDED_POINTERS__
52 shll $2, %ecx /* convert limbs to bytes */
53 CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %ecx)
54 CHECK_BOUNDS_BOTH_WIDE (%esi, S1(%esp), %ecx)
55 CHECK_BOUNDS_BOTH_WIDE (%edx, S2(%esp), %ecx)
59 shrl $3,%ecx /* compute count for unrolled loop */
61 andl $7,%eax /* get index where to start loop */
62 jz L(oop) /* necessary special case for 0 */
63 incl %ecx /* adjust loop count */
64 shll $2,%eax /* adjustment for pointers... */
65 subl %eax,%edi /* ... since they are offset ... */
66 subl %eax,%esi /* ... by a constant when we ... */
67 subl %eax,%edx /* ... enter the loop */
68 shrl $2,%eax /* restore previous value */
70 /* Calculate start address in loop for PIC. */
71 leal (L(oop)-L(0)-3)(%eax,%eax,8),%eax
75 /* Calculate start address in loop for non-PIC. */
76 leal (L(oop) - 3)(%eax,%eax,8),%eax
78 jmp *%eax /* jump into loop */
80 L(oop): movl (%esi),%eax
114 cfi_adjust_cfa_offset (-4)
117 cfi_adjust_cfa_offset (-4)
122 END (BP_SYM (__mpn_add_n))