Commit | Line | Data |
---|---|---|
f24c459c JH |
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 W. Metzenthen, 22 Parker St, Ormond, | |
11 | * Vic 3163, Australia. | |
12 | * E-mail apm233m@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 operating system. Any other use is not permitted | |
18 | * 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 | ||
53 | ||
54 | #include "fpu_asm.h" | |
55 | ||
56 | .text | |
57 | .align 2,144 | |
58 | .globl _mul64 | |
59 | _mul64: | |
60 | pushl %ebp | |
61 | movl %esp,%ebp | |
62 | subl $16,%esp | |
63 | pushl %esi | |
64 | pushl %ebx | |
65 | ||
66 | movl PARAM1,%esi | |
67 | movl PARAM2,%ecx | |
68 | movl PARAM3,%ebx | |
69 | ||
70 | xor %eax,%eax | |
71 | movl %eax,-4(%ebp) | |
72 | movl %eax,-8(%ebp) | |
73 | ||
74 | movl (%esi),%eax | |
75 | mull (%ecx) | |
76 | movl %eax,-16(%ebp) /* Not used */ | |
77 | movl %edx,-12(%ebp) | |
78 | ||
79 | movl (%esi),%eax | |
80 | mull 4(%ecx) | |
81 | addl %eax,-12(%ebp) | |
82 | adcl %edx,-8(%ebp) | |
83 | adcl $0,-4(%ebp) | |
84 | ||
85 | movl 4(%esi),%eax | |
86 | mull (%ecx) | |
87 | addl %eax,-12(%ebp) | |
88 | adcl %edx,-8(%ebp) | |
89 | adcl $0,-4(%ebp) | |
90 | ||
91 | movl 4(%esi),%eax | |
92 | mull 4(%ecx) | |
93 | addl %eax,-8(%ebp) | |
94 | adcl %edx,-4(%ebp) | |
95 | ||
96 | testb $128,-9(%ebp) | |
97 | je L_no_round | |
98 | ||
99 | addl $1,-8(%ebp) | |
100 | adcl $0,-4(%ebp) | |
101 | ||
102 | L_no_round: | |
103 | movl -8(%ebp),%esi | |
104 | movl %esi,(%ebx) | |
105 | movl -4(%ebp),%esi | |
106 | movl %esi,4(%ebx) | |
107 | ||
108 | popl %ebx | |
109 | popl %esi | |
110 | leave | |
111 | ret |