4 * Multiply one FPU_REG by another, put the result in a destination FPU_REG.
7 * Copyright (C) 1992,1993,1994
8 * W. Metzenthen, 22 Parker St, Ormond, Vic 3163,
9 * Australia. E-mail billm@vaxc.cc.monash.edu.au
10 * All rights reserved.
12 * This copyright notice covers the redistribution and use of the
13 * FPU emulator developed by W. Metzenthen. It covers only its use
14 * in the 386BSD, FreeBSD and NetBSD operating systems. Any other
15 * use is not permitted under this copyright.
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must include information specifying
23 * that source code for the emulator is freely available and include
25 * a) an offer to provide the source code for a nominal distribution
27 * b) list at least two alternative methods whereby the source
28 * can be obtained, e.g. a publically accessible bulletin board
29 * and an anonymous ftp site from which the software can be
31 * 3. All advertising materials specifically mentioning features or use of
32 * this emulator must acknowledge that it was developed by W. Metzenthen.
33 * 4. The name of W. Metzenthen may not be used to endorse or promote
34 * products derived from this software without specific prior written
37 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
38 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
39 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
40 * W. METZENTHEN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
41 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
42 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
43 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
44 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
45 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
46 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 * The purpose of this copyright, based upon the Berkeley copyright, is to
50 * ensure that the covered software remains freely available to everyone.
52 * The software (with necessary differences) is also available, but under
53 * the terms of the GNU copyleft, for the Linux operating system and for
54 * the djgpp ms-dos extender.
56 * W. Metzenthen June 1994.
63 /*---------------------------------------------------------------------------+
64 | The destination may be any FPU_REG, including one of the source FPU_REGs. |
65 +---------------------------------------------------------------------------*/
67 #include <gnu/i386/fpemul/reg_constant.h>
70 /* This routine must be called with non-empty source registers */
72 reg_mul(FPU_REG * a, FPU_REG * b, FPU_REG * dest, unsigned int control_w)
74 char sign = (a->sign ^ b->sign);
76 if (!(a->tag | b->tag)) {
77 /* This should be the most common case */
78 reg_u_mul(a, b, dest, control_w);
82 if ((a->tag <= TW_Zero) && (b->tag <= TW_Zero)) {
84 if (((b->tag == TW_Valid) && (b->exp <= EXP_UNDER)) ||
85 ((a->tag == TW_Valid) && (a->exp <= EXP_UNDER))) {
86 if (denormal_operand())
89 #endif /* DENORM_OPERAND */
90 /* Must have either both arguments == zero, or one
91 * valid and the other zero. The result is therefore
93 reg_move(&CONST_Z, dest);
95 /* The 80486 book says that the answer is +0, but a
96 * real 80486 appears to behave this way... */
98 #endif /* PECULIAR_486 */
101 #if 0 /* TW_Denormal is not used yet... perhaps
104 if ((a->tag <= TW_Denormal) && (b->tag <= TW_Denormal)) {
105 /* One or both arguments are de-normalized */
106 /* Internal de-normalized numbers are not
108 EXCEPTION(EX_INTERNAL | 0x105);
109 reg_move(&CONST_Z, dest);
113 /* Must have infinities, NaNs, etc */
114 if ((a->tag == TW_NaN) || (b->tag == TW_NaN)) {
115 real_2op_NaN(a, b, dest);
118 if (a->tag == TW_Infinity) {
119 if (b->tag == TW_Zero) {
123 /* Zero*Infinity is invalid */
125 #ifdef DENORM_OPERAND
126 if ((b->tag == TW_Valid) && (b->exp <= EXP_UNDER) &&
129 #endif /* DENORM_OPERAND */
135 if (b->tag == TW_Infinity) {
136 if (a->tag == TW_Zero) {
143 #ifdef DENORM_OPERAND
144 if ((a->tag == TW_Valid) && (a->exp <= EXP_UNDER) &&
147 #endif /* DENORM_OPERAND */
155 EXCEPTION(EX_INTERNAL | 0x102);
157 #endif /* PARANOID */