(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / sysdeps / i386 / lshift.S
blobab1c89d23bc880cf52e86d915f7978f15fc1ae8c
1 /* i80386 __mpn_lshift --
2    Copyright (C) 1992, 1994, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
3    This file is part of the GNU MP Library.
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.
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.
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, write to
17    the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18    MA 02111-1307, USA. */
20 #include "sysdep.h"
21 #include "asm-syntax.h"
22 #include "bp-sym.h"
23 #include "bp-asm.h"
25 #define PARMS   LINKAGE+12              /* space for 3 saved regs */
26 #define RES     PARMS
27 #define S       RES+PTR_SIZE
28 #define SIZE    S+PTR_SIZE
29 #define CNT     SIZE+4
31         .text
32 ENTRY (BP_SYM (__mpn_lshift))
33         ENTER
35         pushl   %edi
36         pushl   %esi
37         pushl   %ebx
39         movl    RES(%esp),%edi
40         movl    S(%esp),%esi
41         movl    SIZE(%esp),%edx
42         movl    CNT(%esp),%ecx
43 #if __BOUNDED_POINTERS__
44         shll    $2, %edx                /* convert limbs to bytes */
45         CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %edx)
46         CHECK_BOUNDS_BOTH_WIDE (%esi, S(%esp), %edx)
47         shrl    $2, %edx
48 #endif
49         subl    $4,%esi                 /* adjust s_ptr */
51         movl    (%esi,%edx,4),%ebx      /* read most significant limb */
52         xorl    %eax,%eax
53         shldl   %cl,%ebx,%eax           /* compute carry limb */
54         decl    %edx
55         jz      L(end)
56         pushl   %eax                    /* push carry limb onto stack */
57         testb   $1,%dl
58         jnz     L(1)                    /* enter loop in the middle */
59         movl    %ebx,%eax
61         ALIGN (3)
62 L(oop): movl    (%esi,%edx,4),%ebx      /* load next lower limb */
63         shldl   %cl,%ebx,%eax           /* compute result limb */
64         movl    %eax,(%edi,%edx,4)      /* store it */
65         decl    %edx
66 L(1):   movl    (%esi,%edx,4),%eax
67         shldl   %cl,%eax,%ebx
68         movl    %ebx,(%edi,%edx,4)
69         decl    %edx
70         jnz     L(oop)
72         shll    %cl,%eax                /* compute least significant limb */
73         movl    %eax,(%edi)             /* store it */
75         popl    %eax                    /* pop carry limb */
77         popl    %ebx
78         popl    %esi
79         popl    %edi
81         LEAVE
82         ret
84 L(end): shll    %cl,%ebx                /* compute least significant limb */
85         movl    %ebx,(%edi)             /* store it */
87         popl    %ebx
88         popl    %esi
89         popl    %edi
91         LEAVE
92         ret
93 END (BP_SYM (__mpn_lshift))