]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/i386/sub_n.S
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / i386 / sub_n.S
CommitLineData
28f540f4
RM
1/* i80386 __mpn_sub_n -- Add two limb vectors of the same length > 0 and store
2 sum in a third limb vector.
d614a753 3 Copyright (C) 1992-2020 Free Software Foundation, Inc.
5929563f 4 This file is part of the GNU MP Library.
28f540f4 5
5929563f 6 The GNU MP Library is free software; you can redistribute it and/or modify
6d84f89a
AJ
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
5929563f 9 option) any later version.
28f540f4 10
5929563f
UD
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
6d84f89a 13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
5929563f 14 License for more details.
28f540f4 15
6d84f89a 16 You should have received a copy of the GNU Lesser General Public License
59ba27a6 17 along with the GNU MP Library; see the file COPYING.LIB. If not,
5a82c748 18 see <https://www.gnu.org/licenses/>. */
28f540f4 19
be9ccd27 20#include <sysdep.h>
28f540f4 21#include "asm-syntax.h"
3f02f778 22
2366713d 23#define PARMS 4+8 /* space for 2 saved regs */
3f02f778 24#define RES PARMS
2366713d
JM
25#define S1 RES+4
26#define S2 S1+4
27#define SIZE S2+4
28f540f4 28
ae828bc6 29 .text
2366713d 30ENTRY (__mpn_sub_n)
3f02f778 31
28f540f4 32 pushl %edi
1ad9da69 33 cfi_adjust_cfa_offset (4)
28f540f4 34 pushl %esi
1ad9da69 35 cfi_adjust_cfa_offset (4)
28f540f4 36
3f02f778 37 movl RES(%esp),%edi
1ad9da69 38 cfi_rel_offset (edi, 4)
3f02f778 39 movl S1(%esp),%esi
1ad9da69 40 cfi_rel_offset (esi, 0)
3f02f778
GM
41 movl S2(%esp),%edx
42 movl SIZE(%esp),%ecx
be9ccd27
L
43
44#if IBT_ENABLED
45 pushl %ebx
46 cfi_adjust_cfa_offset (4)
47 cfi_rel_offset (ebx, 0)
48#endif
49
28f540f4
RM
50 movl %ecx,%eax
51 shrl $3,%ecx /* compute count for unrolled loop */
52 negl %eax
53 andl $7,%eax /* get index where to start loop */
5929563f 54 jz L(oop) /* necessary special case for 0 */
28f540f4
RM
55 incl %ecx /* adjust loop count */
56 shll $2,%eax /* adjustment for pointers... */
57 subl %eax,%edi /* ... since they are offset ... */
58 subl %eax,%esi /* ... by a constant when we ... */
59 subl %eax,%edx /* ... enter the loop */
60 shrl $2,%eax /* restore previous value */
be9ccd27
L
61#if defined __CET__ && (__CET__ & 1) != 0
62 leal -4(,%eax,4),%ebx /* Count for 4-byte endbr32 */
63#endif
53afa8d9 64#ifdef PIC
8f5ca04b
RM
65/* Calculate start address in loop for PIC. Due to limitations in some
66 assemblers, Loop-L0-3 cannot be put into the leal */
5929563f 67 call L(0)
fee732e5 68 cfi_adjust_cfa_offset (4)
5929563f 69L(0): leal (%eax,%eax,8),%eax
8f5ca04b 70 addl (%esp),%eax
5929563f 71 addl $(L(oop)-L(0)-3),%eax
8f5ca04b 72 addl $4,%esp
fee732e5 73 cfi_adjust_cfa_offset (-4)
53afa8d9 74#else
8f5ca04b 75/* Calculate start address in loop for non-PIC. */
5929563f 76 leal (L(oop) - 3)(%eax,%eax,8),%eax
be9ccd27
L
77#endif
78#if defined __CET__ && (__CET__ & 1) != 0
79 addl %ebx,%eax /* Adjust for endbr32 */
e215c478 80#endif
8f5ca04b 81 jmp *%eax /* jump into loop */
28f540f4 82 ALIGN (3)
5929563f 83L(oop): movl (%esi),%eax
28f540f4
RM
84 sbbl (%edx),%eax
85 movl %eax,(%edi)
be9ccd27 86 _CET_ENDBR
28f540f4
RM
87 movl 4(%esi),%eax
88 sbbl 4(%edx),%eax
89 movl %eax,4(%edi)
be9ccd27 90 _CET_ENDBR
28f540f4
RM
91 movl 8(%esi),%eax
92 sbbl 8(%edx),%eax
93 movl %eax,8(%edi)
94 movl 12(%esi),%eax
95 sbbl 12(%edx),%eax
96 movl %eax,12(%edi)
be9ccd27 97 _CET_ENDBR
28f540f4
RM
98 movl 16(%esi),%eax
99 sbbl 16(%edx),%eax
100 movl %eax,16(%edi)
be9ccd27 101 _CET_ENDBR
28f540f4
RM
102 movl 20(%esi),%eax
103 sbbl 20(%edx),%eax
104 movl %eax,20(%edi)
be9ccd27 105 _CET_ENDBR
28f540f4
RM
106 movl 24(%esi),%eax
107 sbbl 24(%edx),%eax
108 movl %eax,24(%edi)
be9ccd27 109 _CET_ENDBR
28f540f4
RM
110 movl 28(%esi),%eax
111 sbbl 28(%edx),%eax
112 movl %eax,28(%edi)
113 leal 32(%edi),%edi
114 leal 32(%esi),%esi
115 leal 32(%edx),%edx
116 decl %ecx
5929563f 117 jnz L(oop)
28f540f4
RM
118
119 sbbl %eax,%eax
120 negl %eax
121
be9ccd27
L
122#if defined __CET__ && (__CET__ & 1) != 0
123 popl %ebx
124 cfi_adjust_cfa_offset (-4)
125 cfi_restore (ebx)
126#endif
28f540f4 127 popl %esi
1ad9da69
UD
128 cfi_adjust_cfa_offset (-4)
129 cfi_restore (esi)
28f540f4 130 popl %edi
1ad9da69
UD
131 cfi_adjust_cfa_offset (-4)
132 cfi_restore (edi)
3f02f778 133
28f540f4 134 ret
2366713d 135END (__mpn_sub_n)