More compact unwind info.
[glibc.git] / sysdeps / i386 / rshift.S
blob332c4d09e77a809211a8720056ce72e8fb59ebf8
1 /* i80386 __mpn_rshift --
2    Copyright (C) 1992,1994,1997-2000,2005,2010 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_rshift))
33         ENTER
35         pushl   %edi
36         cfi_adjust_cfa_offset (4)
37         pushl   %esi
38         cfi_adjust_cfa_offset (4)
39         pushl   %ebx
40         cfi_adjust_cfa_offset (4)
42         movl    RES(%esp),%edi
43         cfi_rel_offset (edi, 8)
44         movl    S(%esp),%esi
45         cfi_rel_offset (esi, 4)
46         movl    SIZE(%esp),%edx
47         movl    CNT(%esp),%ecx
48 #if __BOUNDED_POINTERS__
49         shll    $2, %edx                /* convert limbs to bytes */
50         CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %edx)
51         CHECK_BOUNDS_BOTH_WIDE (%esi, S(%esp), %edx)
52         shrl    $2, %edx
53 #endif
54         leal    -4(%edi,%edx,4),%edi
55         leal    (%esi,%edx,4),%esi
56         negl    %edx
58         movl    (%esi,%edx,4),%ebx      /* read least significant limb */
59         cfi_rel_offset (ebx, 0)
60         cfi_remember_state
61         xorl    %eax,%eax
62         shrdl   %cl,%ebx,%eax           /* compute carry limb */
63         incl    %edx
64         jz      L(end)
65         pushl   %eax                    /* push carry limb onto stack */
66         cfi_adjust_cfa_offset (4)
67         testb   $1,%dl
68         jnz     L(1)                    /* enter loop in the middle */
69         movl    %ebx,%eax
71         ALIGN (3)
72 L(oop): movl    (%esi,%edx,4),%ebx      /* load next higher limb */
73         shrdl   %cl,%ebx,%eax           /* compute result limb */
74         movl    %eax,(%edi,%edx,4)      /* store it */
75         incl    %edx
76 L(1):   movl    (%esi,%edx,4),%eax
77         shrdl   %cl,%eax,%ebx
78         movl    %ebx,(%edi,%edx,4)
79         incl    %edx
80         jnz     L(oop)
82         shrl    %cl,%eax                /* compute most significant limb */
83         movl    %eax,(%edi)             /* store it */
85         popl    %eax                    /* pop carry limb */
86         cfi_adjust_cfa_offset (-4)
88         popl    %ebx
89         cfi_adjust_cfa_offset (-4)
90         cfi_restore (ebx)
91         popl    %esi
92         cfi_adjust_cfa_offset (-4)
93         cfi_restore (esi)
94         popl    %edi
95         cfi_adjust_cfa_offset (-4)
96         cfi_restore (edi)
98         LEAVE
99         ret
101         cfi_restore_state
102 L(end): shrl    %cl,%ebx                /* compute most significant limb */
103         movl    %ebx,(%edi)             /* store it */
105         popl    %ebx
106         cfi_adjust_cfa_offset (-4)
107         cfi_restore (ebx)
108         popl    %esi
109         cfi_adjust_cfa_offset (-4)
110         cfi_restore (esi)
111         popl    %edi
112         cfi_adjust_cfa_offset (-4)
113         cfi_restore (edi)
115         LEAVE
116         ret
117 END (BP_SYM (__mpn_rshift))