4 * All of the constant FPU_REGs
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.
58 * $FreeBSD: src/sys/gnu/i386/fpemul/reg_constant.c,v 1.6.8.1 2000/08/03 00:53:55 peter Exp $
59 * $DragonFly: src/sys/i386/gnu/fpemul/Attic/reg_constant.c,v 1.3 2003/08/07 21:17:20 dillon Exp $
64 #include <sys/param.h>
66 #include <machine/pcb.h>
69 #include "fpu_system.h"
73 FPU_REG CONST_1 = {SIGN_POS, TW_Valid, EXP_BIAS,
74 0x00000000, 0x80000000};
75 static FPU_REG CONST_L2T = {SIGN_POS, TW_Valid, EXP_BIAS + 1,
76 0xcd1b8afe, 0xd49a784b};
77 static FPU_REG CONST_L2E = {SIGN_POS, TW_Valid, EXP_BIAS,
78 0x5c17f0bc, 0xb8aa3b29};
79 FPU_REG CONST_PI = {SIGN_POS, TW_Valid, EXP_BIAS + 1,
80 0x2168c235, 0xc90fdaa2};
81 FPU_REG CONST_PI2 = {SIGN_POS, TW_Valid, EXP_BIAS,
82 0x2168c235, 0xc90fdaa2};
83 FPU_REG CONST_PI4 = {SIGN_POS, TW_Valid, EXP_BIAS - 1,
84 0x2168c235, 0xc90fdaa2};
85 static FPU_REG CONST_LG2 = {SIGN_POS, TW_Valid, EXP_BIAS - 2,
86 0xfbcff799, 0x9a209a84};
87 FPU_REG CONST_LN2 = {SIGN_POS, TW_Valid, EXP_BIAS - 1,
88 0xd1cf79ac, 0xb17217f7};
89 /* Only the sign (and tag) is used in internal zeroes */
90 FPU_REG CONST_Z = {SIGN_POS, TW_Zero, 0, 0x0, 0x0};
91 /* Only the sign and significand (and tag) are used in internal NaNs */
92 /* The 80486 never generates one of these
93 FPU_REG CONST_SNAN = { SIGN_POS, TW_NaN, EXP_OVER, 0x00000001, 0x80000000 };
95 /* This is the real indefinite QNaN */
96 FPU_REG CONST_QNaN = {SIGN_NEG, TW_NaN, EXP_OVER, 0x00000000, 0xC0000000};
97 /* Only the sign (and tag) is used in internal infinities */
98 FPU_REG CONST_INF = {SIGN_POS, TW_Infinity, EXP_OVER, 0x00000000, 0x80000000};
103 fld_const(FPU_REG * c)
107 if (STACK_OVERFLOW) {
112 reg_move(c, FPU_st0_ptr);
113 status_word &= ~SW_C1;
126 fld_const(&CONST_L2T);
132 fld_const(&CONST_L2E);
138 fld_const(&CONST_PI);
144 fld_const(&CONST_LG2);
150 fld_const(&CONST_LN2);
159 static FUNC constants_table[] = {
160 fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, Un_impl
166 (constants_table[FPU_rm]) ();