1 dnl x86 mpn_mul_basecase -- Multiply two limb vectors and store the result
2 dnl in a third limb vector.
5 dnl Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation,
8 dnl This file is part of the GNU MP Library.
10 dnl The GNU MP Library is free software; you can redistribute it and/or
11 dnl modify it under the terms of the GNU Lesser General Public License as
12 dnl published by the Free Software Foundation; either version 2.1 of the
13 dnl License, or (at your option) any later version.
15 dnl The GNU MP Library is distributed in the hope that it will be useful,
16 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
17 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 dnl Lesser General Public License for more details.
20 dnl You should have received a copy of the GNU Lesser General Public
21 dnl License along with the GNU MP Library; see the file COPYING.LIB. If
22 dnl not, write to the Free Software Foundation, Inc., 59 Temple Place -
23 dnl Suite 330, Boston, MA 02111-1307, USA.
26 include(`../config.m4')
29 C void mpn_mul_basecase (mp_ptr wp,
30 C mp_srcptr xp, mp_size_t xsize,
31 C mp_srcptr yp, mp_size_t ysize);
33 C This was written in a haste since the Pentium optimized code that was used
34 C for all x86 machines was slow for the Pentium II. This code would benefit
37 C To shave off some percentage of the run-time, one should make 4 variants
38 C of the Louter loop, for the four different outcomes of un mod 4. That
39 C would avoid Loop0 altogether. Code expansion would be > 4-fold for that
40 C part of the function, but since it is not very large, that would be
43 C The mul loop (at L(oopM)) might need some tweaking. It's current speed is
46 defframe(PARAM_YSIZE,20)
47 defframe(PARAM_YP, 16)
48 defframe(PARAM_XSIZE,12)
52 defframe(VAR_MULTIPLIER, -4)
53 defframe(VAR_COUNTER, -8)
54 deflit(VAR_STACK_SPACE, 8)
59 PROLOGUE(mpn_mul_basecase)
62 subl $VAR_STACK_SPACE,%esp
66 deflit(`FRAME',eval(VAR_STACK_SPACE+12))
72 movl (%esi),%eax C load xp[0]
73 mull (%ebp) C multiply by yp[0]
74 movl %eax,(%edi) C store to wp[0]
75 movl PARAM_XSIZE,%ecx C xsize
76 decl %ecx C If xsize = 1, ysize = 1 too
87 movl (%esi),%eax C load next limb at xp[j]
98 movl %ebx,(%edi) C most significant limb of product
99 addl $4,%edi C increment wp
100 movl PARAM_XSIZE,%eax
105 movl PARAM_YSIZE,%eax C ysize
108 movl %eax,VAR_COUNTER C set index i to ysize
111 movl PARAM_YP,%ebp C yp
112 addl $4,%ebp C make ebp point to next v limb
114 movl (%ebp),%eax C copy y limb ...
115 movl %eax,VAR_MULTIPLIER C ... to stack slot
116 movl PARAM_XSIZE,%ecx
130 adcl %edx,%ebx C propagate carry into cylimb
137 movl PARAM_XSIZE,%ecx
152 adcl %eax,%ebp C new lo + cylimb
159 adcl %eax,%ebx C new lo + cylimb
166 adcl %eax,%ebp C new lo + cylimb
171 adcl $0,%ebx C propagate carry into cylimb
182 C we incremented wp and xp in the loop above; compensate
183 movl PARAM_XSIZE,%eax
188 movl VAR_COUNTER,%eax
190 movl %eax,VAR_COUNTER
202 movl %edx,4(%edi) C store to wp[1]