6965e8b9ba278ef6d22d7396c0905c63bddbb251
[platform/upstream/glibc.git] / sysdeps / i386 / i586 / mul_1.S
1 /* Pentium __mpn_mul_1 -- Multiply a limb vector with a limb and store
2    the result in a second limb vector.
3    Copyright (C) 1992-2013 Free Software Foundation, Inc.
4    This file is part of the GNU MP Library.
5
6    The GNU MP Library is free software; you can redistribute it and/or modify
7    it under the terms of the GNU Lesser General Public License as published by
8    the Free Software Foundation; either version 2.1 of the License, or (at your
9    option) any later version.
10
11    The GNU MP Library is distributed in the hope that it will be useful, but
12    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14    License for more details.
15
16    You should have received a copy of the GNU Lesser General Public License
17    along with the GNU MP Library; see the file COPYING.LIB.  If not,
18    see <http://www.gnu.org/licenses/>.  */
19
20 #include "sysdep.h"
21 #include "asm-syntax.h"
22 #include "bp-sym.h"
23 #include "bp-asm.h"
24
25 #define PARMS   LINKAGE+16      /* space for 4 saved regs */
26 #define RES     PARMS
27 #define S1      RES+PTR_SIZE
28 #define SIZE    S1+PTR_SIZE
29 #define S2LIMB  SIZE+4
30
31 #define res_ptr edi
32 #define s1_ptr esi
33 #define size ecx
34 #define s2_limb ebx
35
36         .text
37 ENTRY (BP_SYM (__mpn_mul_1))
38
39         pushl   %res_ptr
40         cfi_adjust_cfa_offset (4)
41         pushl   %s1_ptr
42         cfi_adjust_cfa_offset (4)
43         pushl   %ebp
44         cfi_adjust_cfa_offset (4)
45         pushl   %s2_limb
46         cfi_adjust_cfa_offset (4)
47
48         movl    RES(%esp), %res_ptr
49         cfi_rel_offset (res_ptr, 12)
50         movl    S1(%esp), %s1_ptr
51         cfi_rel_offset (s1_ptr, 8)
52         movl    SIZE(%esp), %size
53         movl    S2LIMB(%esp), %s2_limb
54         cfi_rel_offset (s2_limb, 0)
55         leal    (%res_ptr,%size,4), %res_ptr
56         leal    (%s1_ptr,%size,4), %s1_ptr
57         negl    %size
58         xorl    %ebp, %ebp
59         cfi_rel_offset (ebp, 4)
60         ALIGN (3)
61
62 L(oop): adcl    $0, %ebp
63         movl    (%s1_ptr,%size,4), %eax
64
65         mull    %s2_limb
66
67         addl    %eax, %ebp
68
69         movl    %ebp, (%res_ptr,%size,4)
70         incl    %size
71
72         movl    %edx, %ebp
73         jnz     L(oop)
74
75         adcl    $0, %ebp
76         movl    %ebp, %eax
77         popl    %s2_limb
78         cfi_adjust_cfa_offset (-4)
79         cfi_restore (s2_limb)
80         popl    %ebp
81         cfi_adjust_cfa_offset (-4)
82         cfi_restore (ebp)
83         popl    %s1_ptr
84         cfi_adjust_cfa_offset (-4)
85         cfi_restore (s1_ptr)
86         popl    %res_ptr
87         cfi_adjust_cfa_offset (-4)
88         cfi_restore (res_ptr)
89
90         ret
91 #undef size
92 END (BP_SYM (__mpn_mul_1))