Reorganisation of the source tree
[ghc-hetmet.git] / rts / gmp / mpn / x86 / aorsmul_1.asm
1 dnl  x86 __gmpn_addmul_1 (for 386 and 486) -- Multiply a limb vector with a
2 dnl  limb and add the result to a second limb vector.
3
4
5 dnl  Copyright (C) 1992, 1994, 1997, 1999, 2000 Free Software Foundation,
6 dnl  Inc.
7 dnl 
8 dnl  This file is part of the GNU MP Library.
9 dnl 
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.
14 dnl 
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.
19 dnl 
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.
24
25
26 include(`../config.m4')
27
28
29 ifdef(`OPERATION_addmul_1',`
30       define(M4_inst,        addl)
31       define(M4_function_1,  mpn_addmul_1)
32
33 ',`ifdef(`OPERATION_submul_1',`
34       define(M4_inst,        subl)
35       define(M4_function_1,  mpn_submul_1)
36
37 ',`m4_error(`Need OPERATION_addmul_1 or OPERATION_submul_1
38 ')')')
39
40 MULFUNC_PROLOGUE(mpn_addmul_1 mpn_submul_1)
41
42
43 C mp_limb_t M4_function_1 (mp_ptr dst, mp_srcptr src, mp_size_t size,
44 C                          mp_limb_t mult);
45
46 define(PARAM_MULTIPLIER, `FRAME+16(%esp)')
47 define(PARAM_SIZE,       `FRAME+12(%esp)')
48 define(PARAM_SRC,        `FRAME+8(%esp)')
49 define(PARAM_DST,        `FRAME+4(%esp)')
50
51         TEXT
52         ALIGN(8)
53
54 PROLOGUE(M4_function_1)
55 deflit(`FRAME',0)
56
57         pushl   %edi
58         pushl   %esi
59         pushl   %ebx
60         pushl   %ebp
61 deflit(`FRAME',16)
62
63         movl    PARAM_DST,%edi
64         movl    PARAM_SRC,%esi
65         movl    PARAM_SIZE,%ecx
66
67         xorl    %ebx,%ebx
68         andl    $3,%ecx
69         jz      L(end0)
70
71 L(oop0):
72         movl    (%esi),%eax
73         mull    PARAM_MULTIPLIER
74         leal    4(%esi),%esi
75         addl    %ebx,%eax
76         movl    $0,%ebx
77         adcl    %ebx,%edx
78         M4_inst %eax,(%edi)
79         adcl    %edx,%ebx       C propagate carry into cylimb
80
81         leal    4(%edi),%edi
82         decl    %ecx
83         jnz     L(oop0)
84
85 L(end0):
86         movl    PARAM_SIZE,%ecx
87         shrl    $2,%ecx
88         jz      L(end)
89
90         ALIGN(8)
91 L(oop): movl    (%esi),%eax
92         mull    PARAM_MULTIPLIER
93         addl    %eax,%ebx
94         movl    $0,%ebp
95         adcl    %edx,%ebp
96
97         movl    4(%esi),%eax
98         mull    PARAM_MULTIPLIER
99         M4_inst %ebx,(%edi)
100         adcl    %eax,%ebp       C new lo + cylimb
101         movl    $0,%ebx
102         adcl    %edx,%ebx
103
104         movl    8(%esi),%eax
105         mull    PARAM_MULTIPLIER
106         M4_inst %ebp,4(%edi)
107         adcl    %eax,%ebx       C new lo + cylimb
108         movl    $0,%ebp
109         adcl    %edx,%ebp
110
111         movl    12(%esi),%eax
112         mull    PARAM_MULTIPLIER
113         M4_inst %ebx,8(%edi)
114         adcl    %eax,%ebp       C new lo + cylimb
115         movl    $0,%ebx
116         adcl    %edx,%ebx
117
118         M4_inst %ebp,12(%edi)
119         adcl    $0,%ebx         C propagate carry into cylimb
120
121         leal    16(%esi),%esi
122         leal    16(%edi),%edi
123         decl    %ecx
124         jnz     L(oop)
125
126 L(end): movl    %ebx,%eax
127
128         popl    %ebp
129         popl    %ebx
130         popl    %esi
131         popl    %edi
132         ret
133
134 EPILOGUE()