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 $
63 #include <sys/param.h>
65 #include <machine/pcb.h>
67 #include <gnu/i386/fpemul/fpu_emu.h>
68 #include <gnu/i386/fpemul/fpu_system.h>
69 #include <gnu/i386/fpemul/status_w.h>
72 FPU_REG CONST_1 = {SIGN_POS, TW_Valid, EXP_BIAS,
73 0x00000000, 0x80000000};
74 static FPU_REG CONST_L2T = {SIGN_POS, TW_Valid, EXP_BIAS + 1,
75 0xcd1b8afe, 0xd49a784b};
76 static FPU_REG CONST_L2E = {SIGN_POS, TW_Valid, EXP_BIAS,
77 0x5c17f0bc, 0xb8aa3b29};
78 FPU_REG CONST_PI = {SIGN_POS, TW_Valid, EXP_BIAS + 1,
79 0x2168c235, 0xc90fdaa2};
80 FPU_REG CONST_PI2 = {SIGN_POS, TW_Valid, EXP_BIAS,
81 0x2168c235, 0xc90fdaa2};
82 FPU_REG CONST_PI4 = {SIGN_POS, TW_Valid, EXP_BIAS - 1,
83 0x2168c235, 0xc90fdaa2};
84 static FPU_REG CONST_LG2 = {SIGN_POS, TW_Valid, EXP_BIAS - 2,
85 0xfbcff799, 0x9a209a84};
86 FPU_REG CONST_LN2 = {SIGN_POS, TW_Valid, EXP_BIAS - 1,
87 0xd1cf79ac, 0xb17217f7};
88 /* Only the sign (and tag) is used in internal zeroes */
89 FPU_REG CONST_Z = {SIGN_POS, TW_Zero, 0, 0x0, 0x0};
90 /* Only the sign and significand (and tag) are used in internal NaNs */
91 /* The 80486 never generates one of these
92 FPU_REG CONST_SNAN = { SIGN_POS, TW_NaN, EXP_OVER, 0x00000001, 0x80000000 };
94 /* This is the real indefinite QNaN */
95 FPU_REG CONST_QNaN = {SIGN_NEG, TW_NaN, EXP_OVER, 0x00000000, 0xC0000000};
96 /* Only the sign (and tag) is used in internal infinities */
97 FPU_REG CONST_INF = {SIGN_POS, TW_Infinity, EXP_OVER, 0x00000000, 0x80000000};
102 fld_const(FPU_REG * c)
106 if (STACK_OVERFLOW) {
111 reg_move(c, FPU_st0_ptr);
112 status_word &= ~SW_C1;
125 fld_const(&CONST_L2T);
131 fld_const(&CONST_L2E);
137 fld_const(&CONST_PI);
143 fld_const(&CONST_LG2);
149 fld_const(&CONST_LN2);
158 static FUNC constants_table[] = {
159 fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, Un_impl
165 (constants_table[FPU_rm]) ();