2.9
[glibc/nacl-glibc.git] / sysdeps / i386 / mul_1.S
blob0d0c07e7cf4d670bd54899d3b98a4d88bcf29f7e
1 /* i80386 __mpn_mul_1 -- Multiply a limb vector with a limb and store
2    the result in a second limb vector.
3    Copyright (C) 1992,1994,1997,1998,2000,2005 Free Software Foundation, Inc.
4    This file is part of the GNU MP Library.
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.
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.
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, write to
18    the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19    MA 02111-1307, USA. */
21 #include <sysdep.h>
22 #include "asm-syntax.h"
23 #include "bp-sym.h"
24 #include "bp-asm.h"
26 #define PARMS   LINKAGE+16      /* space for 4 saved regs */
27 #define RES     PARMS
28 #define S1      RES+PTR_SIZE
29 #define SIZE    S1+PTR_SIZE
30 #define S2LIMB  SIZE+4
32 #define res_ptr edi
33 #define s1_ptr esi
34 #define size ecx
35 #define s2_limb ebx
37         .text
38 ENTRY (BP_SYM (__mpn_mul_1))
39         ENTER
41         pushl   %res_ptr
42         cfi_adjust_cfa_offset (4)
43         pushl   %s1_ptr
44         cfi_adjust_cfa_offset (4)
45         pushl   %ebp
46         cfi_adjust_cfa_offset (4)
47         pushl   %s2_limb
48         cfi_adjust_cfa_offset (4)
50         movl    RES(%esp), %res_ptr
51         cfi_rel_offset (res_ptr, 12)
52         movl    S1(%esp), %s1_ptr
53         cfi_rel_offset (s1_ptr, 8)
54         movl    SIZE(%esp), %size
55         movl    S2LIMB(%esp), %s2_limb
56         cfi_rel_offset (s2_limb, 0)
57 #if __BOUNDED_POINTERS__
58         shll    $2, %size       /* convert limbs to bytes */
59         CHECK_BOUNDS_BOTH_WIDE (%res_ptr, RES(%esp), %size)
60         CHECK_BOUNDS_BOTH_WIDE (%s1_ptr, S1(%esp), %size)
61         shrl    $2, %size
62 #endif
63         leal    (%res_ptr,%size,4), %res_ptr
64         leal    (%s1_ptr,%size,4), %s1_ptr
65         negl    %size
66         xorl    %ebp, %ebp
67         cfi_rel_offset (ebp, 4)
68         ALIGN (3)
69 L(oop):
70         movl    (%s1_ptr,%size,4), %eax
71         mull    %s2_limb
72         addl    %ebp, %eax
73         movl    %eax, (%res_ptr,%size,4)
74         adcl    $0, %edx
75         movl    %edx, %ebp
77         incl    %size
78         jnz     L(oop)
79         movl    %ebp, %eax
81         popl    %s2_limb
82         cfi_adjust_cfa_offset (-4)
83         cfi_restore (s2_limb)
84         popl    %ebp
85         cfi_adjust_cfa_offset (-4)
86         cfi_restore (ebp)
87         popl    %s1_ptr
88         cfi_adjust_cfa_offset (-4)
89         cfi_restore (s1_ptr)
90         popl    %res_ptr
91         cfi_adjust_cfa_offset (-4)
92         cfi_restore (res_ptr)
94         LEAVE
95         ret
96 #undef size
97 END (BP_SYM (__mpn_mul_1))