This source file includes following definitions.
- fld_const
- fld1
- fldl2t
- fldl2e
- fldpi
- fldlg2
- fldln2
- fldz
- fconst
1
2
3
4
5
6
7
8
9
10
11
12
13 #include "fpu_system.h"
14 #include "fpu_emu.h"
15 #include "status_w.h"
16 #include "reg_constant.h"
17 #include "control_w.h"
18
19
20 FPU_REG const CONST_1 = { SIGN_POS, TW_Valid, EXP_BIAS,
21 0x00000000, 0x80000000 };
22 FPU_REG const CONST_2 = { SIGN_POS, TW_Valid, EXP_BIAS+1,
23 0x00000000, 0x80000000 };
24 FPU_REG const CONST_HALF = { SIGN_POS, TW_Valid, EXP_BIAS-1,
25 0x00000000, 0x80000000 };
26 FPU_REG const CONST_L2T = { SIGN_POS, TW_Valid, EXP_BIAS+1,
27 0xcd1b8afe, 0xd49a784b };
28 FPU_REG const CONST_L2E = { SIGN_POS, TW_Valid, EXP_BIAS,
29 0x5c17f0bc, 0xb8aa3b29 };
30 FPU_REG const CONST_PI = { SIGN_POS, TW_Valid, EXP_BIAS+1,
31 0x2168c235, 0xc90fdaa2 };
32 FPU_REG const CONST_PI2 = { SIGN_POS, TW_Valid, EXP_BIAS,
33 0x2168c235, 0xc90fdaa2 };
34 FPU_REG const CONST_PI4 = { SIGN_POS, TW_Valid, EXP_BIAS-1,
35 0x2168c235, 0xc90fdaa2 };
36 FPU_REG const CONST_LG2 = { SIGN_POS, TW_Valid, EXP_BIAS-2,
37 0xfbcff799, 0x9a209a84 };
38 FPU_REG const CONST_LN2 = { SIGN_POS, TW_Valid, EXP_BIAS-1,
39 0xd1cf79ac, 0xb17217f7 };
40
41
42 FPU_REG const CONST_PI2extra = { SIGN_NEG, TW_Valid, EXP_BIAS-66,
43 0xfc8f8cbb, 0xece675d1 };
44
45
46 FPU_REG const CONST_Z = { SIGN_POS, TW_Zero, EXP_UNDER, 0x0, 0x0 };
47
48
49
50
51
52
53 FPU_REG const CONST_QNaN = { SIGN_NEG, TW_NaN, EXP_OVER, 0x00000000, 0xC0000000 };
54
55
56 FPU_REG const CONST_INF = { SIGN_POS, TW_Infinity, EXP_OVER, 0x00000000, 0x80000000 };
57
58
59
60 static void fld_const(FPU_REG const *c, int adj)
61 {
62 FPU_REG *st_new_ptr;
63
64 if ( STACK_OVERFLOW )
65 {
66 stack_overflow();
67 return;
68 }
69 push();
70 reg_move(c, st_new_ptr);
71 st_new_ptr->sigl += adj;
72
73 clear_C1();
74 }
75
76
77
78
79 #define DOWN_OR_CHOP(x) (x & RC_DOWN)
80
81 static void fld1(int rc)
82 {
83 fld_const(&CONST_1, 0);
84 }
85
86 static void fldl2t(int rc)
87 {
88 fld_const(&CONST_L2T, (rc == RC_UP) ? 1 : 0);
89 }
90
91 static void fldl2e(int rc)
92 {
93 fld_const(&CONST_L2E, DOWN_OR_CHOP(rc) ? -1 : 0);
94 }
95
96 static void fldpi(int rc)
97 {
98 fld_const(&CONST_PI, DOWN_OR_CHOP(rc) ? -1 : 0);
99 }
100
101 static void fldlg2(int rc)
102 {
103 fld_const(&CONST_LG2, DOWN_OR_CHOP(rc) ? -1 : 0);
104 }
105
106 static void fldln2(int rc)
107 {
108 fld_const(&CONST_LN2, DOWN_OR_CHOP(rc) ? -1 : 0);
109 }
110
111 static void fldz(int rc)
112 {
113 fld_const(&CONST_Z, 0);
114 }
115
116 typedef void (*FUNC_RC)(int);
117
118 static FUNC_RC constants_table[] = {
119 fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, (FUNC_RC)FPU_illegal
120 };
121
122 void fconst(void)
123 {
124 (constants_table[FPU_rm])(control_word & CW_RC);
125 }