Replace FSF snail mail address with URLs.
[glibc.git] / sysdeps / i386 / rshift.S
blobc9ec570979f5b5550f17dd4f487e1de5da4ad77c
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,
17    see <http://www.gnu.org/licenses/>.  */
19 #include "sysdep.h"
20 #include "asm-syntax.h"
21 #include "bp-sym.h"
22 #include "bp-asm.h"
24 #define PARMS   LINKAGE+12              /* space for 3 saved regs */
25 #define RES     PARMS
26 #define S       RES+PTR_SIZE
27 #define SIZE    S+PTR_SIZE
28 #define CNT     SIZE+4
30         .text
31 ENTRY (BP_SYM (__mpn_rshift))
32         ENTER
34         pushl   %edi
35         cfi_adjust_cfa_offset (4)
36         pushl   %esi
37         cfi_adjust_cfa_offset (4)
38         pushl   %ebx
39         cfi_adjust_cfa_offset (4)
41         movl    RES(%esp),%edi
42         cfi_rel_offset (edi, 8)
43         movl    S(%esp),%esi
44         cfi_rel_offset (esi, 4)
45         movl    SIZE(%esp),%edx
46         movl    CNT(%esp),%ecx
47 #if __BOUNDED_POINTERS__
48         shll    $2, %edx                /* convert limbs to bytes */
49         CHECK_BOUNDS_BOTH_WIDE (%edi, RES(%esp), %edx)
50         CHECK_BOUNDS_BOTH_WIDE (%esi, S(%esp), %edx)
51         shrl    $2, %edx
52 #endif
53         leal    -4(%edi,%edx,4),%edi
54         leal    (%esi,%edx,4),%esi
55         negl    %edx
57         movl    (%esi,%edx,4),%ebx      /* read least significant limb */
58         cfi_rel_offset (ebx, 0)
59         cfi_remember_state
60         xorl    %eax,%eax
61         shrdl   %cl,%ebx,%eax           /* compute carry limb */
62         incl    %edx
63         jz      L(end)
64         pushl   %eax                    /* push carry limb onto stack */
65         cfi_adjust_cfa_offset (4)
66         testb   $1,%dl
67         jnz     L(1)                    /* enter loop in the middle */
68         movl    %ebx,%eax
70         ALIGN (3)
71 L(oop): movl    (%esi,%edx,4),%ebx      /* load next higher limb */
72         shrdl   %cl,%ebx,%eax           /* compute result limb */
73         movl    %eax,(%edi,%edx,4)      /* store it */
74         incl    %edx
75 L(1):   movl    (%esi,%edx,4),%eax
76         shrdl   %cl,%eax,%ebx
77         movl    %ebx,(%edi,%edx,4)
78         incl    %edx
79         jnz     L(oop)
81         shrl    %cl,%eax                /* compute most significant limb */
82         movl    %eax,(%edi)             /* store it */
84         popl    %eax                    /* pop carry limb */
85         cfi_adjust_cfa_offset (-4)
87         popl    %ebx
88         cfi_adjust_cfa_offset (-4)
89         cfi_restore (ebx)
90         popl    %esi
91         cfi_adjust_cfa_offset (-4)
92         cfi_restore (esi)
93         popl    %edi
94         cfi_adjust_cfa_offset (-4)
95         cfi_restore (edi)
97         LEAVE
98         ret
100         cfi_restore_state
101 L(end): shrl    %cl,%ebx                /* compute most significant limb */
102         movl    %ebx,(%edi)             /* store it */
104         popl    %ebx
105         cfi_adjust_cfa_offset (-4)
106         cfi_restore (ebx)
107         popl    %esi
108         cfi_adjust_cfa_offset (-4)
109         cfi_restore (esi)
110         popl    %edi
111         cfi_adjust_cfa_offset (-4)
112         cfi_restore (edi)
114         LEAVE
115         ret
116 END (BP_SYM (__mpn_rshift))