alpha: Purge __ASSUME_STAT64_SYSCALL
[glibc.git] / sysdeps / i386 / sub_n.S
blobdbda4d4d4e7180f478f7970235f0871497368b61
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,
19    see <http://www.gnu.org/licenses/>.  */
21 #include "sysdep.h"
22 #include "asm-syntax.h"
23 #include "bp-sym.h"
24 #include "bp-asm.h"
26 #define PARMS   LINKAGE+8               /* space for 2 saved regs */
27 #define RES     PARMS
28 #define S1      RES+PTR_SIZE
29 #define S2      S1+PTR_SIZE
30 #define SIZE    S2+PTR_SIZE
32         .text
33 ENTRY (BP_SYM (__mpn_sub_n))
34         ENTER
36         pushl %edi
37         cfi_adjust_cfa_offset (4)
38         pushl %esi
39         cfi_adjust_cfa_offset (4)
41         movl    RES(%esp),%edi
42         cfi_rel_offset (edi, 4)
43         movl    S1(%esp),%esi
44         cfi_rel_offset (esi, 0)
45         movl    S2(%esp),%edx
46         movl    SIZE(%esp),%ecx
47 #if __BOUNDED_POINTERS__
48         shll    $2, %ecx        /* convert limbs to bytes */
49         CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %ecx)
50         CHECK_BOUNDS_BOTH_WIDE (%esi, S1(%esp), %ecx)
51         CHECK_BOUNDS_BOTH_WIDE (%edx, S2(%esp), %ecx)
52         shrl    $2, %ecx
53 #endif
54         movl    %ecx,%eax
55         shrl    $3,%ecx                 /* compute count for unrolled loop */
56         negl    %eax
57         andl    $7,%eax                 /* get index where to start loop */
58         jz      L(oop)                  /* necessary special case for 0 */
59         incl    %ecx                    /* adjust loop count */
60         shll    $2,%eax                 /* adjustment for pointers... */
61         subl    %eax,%edi               /* ... since they are offset ... */
62         subl    %eax,%esi               /* ... by a constant when we ... */
63         subl    %eax,%edx               /* ... enter the loop */
64         shrl    $2,%eax                 /* restore previous value */
65 #ifdef PIC
66 /* Calculate start address in loop for PIC.  Due to limitations in some
67    assemblers, Loop-L0-3 cannot be put into the leal */
68         call    L(0)
69         cfi_adjust_cfa_offset (4)
70 L(0):   leal    (%eax,%eax,8),%eax
71         addl    (%esp),%eax
72         addl    $(L(oop)-L(0)-3),%eax
73         addl    $4,%esp
74         cfi_adjust_cfa_offset (-4)
75 #else
76 /* Calculate start address in loop for non-PIC.  */
77         leal    (L(oop) - 3)(%eax,%eax,8),%eax
78 #endif
79         jmp     *%eax                   /* jump into loop */
80         ALIGN (3)
81 L(oop): movl    (%esi),%eax
82         sbbl    (%edx),%eax
83         movl    %eax,(%edi)
84         movl    4(%esi),%eax
85         sbbl    4(%edx),%eax
86         movl    %eax,4(%edi)
87         movl    8(%esi),%eax
88         sbbl    8(%edx),%eax
89         movl    %eax,8(%edi)
90         movl    12(%esi),%eax
91         sbbl    12(%edx),%eax
92         movl    %eax,12(%edi)
93         movl    16(%esi),%eax
94         sbbl    16(%edx),%eax
95         movl    %eax,16(%edi)
96         movl    20(%esi),%eax
97         sbbl    20(%edx),%eax
98         movl    %eax,20(%edi)
99         movl    24(%esi),%eax
100         sbbl    24(%edx),%eax
101         movl    %eax,24(%edi)
102         movl    28(%esi),%eax
103         sbbl    28(%edx),%eax
104         movl    %eax,28(%edi)
105         leal    32(%edi),%edi
106         leal    32(%esi),%esi
107         leal    32(%edx),%edx
108         decl    %ecx
109         jnz     L(oop)
111         sbbl    %eax,%eax
112         negl    %eax
114         popl %esi
115         cfi_adjust_cfa_offset (-4)
116         cfi_restore (esi)
117         popl %edi
118         cfi_adjust_cfa_offset (-4)
119         cfi_restore (edi)
121         LEAVE
122         ret
123 END (BP_SYM (__mpn_sub_n))