Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / platform / pc32 / gnu / fpemul / poly_mul64.s
1 /*
2  *  poly_mul64.S
3  *
4  * Multiply two 64 bit integers.
5  *
6  * Call from C as:
7  *   void mul64(long long *a, long long *b, long long *result)
8  *
9  *
10  * Copyright (C) 1992,1993,1994
11  *                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,
12  *                       Australia.  E-mail   billm@vaxc.cc.monash.edu.au
13  * All rights reserved.
14  *
15  * This copyright notice covers the redistribution and use of the
16  * FPU emulator developed by W. Metzenthen. It covers only its use
17  * in the 386BSD, FreeBSD and NetBSD operating systems. Any other
18  * use is not permitted under this copyright.
19  *
20  * Redistribution and use in source and binary forms, with or without
21  * modification, are permitted provided that the following conditions
22  * are met:
23  * 1. Redistributions of source code must retain the above copyright
24  *    notice, this list of conditions and the following disclaimer.
25  * 2. Redistributions in binary form must include information specifying
26  *    that source code for the emulator is freely available and include
27  *    either:
28  *      a) an offer to provide the source code for a nominal distribution
29  *         fee, or
30  *      b) list at least two alternative methods whereby the source
31  *         can be obtained, e.g. a publically accessible bulletin board
32  *         and an anonymous ftp site from which the software can be
33  *         downloaded.
34  * 3. All advertising materials specifically mentioning features or use of
35  *    this emulator must acknowledge that it was developed by W. Metzenthen.
36  * 4. The name of W. Metzenthen may not be used to endorse or promote
37  *    products derived from this software without specific prior written
38  *    permission.
39  *
40  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
41  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
42  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
43  * W. METZENTHEN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
45  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
47  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
48  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
49  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50  *
51  *
52  * The purpose of this copyright, based upon the Berkeley copyright, is to
53  * ensure that the covered software remains freely available to everyone.
54  *
55  * The software (with necessary differences) is also available, but under
56  * the terms of the GNU copyleft, for the Linux operating system and for
57  * the djgpp ms-dos extender.
58  *
59  * W. Metzenthen   June 1994.
60  *
61  *
62  * $FreeBSD: src/sys/gnu/i386/fpemul/poly_mul64.s,v 1.8 1999/08/28 00:42:54 peter Exp $
63  *
64  */
65
66
67 #include <gnu/i386/fpemul/fpu_asm.h>
68
69 .text
70 ENTRY(mul64)
71         pushl %ebp
72         movl %esp,%ebp
73         subl $16,%esp
74         pushl %esi
75         pushl %ebx
76
77         movl PARAM1,%esi
78         movl PARAM2,%ecx
79         movl PARAM3,%ebx
80
81         xor %eax,%eax
82         movl %eax,-4(%ebp)
83         movl %eax,-8(%ebp)
84
85         movl (%esi),%eax
86         mull (%ecx)
87         movl %eax,-16(%ebp)     /* Not used */
88         movl %edx,-12(%ebp)
89
90         movl (%esi),%eax
91         mull 4(%ecx)
92         addl %eax,-12(%ebp)
93         adcl %edx,-8(%ebp)
94         adcl $0,-4(%ebp)
95
96         movl 4(%esi),%eax
97         mull (%ecx)
98         addl %eax,-12(%ebp)
99         adcl %edx,-8(%ebp)
100         adcl $0,-4(%ebp)
101
102         movl 4(%esi),%eax
103         mull 4(%ecx)
104         addl %eax,-8(%ebp)
105         adcl %edx,-4(%ebp)
106
107         testb $128,-9(%ebp)
108         je L_no_round
109
110         addl $1,-8(%ebp)
111         adcl $0,-4(%ebp)
112
113 L_no_round:
114         movl -8(%ebp),%esi
115         movl %esi,(%ebx)
116         movl -4(%ebp),%esi
117         movl %esi,4(%ebx)
118
119         popl %ebx
120         popl %esi
121         leave
122         ret