4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 #pragma ident "%Z%%M% %I% %E% SMI"
25 * Copyright (c) 1988 by Sun Microsystems, Inc.
29 #include "_Qglobals.h"
34 unpacked
*px
, *py
, *pz
;
38 unsigned acc
[4]; /* Product accumulator. */
39 unsigned i
,j
,y
,*x
,s
,r
,c
;
41 if ((int) px
->fpclass
< (int) py
->fpclass
) {
46 /* Now class(x) >= class(y). */
49 pz
->sign
= px
->sign
^ py
->sign
;
51 switch (px
->fpclass
) {
57 if (py
->fpclass
== fp_zero
) {
59 pz
->fpclass
= fp_quiet
;
63 if (py
->fpclass
== fp_zero
) {
64 pz
->fpclass
= fp_zero
;
69 /* Now x and y are both normal or subnormal. */
71 x
= px
->significand
; /* save typing */
73 s
=r
=acc
[0]=acc
[1]=acc
[2]=acc
[3]=0; /* intialize acc to zero */
75 y
= py
->significand
[3]; /* py->significand[3] * x */
79 s
|= r
; /* shift acc right one bit */
81 acc
[3] = ((acc
[2]&1)<<31)|(acc
[3]>>1);
82 acc
[2] = ((acc
[1]&1)<<31)|(acc
[2]>>1);
83 acc
[1] = ((acc
[0]&1)<<31)|(acc
[1]>>1);
85 if(j
&y
) { /* bit i of y != 0, add x to acc */
87 c
= fpu_add3wc(&acc
[3],acc
[3],x
[3],c
);
88 c
= fpu_add3wc(&acc
[2],acc
[2],x
[2],c
);
89 c
= fpu_add3wc(&acc
[1],acc
[1],x
[1],c
);
90 c
= fpu_add3wc(&acc
[0],acc
[0],x
[0],c
);
96 y
= py
->significand
[2]; /* py->significand[2] * x */
100 s
|= r
; /* shift acc right one bit */
102 acc
[3] = ((acc
[2]&1)<<31)|(acc
[3]>>1);
103 acc
[2] = ((acc
[1]&1)<<31)|(acc
[2]>>1);
104 acc
[1] = ((acc
[0]&1)<<31)|(acc
[1]>>1);
105 acc
[0] = (acc
[0]>>1);
106 if(j
&y
) { /* bit i of y != 0, add x to acc */
108 c
= fpu_add3wc(&acc
[3],acc
[3],x
[3],c
);
109 c
= fpu_add3wc(&acc
[2],acc
[2],x
[2],c
);
110 c
= fpu_add3wc(&acc
[1],acc
[1],x
[1],c
);
111 c
= fpu_add3wc(&acc
[0],acc
[0],x
[0],c
);
116 s
|= r
|(acc
[3]&0x7fffffff);
117 r
= (acc
[3]&0x80000000)>>31;
118 acc
[3]=acc
[2];acc
[2]=acc
[1];acc
[1]=acc
[0];acc
[0]=0;
121 y
= py
->significand
[1]; /* py->significand[1] * x */
125 s
|= r
; /* shift acc right one bit */
127 acc
[3] = ((acc
[2]&1)<<31)|(acc
[3]>>1);
128 acc
[2] = ((acc
[1]&1)<<31)|(acc
[2]>>1);
129 acc
[1] = ((acc
[0]&1)<<31)|(acc
[1]>>1);
130 acc
[0] = (acc
[0]>>1);
131 if(j
&y
) { /* bit i of y != 0, add x to acc */
133 c
= fpu_add3wc(&acc
[3],acc
[3],x
[3],c
);
134 c
= fpu_add3wc(&acc
[2],acc
[2],x
[2],c
);
135 c
= fpu_add3wc(&acc
[1],acc
[1],x
[1],c
);
136 c
= fpu_add3wc(&acc
[0],acc
[0],x
[0],c
);
141 s
|= r
|(acc
[3]&0x7fffffff);
142 r
= (acc
[3]&0x80000000)>>31;
143 acc
[3]=acc
[2];acc
[2]=acc
[1];acc
[1]=acc
[0];acc
[0]=0;
146 /* py->significand[0] * x */
147 y
= py
->significand
[0]; /* y is of form 0x0001???? */
150 s
|= r
; /* shift acc right one bit */
152 acc
[3] = ((acc
[2]&1)<<31)|(acc
[3]>>1);
153 acc
[2] = ((acc
[1]&1)<<31)|(acc
[2]>>1);
154 acc
[1] = ((acc
[0]&1)<<31)|(acc
[1]>>1);
155 acc
[0] = (acc
[0]>>1);
156 if(j
&y
) { /* bit i of y != 0, add x to acc */
158 c
= fpu_add3wc(&acc
[3],acc
[3],x
[3],c
);
159 c
= fpu_add3wc(&acc
[2],acc
[2],x
[2],c
);
160 c
= fpu_add3wc(&acc
[1],acc
[1],x
[1],c
);
161 c
= fpu_add3wc(&acc
[0],acc
[0],x
[0],c
);
166 if(acc
[0]>=0x20000) { /* right shift one bit to normalize */
167 pz
->exponent
= px
->exponent
+ py
->exponent
+ 1;
169 pz
->rounded
= acc
[3]&1;
170 pz
->significand
[3]=((acc
[2]&1)<<31)|(acc
[3]>>1);
171 pz
->significand
[2]=((acc
[1]&1)<<31)|(acc
[2]>>1);
172 pz
->significand
[1]=((acc
[0]&1)<<31)|(acc
[1]>>1);
173 pz
->significand
[0]=(acc
[0]>>1);
175 pz
->exponent
= px
->exponent
+ py
->exponent
;
178 pz
->significand
[3]=acc
[3];
179 pz
->significand
[2]=acc
[2];
180 pz
->significand
[1]=acc
[1];
181 pz
->significand
[0]=acc
[0];