]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/i386/rshift.S
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / i386 / rshift.S
CommitLineData
5929563f 1/* i80386 __mpn_rshift --
d614a753 2 Copyright (C) 1992-2020 Free Software Foundation, Inc.
5929563f 3 This file is part of the GNU MP Library.
28f540f4 4
5929563f 5 The GNU MP Library is free software; you can redistribute it and/or modify
6d84f89a
AJ
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or (at your
5929563f 8 option) any later version.
28f540f4 9
5929563f
UD
10 The GNU MP Library is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
6d84f89a 12 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
5929563f 13 License for more details.
28f540f4 14
6d84f89a 15 You should have received a copy of the GNU Lesser General Public License
59ba27a6 16 along with the GNU MP Library; see the file COPYING.LIB. If not,
5a82c748 17 see <https://www.gnu.org/licenses/>. */
28f540f4 18
28f540f4
RM
19#include "sysdep.h"
20#include "asm-syntax.h"
3f02f778 21
2366713d 22#define PARMS 4+12 /* space for 3 saved regs */
3f02f778 23#define RES PARMS
2366713d
JM
24#define S RES+4
25#define SIZE S+4
3f02f778 26#define CNT SIZE+4
28f540f4 27
ae828bc6 28 .text
2366713d 29ENTRY (__mpn_rshift)
3f02f778 30
28f540f4 31 pushl %edi
1ad9da69 32 cfi_adjust_cfa_offset (4)
28f540f4 33 pushl %esi
1ad9da69 34 cfi_adjust_cfa_offset (4)
28f540f4 35 pushl %ebx
1ad9da69 36 cfi_adjust_cfa_offset (4)
28f540f4 37
3f02f778 38 movl RES(%esp),%edi
1ad9da69 39 cfi_rel_offset (edi, 8)
3f02f778 40 movl S(%esp),%esi
1ad9da69 41 cfi_rel_offset (esi, 4)
3f02f778
GM
42 movl SIZE(%esp),%edx
43 movl CNT(%esp),%ecx
28f540f4
RM
44 leal -4(%edi,%edx,4),%edi
45 leal (%esi,%edx,4),%esi
46 negl %edx
47
48 movl (%esi,%edx,4),%ebx /* read least significant limb */
1ad9da69 49 cfi_rel_offset (ebx, 0)
0ee5660b 50 cfi_remember_state
28f540f4
RM
51 xorl %eax,%eax
52 shrdl %cl,%ebx,%eax /* compute carry limb */
53 incl %edx
5929563f 54 jz L(end)
28f540f4 55 pushl %eax /* push carry limb onto stack */
1ad9da69 56 cfi_adjust_cfa_offset (4)
a7123f0e 57 testb $1,%dl
5929563f 58 jnz L(1) /* enter loop in the middle */
28f540f4
RM
59 movl %ebx,%eax
60
61 ALIGN (3)
5929563f 62L(oop): movl (%esi,%edx,4),%ebx /* load next higher limb */
28f540f4
RM
63 shrdl %cl,%ebx,%eax /* compute result limb */
64 movl %eax,(%edi,%edx,4) /* store it */
65 incl %edx
5929563f 66L(1): movl (%esi,%edx,4),%eax
28f540f4
RM
67 shrdl %cl,%eax,%ebx
68 movl %ebx,(%edi,%edx,4)
69 incl %edx
5929563f 70 jnz L(oop)
28f540f4
RM
71
72 shrl %cl,%eax /* compute most significant limb */
73 movl %eax,(%edi) /* store it */
74
75 popl %eax /* pop carry limb */
1ad9da69 76 cfi_adjust_cfa_offset (-4)
28f540f4
RM
77
78 popl %ebx
1ad9da69
UD
79 cfi_adjust_cfa_offset (-4)
80 cfi_restore (ebx)
28f540f4 81 popl %esi
1ad9da69
UD
82 cfi_adjust_cfa_offset (-4)
83 cfi_restore (esi)
28f540f4 84 popl %edi
1ad9da69
UD
85 cfi_adjust_cfa_offset (-4)
86 cfi_restore (edi)
3f02f778 87
28f540f4
RM
88 ret
89
0ee5660b 90 cfi_restore_state
5929563f 91L(end): shrl %cl,%ebx /* compute most significant limb */
28f540f4
RM
92 movl %ebx,(%edi) /* store it */
93
94 popl %ebx
1ad9da69
UD
95 cfi_adjust_cfa_offset (-4)
96 cfi_restore (ebx)
28f540f4 97 popl %esi
1ad9da69
UD
98 cfi_adjust_cfa_offset (-4)
99 cfi_restore (esi)
28f540f4 100 popl %edi
1ad9da69
UD
101 cfi_adjust_cfa_offset (-4)
102 cfi_restore (edi)
3f02f778 103
28f540f4 104 ret
2366713d 105END (__mpn_rshift)