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.
59 * $FreeBSD: src/sys/gnu/i386/fpemul/reg_mul.c,v 1.8 1999/08/28 00:42:56 peter Exp $
60 * $DragonFly: src/sys/platform/pc32/gnu/fpemul/Attic/reg_mul.c,v 1.2 2003/06/17 04:28:34 dillon Exp $
64 /*---------------------------------------------------------------------------+
65 | The destination may be any FPU_REG, including one of the source FPU_REGs. |
66 +---------------------------------------------------------------------------*/
68 #include <gnu/i386/fpemul/reg_constant.h>
71 /* This routine must be called with non-empty source registers */
73 reg_mul(FPU_REG * a, FPU_REG * b, FPU_REG * dest, unsigned int control_w)
75 char sign = (a->sign ^ b->sign);
77 if (!(a->tag | b->tag)) {
78 /* This should be the most common case */
79 reg_u_mul(a, b, dest, control_w);
83 if ((a->tag <= TW_Zero) && (b->tag <= TW_Zero)) {
85 if (((b->tag == TW_Valid) && (b->exp <= EXP_UNDER)) ||
86 ((a->tag == TW_Valid) && (a->exp <= EXP_UNDER))) {
87 if (denormal_operand())
90 #endif /* DENORM_OPERAND */
91 /* Must have either both arguments == zero, or one
92 * valid and the other zero. The result is therefore
94 reg_move(&CONST_Z, dest);
96 /* The 80486 book says that the answer is +0, but a
97 * real 80486 appears to behave this way... */
99 #endif /* PECULIAR_486 */
102 #if 0 /* TW_Denormal is not used yet... perhaps
105 if ((a->tag <= TW_Denormal) && (b->tag <= TW_Denormal)) {
106 /* One or both arguments are de-normalized */
107 /* Internal de-normalized numbers are not
109 EXCEPTION(EX_INTERNAL | 0x105);
110 reg_move(&CONST_Z, dest);
114 /* Must have infinities, NaNs, etc */
115 if ((a->tag == TW_NaN) || (b->tag == TW_NaN)) {
116 real_2op_NaN(a, b, dest);
119 if (a->tag == TW_Infinity) {
120 if (b->tag == TW_Zero) {
124 /* Zero*Infinity is invalid */
126 #ifdef DENORM_OPERAND
127 if ((b->tag == TW_Valid) && (b->exp <= EXP_UNDER) &&
130 #endif /* DENORM_OPERAND */
136 if (b->tag == TW_Infinity) {
137 if (a->tag == TW_Zero) {
144 #ifdef DENORM_OPERAND
145 if ((a->tag == TW_Valid) && (a->exp <= EXP_UNDER) &&
148 #endif /* DENORM_OPERAND */
156 EXCEPTION(EX_INTERNAL | 0x102);
158 #endif /* PARANOID */