1 | /* i80386 __mpn_lshift -- |
2 | Copyright (C) 1992-2024 Free Software Foundation, Inc. |
3 | This file is part of the GNU MP Library. |
4 | |
5 | The GNU MP Library is free software; you can redistribute it and/or modify |
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 |
8 | option) any later version. |
9 | |
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 |
12 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
13 | License for more details. |
14 | |
15 | You should have received a copy of the GNU Lesser General Public License |
16 | along with the GNU MP Library; see the file COPYING.LIB. If not, |
17 | see <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #include "sysdep.h" |
20 | #include "asm-syntax.h" |
21 | |
22 | #define PARMS 4+12 /* space for 3 saved regs */ |
23 | #define RES PARMS |
24 | #define S RES+4 |
25 | #define SIZE S+4 |
26 | #define CNT SIZE+4 |
27 | |
28 | .text |
29 | ENTRY (__mpn_lshift) |
30 | |
31 | pushl %edi |
32 | cfi_adjust_cfa_offset (4) |
33 | pushl %esi |
34 | cfi_adjust_cfa_offset (4) |
35 | pushl %ebx |
36 | cfi_adjust_cfa_offset (4) |
37 | |
38 | movl RES(%esp),%edi |
39 | cfi_rel_offset (edi, 8) |
40 | movl S(%esp),%esi |
41 | cfi_rel_offset (esi, 4) |
42 | movl SIZE(%esp),%edx |
43 | movl CNT(%esp),%ecx |
44 | subl $4,%esi /* adjust s_ptr */ |
45 | |
46 | movl (%esi,%edx,4),%ebx /* read most significant limb */ |
47 | cfi_rel_offset (ebx, 0) |
48 | cfi_remember_state |
49 | xorl %eax,%eax |
50 | shldl %cl,%ebx,%eax /* compute carry limb */ |
51 | decl %edx |
52 | jz L(end) |
53 | pushl %eax /* push carry limb onto stack */ |
54 | cfi_adjust_cfa_offset (4) |
55 | testb $1,%dl |
56 | jnz L(1) /* enter loop in the middle */ |
57 | movl %ebx,%eax |
58 | |
59 | ALIGN (3) |
60 | L(oop): movl (%esi,%edx,4),%ebx /* load next lower limb */ |
61 | shldl %cl,%ebx,%eax /* compute result limb */ |
62 | movl %eax,(%edi,%edx,4) /* store it */ |
63 | decl %edx |
64 | L(1): movl (%esi,%edx,4),%eax |
65 | shldl %cl,%eax,%ebx |
66 | movl %ebx,(%edi,%edx,4) |
67 | decl %edx |
68 | jnz L(oop) |
69 | |
70 | shll %cl,%eax /* compute least significant limb */ |
71 | movl %eax,(%edi) /* store it */ |
72 | |
73 | popl %eax /* pop carry limb */ |
74 | cfi_adjust_cfa_offset (-4) |
75 | |
76 | popl %ebx |
77 | cfi_adjust_cfa_offset (-4) |
78 | cfi_restore (ebx) |
79 | popl %esi |
80 | cfi_adjust_cfa_offset (-4) |
81 | cfi_restore (esi) |
82 | popl %edi |
83 | cfi_adjust_cfa_offset (-4) |
84 | cfi_restore (edi) |
85 | |
86 | ret |
87 | |
88 | cfi_restore_state |
89 | L(end): shll %cl,%ebx /* compute least significant limb */ |
90 | movl %ebx,(%edi) /* store it */ |
91 | |
92 | popl %ebx |
93 | cfi_adjust_cfa_offset (-4) |
94 | cfi_restore (ebx) |
95 | popl %esi |
96 | cfi_adjust_cfa_offset (-4) |
97 | cfi_restore (esi) |
98 | popl %edi |
99 | cfi_adjust_cfa_offset (-4) |
100 | cfi_restore (edi) |
101 | |
102 | ret |
103 | END (__mpn_lshift) |
104 | |