Tizen 2.1 base
[external/gmp.git] / mpn / x86 / lshift.asm
1 dnl  x86 mpn_lshift -- mpn left shift.
2
3 dnl  Copyright 1992, 1994, 1996, 1999, 2000, 2001, 2002 Free Software
4 dnl  Foundation, Inc.
5 dnl
6 dnl  This file is part of the GNU MP Library.
7 dnl
8 dnl  The GNU MP Library is free software; you can redistribute it and/or
9 dnl  modify it under the terms of the GNU Lesser General Public License as
10 dnl  published by the Free Software Foundation; either version 3 of the
11 dnl  License, or (at your option) any later version.
12 dnl
13 dnl  The GNU MP Library is distributed in the hope that it will be useful,
14 dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 dnl  Lesser General Public License for more details.
17 dnl
18 dnl  You should have received a copy of the GNU Lesser General Public License
19 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
20
21 include(`../config.m4')
22
23
24 C     cycles/limb
25 C P54:   7.5
26 C P55:   7.0
27 C P6:    2.5
28 C K6:    4.5
29 C K7:    5.0
30 C P4:   14.5
31
32
33 C mp_limb_t mpn_lshift (mp_ptr dst, mp_srcptr src, mp_size_t size,
34 C                       unsigned shift);
35
36 defframe(PARAM_SHIFT,16)
37 defframe(PARAM_SIZE, 12)
38 defframe(PARAM_SRC,  8)
39 defframe(PARAM_DST,  4)
40
41         TEXT
42         ALIGN(8)
43 PROLOGUE(mpn_lshift)
44
45         pushl   %edi
46         pushl   %esi
47         pushl   %ebx
48 deflit(`FRAME',12)
49
50         movl    PARAM_DST,%edi
51         movl    PARAM_SRC,%esi
52         movl    PARAM_SIZE,%edx
53         movl    PARAM_SHIFT,%ecx
54
55         subl    $4,%esi                 C adjust src
56
57         movl    (%esi,%edx,4),%ebx      C read most significant limb
58         xorl    %eax,%eax
59         shldl(  %cl, %ebx, %eax)        C compute carry limb
60         decl    %edx
61         jz      L(end)
62         pushl   %eax                    C push carry limb onto stack
63         testb   $1,%dl
64         jnz     L(1)                    C enter loop in the middle
65         movl    %ebx,%eax
66
67         ALIGN(8)
68 L(oop): movl    (%esi,%edx,4),%ebx      C load next lower limb
69         shldl(  %cl, %ebx, %eax)        C compute result limb
70         movl    %eax,(%edi,%edx,4)      C store it
71         decl    %edx
72 L(1):   movl    (%esi,%edx,4),%eax
73         shldl(  %cl, %eax, %ebx)
74         movl    %ebx,(%edi,%edx,4)
75         decl    %edx
76         jnz     L(oop)
77
78         shll    %cl,%eax                C compute least significant limb
79         movl    %eax,(%edi)             C store it
80
81         popl    %eax                    C pop carry limb
82
83         popl    %ebx
84         popl    %esi
85         popl    %edi
86         ret
87
88 L(end): shll    %cl,%ebx                C compute least significant limb
89         movl    %ebx,(%edi)             C store it
90
91         popl    %ebx
92         popl    %esi
93         popl    %edi
94         ret
95
96 EPILOGUE()