Update.
[glibc.git] / sysdeps / i386 / rshift.S
bloba0382672de71773f1b64a43d8c12837df0d65b0e
1 /* i80386 __mpn_rshift --
2    Copyright (C) 1992, 1994, 1997 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 Library General Public License as published by
7    the Free Software Foundation; either version 2 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 Library General Public
13    License for more details.
15    You should have received a copy of the GNU Library 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. */
21   INPUT PARAMETERS
22   res_ptr       (sp + 4)
23   s_ptr         (sp + 8)
24   size          (sp + 12)
25   cnt           (sp + 16)
28 #include "sysdep.h"
29 #include "asm-syntax.h"
31 .text
32         ALIGN (3)
33         .globl C_SYMBOL_NAME(__mpn_rshift)
34         ASM_TYPE_DIRECTIVE(C_SYMBOL_NAME(__mpn_rshift),@function)
35 C_SYMBOL_NAME(__mpn_rshift:)
36         pushl   %edi
37         pushl   %esi
38         pushl   %ebx
40         movl    16(%esp),%edi           /* res_ptr */
41         movl    20(%esp),%esi           /* s_ptr */
42         movl    24(%esp),%edx           /* size */
43         movl    28(%esp),%ecx           /* cnt */
45         leal    -4(%edi,%edx,4),%edi
46         leal    (%esi,%edx,4),%esi
47         negl    %edx
49         movl    (%esi,%edx,4),%ebx      /* read least significant limb */
50         xorl    %eax,%eax
51         shrdl   %cl,%ebx,%eax           /* compute carry limb */
52         incl    %edx
53         jz      L(end)
54         pushl   %eax                    /* push carry limb onto stack */
55         testb   $1,%edx
56         jnz     L(1)                    /* enter loop in the middle */
57         movl    %ebx,%eax
59         ALIGN (3)
60 L(oop): movl    (%esi,%edx,4),%ebx      /* load next higher limb */
61         shrdl   %cl,%ebx,%eax           /* compute result limb */
62         movl    %eax,(%edi,%edx,4)      /* store it */
63         incl    %edx
64 L(1):   movl    (%esi,%edx,4),%eax
65         shrdl   %cl,%eax,%ebx
66         movl    %ebx,(%edi,%edx,4)
67         incl    %edx
68         jnz     L(oop)
70         shrl    %cl,%eax                /* compute most significant limb */
71         movl    %eax,(%edi)             /* store it */
73         popl    %eax                    /* pop carry limb */
75         popl    %ebx
76         popl    %esi
77         popl    %edi
78         ret
80 L(end): shrl    %cl,%ebx                /* compute most significant limb */
81         movl    %ebx,(%edi)             /* store it */
83         popl    %ebx
84         popl    %esi
85         popl    %edi
86         ret
88         ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(__mpn_rshift))