~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/gmp/mpn/x86/pentium/mul_1.asm

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2006-05-17 02:46:26 UTC
  • Revision ID: james.westby@ubuntu.com-20060517024626-lljr08ftv9g9vefl
Tags: upstream-0.9h-20060510
ImportĀ upstreamĀ versionĀ 0.9h-20060510

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl  Intel Pentium mpn_mul_1 -- mpn by limb multiplication.
 
2
 
 
3
dnl  Copyright 1992, 1994, 1996, 1999, 2000, 2002 Free Software Foundation,
 
4
dnl  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 2.1 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
 
19
dnl  License along with the GNU MP Library; see the file COPYING.LIB.  If
 
20
dnl  not, write to the Free Software Foundation, Inc., 59 Temple Place -
 
21
dnl  Suite 330, Boston, MA 02111-1307, USA. */
 
22
 
 
23
include(`../config.m4')
 
24
 
 
25
 
 
26
C P5: 12.0 cycles/limb
 
27
 
 
28
 
 
29
C mp_limb_t mpn_mul_1 (mp_ptr dst, mp_srcptr src, mp_size_t size,
 
30
C                      mp_limb_t multiplier);
 
31
C mp_limb_t mpn_mul_1c (mp_ptr dst, mp_srcptr src, mp_size_t size,
 
32
C                       mp_limb_t multiplier, mp_limb_t carry);
 
33
C
 
34
 
 
35
defframe(PARAM_CARRY,     20)
 
36
defframe(PARAM_MULTIPLIER,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_mul_1c)
 
44
deflit(`FRAME',0)
 
45
 
 
46
        movl    PARAM_CARRY, %ecx
 
47
        pushl   %esi            FRAME_pushl()
 
48
 
 
49
        jmp     L(start_1c)
 
50
 
 
51
EPILOGUE()
 
52
 
 
53
 
 
54
        ALIGN(8)
 
55
PROLOGUE(mpn_mul_1)
 
56
deflit(`FRAME',0)
 
57
 
 
58
        xorl    %ecx, %ecx
 
59
        pushl   %esi            FRAME_pushl()
 
60
 
 
61
L(start_1c):
 
62
        movl    PARAM_SRC, %esi
 
63
        movl    PARAM_SIZE, %eax
 
64
 
 
65
        shrl    %eax
 
66
        jnz     L(two_or_more)
 
67
 
 
68
 
 
69
        C one limb only
 
70
 
 
71
        movl    (%esi), %eax
 
72
 
 
73
        mull    PARAM_MULTIPLIER
 
74
 
 
75
        addl    %eax, %ecx
 
76
        movl    PARAM_DST, %eax
 
77
 
 
78
        adcl    $0, %edx
 
79
        popl    %esi
 
80
 
 
81
        movl    %ecx, (%eax)
 
82
        movl    %edx, %eax
 
83
 
 
84
        ret
 
85
 
 
86
 
 
87
L(two_or_more):
 
88
        C eax   size/2
 
89
        C ebx
 
90
        C ecx   carry
 
91
        C edx
 
92
        C esi   src
 
93
        C edi
 
94
        C ebp
 
95
 
 
96
        pushl   %edi            FRAME_pushl()
 
97
        pushl   %ebx            FRAME_pushl()
 
98
 
 
99
        movl    PARAM_DST, %edi
 
100
        leal    -1(%eax), %ebx          C size/2-1
 
101
 
 
102
        notl    %ebx                    C -size, preserve carry
 
103
 
 
104
        leal    (%esi,%eax,8), %esi     C src end
 
105
        leal    (%edi,%eax,8), %edi     C dst end
 
106
 
 
107
        pushl   %ebp            FRAME_pushl()
 
108
        jnc     L(top)
 
109
 
 
110
 
 
111
        C size was odd, process one limb separately
 
112
 
 
113
        movl    (%esi,%ebx,8), %eax
 
114
        addl    $4, %esi
 
115
 
 
116
        mull    PARAM_MULTIPLIER
 
117
 
 
118
        addl    %ecx, %eax
 
119
        movl    %edx, %ecx
 
120
 
 
121
        movl    %eax, (%edi,%ebx,8)
 
122
        leal    4(%edi), %edi
 
123
 
 
124
 
 
125
L(top):
 
126
        C eax
 
127
        C ebx   counter, negative
 
128
        C ecx   carry
 
129
        C edx
 
130
        C esi   src end
 
131
        C edi   dst end
 
132
        C ebp
 
133
 
 
134
        adcl    $0, %ecx
 
135
        movl    (%esi,%ebx,8), %eax
 
136
 
 
137
        mull    PARAM_MULTIPLIER
 
138
 
 
139
        movl    %edx, %ebp
 
140
        addl    %eax, %ecx
 
141
 
 
142
        adcl    $0, %ebp
 
143
        movl    4(%esi,%ebx,8), %eax
 
144
 
 
145
        mull    PARAM_MULTIPLIER
 
146
 
 
147
        movl    %ecx, (%edi,%ebx,8)
 
148
        addl    %ebp, %eax
 
149
 
 
150
        movl    %eax, 4(%edi,%ebx,8)
 
151
        incl    %ebx
 
152
 
 
153
        movl    %edx, %ecx
 
154
        jnz     L(top)
 
155
 
 
156
 
 
157
        adcl    $0, %ecx
 
158
        popl    %ebp
 
159
 
 
160
        movl    %ecx, %eax
 
161
        popl    %ebx
 
162
 
 
163
        popl    %edi
 
164
        popl    %esi
 
165
 
 
166
        ret
 
167
 
 
168
EPILOGUE()