root / target-arm / nwfpe / fpopcode.c @ 40d0591e
History | View | Annotate | Download (4.1 kB)
1 | 00406dff | bellard | /*
|
---|---|---|---|
2 | 00406dff | bellard | NetWinder Floating Point Emulator
|
3 | 00406dff | bellard | (c) Rebel.COM, 1998,1999
|
4 | 00406dff | bellard | |
5 | 00406dff | bellard | Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
|
6 | 00406dff | bellard | |
7 | 00406dff | bellard | This program is free software; you can redistribute it and/or modify
|
8 | 00406dff | bellard | it under the terms of the GNU General Public License as published by
|
9 | 00406dff | bellard | the Free Software Foundation; either version 2 of the License, or
|
10 | 00406dff | bellard | (at your option) any later version.
|
11 | 00406dff | bellard | |
12 | 00406dff | bellard | This program is distributed in the hope that it will be useful,
|
13 | 00406dff | bellard | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 | 00406dff | bellard | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 | 00406dff | bellard | GNU General Public License for more details.
|
16 | 00406dff | bellard | |
17 | 00406dff | bellard | You should have received a copy of the GNU General Public License
|
18 | 00406dff | bellard | along with this program; if not, write to the Free Software
|
19 | 00406dff | bellard | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
20 | 00406dff | bellard | */
|
21 | 00406dff | bellard | |
22 | 00406dff | bellard | #include "fpa11.h" |
23 | 00406dff | bellard | #include "softfloat.h" |
24 | 00406dff | bellard | #include "fpopcode.h" |
25 | 00406dff | bellard | #include "fpsr.h" |
26 | 00406dff | bellard | //#include "fpmodule.h"
|
27 | 00406dff | bellard | //#include "fpmodule.inl"
|
28 | 00406dff | bellard | |
29 | 00406dff | bellard | const floatx80 floatx80Constant[] = {
|
30 | 20495218 | bellard | { 0x0000000000000000ULL, 0x0000}, /* extended 0.0 */ |
31 | 20495218 | bellard | { 0x8000000000000000ULL, 0x3fff}, /* extended 1.0 */ |
32 | 20495218 | bellard | { 0x8000000000000000ULL, 0x4000}, /* extended 2.0 */ |
33 | 20495218 | bellard | { 0xc000000000000000ULL, 0x4000}, /* extended 3.0 */ |
34 | 20495218 | bellard | { 0x8000000000000000ULL, 0x4001}, /* extended 4.0 */ |
35 | 20495218 | bellard | { 0xa000000000000000ULL, 0x4001}, /* extended 5.0 */ |
36 | 20495218 | bellard | { 0x8000000000000000ULL, 0x3ffe}, /* extended 0.5 */ |
37 | 20495218 | bellard | { 0xa000000000000000ULL, 0x4002} /* extended 10.0 */ |
38 | 3b46e624 | ths | }; |
39 | 00406dff | bellard | |
40 | 00406dff | bellard | const float64 float64Constant[] = {
|
41 | 00406dff | bellard | 0x0000000000000000ULL, /* double 0.0 */ |
42 | 00406dff | bellard | 0x3ff0000000000000ULL, /* double 1.0 */ |
43 | 00406dff | bellard | 0x4000000000000000ULL, /* double 2.0 */ |
44 | 00406dff | bellard | 0x4008000000000000ULL, /* double 3.0 */ |
45 | 00406dff | bellard | 0x4010000000000000ULL, /* double 4.0 */ |
46 | 00406dff | bellard | 0x4014000000000000ULL, /* double 5.0 */ |
47 | 00406dff | bellard | 0x3fe0000000000000ULL, /* double 0.5 */ |
48 | 00406dff | bellard | 0x4024000000000000ULL /* double 10.0 */ |
49 | 3b46e624 | ths | }; |
50 | 00406dff | bellard | |
51 | 00406dff | bellard | const float32 float32Constant[] = {
|
52 | 00406dff | bellard | 0x00000000, /* single 0.0 */ |
53 | 00406dff | bellard | 0x3f800000, /* single 1.0 */ |
54 | 00406dff | bellard | 0x40000000, /* single 2.0 */ |
55 | 00406dff | bellard | 0x40400000, /* single 3.0 */ |
56 | 00406dff | bellard | 0x40800000, /* single 4.0 */ |
57 | 00406dff | bellard | 0x40a00000, /* single 5.0 */ |
58 | 00406dff | bellard | 0x3f000000, /* single 0.5 */ |
59 | 00406dff | bellard | 0x41200000 /* single 10.0 */ |
60 | 3b46e624 | ths | }; |
61 | 00406dff | bellard | |
62 | 00406dff | bellard | unsigned int getTransferLength(const unsigned int opcode) |
63 | 00406dff | bellard | { |
64 | 00406dff | bellard | unsigned int nRc; |
65 | 3b46e624 | ths | |
66 | 00406dff | bellard | switch (opcode & MASK_TRANSFER_LENGTH)
|
67 | 00406dff | bellard | { |
68 | 00406dff | bellard | case 0x00000000: nRc = 1; break; /* single precision */ |
69 | 00406dff | bellard | case 0x00008000: nRc = 2; break; /* double precision */ |
70 | 00406dff | bellard | case 0x00400000: nRc = 3; break; /* extended precision */ |
71 | 00406dff | bellard | default: nRc = 0; |
72 | 00406dff | bellard | } |
73 | 3b46e624 | ths | |
74 | 00406dff | bellard | return(nRc);
|
75 | 00406dff | bellard | } |
76 | 00406dff | bellard | |
77 | 00406dff | bellard | unsigned int getRegisterCount(const unsigned int opcode) |
78 | 00406dff | bellard | { |
79 | 00406dff | bellard | unsigned int nRc; |
80 | 3b46e624 | ths | |
81 | 00406dff | bellard | switch (opcode & MASK_REGISTER_COUNT)
|
82 | 00406dff | bellard | { |
83 | 00406dff | bellard | case 0x00000000: nRc = 4; break; |
84 | 00406dff | bellard | case 0x00008000: nRc = 1; break; |
85 | 00406dff | bellard | case 0x00400000: nRc = 2; break; |
86 | 00406dff | bellard | case 0x00408000: nRc = 3; break; |
87 | 00406dff | bellard | default: nRc = 0; |
88 | 00406dff | bellard | } |
89 | 3b46e624 | ths | |
90 | 00406dff | bellard | return(nRc);
|
91 | 00406dff | bellard | } |
92 | 00406dff | bellard | |
93 | 00406dff | bellard | unsigned int getRoundingPrecision(const unsigned int opcode) |
94 | 00406dff | bellard | { |
95 | 00406dff | bellard | unsigned int nRc; |
96 | 3b46e624 | ths | |
97 | 00406dff | bellard | switch (opcode & MASK_ROUNDING_PRECISION)
|
98 | 00406dff | bellard | { |
99 | 00406dff | bellard | case 0x00000000: nRc = 1; break; |
100 | 00406dff | bellard | case 0x00000080: nRc = 2; break; |
101 | 00406dff | bellard | case 0x00080000: nRc = 3; break; |
102 | 00406dff | bellard | default: nRc = 0; |
103 | 00406dff | bellard | } |
104 | 3b46e624 | ths | |
105 | 00406dff | bellard | return(nRc);
|
106 | 00406dff | bellard | } |
107 | 00406dff | bellard | |
108 | 00406dff | bellard | unsigned int getDestinationSize(const unsigned int opcode) |
109 | 00406dff | bellard | { |
110 | 00406dff | bellard | unsigned int nRc; |
111 | 3b46e624 | ths | |
112 | 00406dff | bellard | switch (opcode & MASK_DESTINATION_SIZE)
|
113 | 00406dff | bellard | { |
114 | 00406dff | bellard | case 0x00000000: nRc = typeSingle; break; |
115 | 00406dff | bellard | case 0x00000080: nRc = typeDouble; break; |
116 | 00406dff | bellard | case 0x00080000: nRc = typeExtended; break; |
117 | 00406dff | bellard | default: nRc = typeNone;
|
118 | 00406dff | bellard | } |
119 | 3b46e624 | ths | |
120 | 00406dff | bellard | return(nRc);
|
121 | 00406dff | bellard | } |
122 | 00406dff | bellard | |
123 | 00406dff | bellard | /* condition code lookup table
|
124 | 00406dff | bellard | index into the table is test code: EQ, NE, ... LT, GT, AL, NV
|
125 | 00406dff | bellard | bit position in short is condition code: NZCV */
|
126 | 00406dff | bellard | static const unsigned short aCC[16] = { |
127 | 00406dff | bellard | 0xF0F0, // EQ == Z set |
128 | 00406dff | bellard | 0x0F0F, // NE |
129 | 00406dff | bellard | 0xCCCC, // CS == C set |
130 | 00406dff | bellard | 0x3333, // CC |
131 | 00406dff | bellard | 0xFF00, // MI == N set |
132 | 00406dff | bellard | 0x00FF, // PL |
133 | 00406dff | bellard | 0xAAAA, // VS == V set |
134 | 00406dff | bellard | 0x5555, // VC |
135 | 00406dff | bellard | 0x0C0C, // HI == C set && Z clear |
136 | 00406dff | bellard | 0xF3F3, // LS == C clear || Z set |
137 | 00406dff | bellard | 0xAA55, // GE == (N==V) |
138 | 00406dff | bellard | 0x55AA, // LT == (N!=V) |
139 | 00406dff | bellard | 0x0A05, // GT == (!Z && (N==V)) |
140 | 00406dff | bellard | 0xF5FA, // LE == (Z || (N!=V)) |
141 | 00406dff | bellard | 0xFFFF, // AL always |
142 | 00406dff | bellard | 0 // NV |
143 | 00406dff | bellard | }; |
144 | 00406dff | bellard | |
145 | 00406dff | bellard | unsigned int checkCondition(const unsigned int opcode, const unsigned int ccodes) |
146 | 00406dff | bellard | { |
147 | 00406dff | bellard | return (aCC[opcode>>28] >> (ccodes>>28)) & 1; |
148 | 00406dff | bellard | } |