1 |
/* IEEE floating point support routines, for GDB, the GNU Debugger. |
/* IEEE floating point support routines, for GDB, the GNU Debugger. |
2 |
Copyright (C) 1991, 1994 Free Software Foundation, Inc. |
Copyright (C) 1991, 1994, 1999, 2000 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GDB. |
This file is part of GDB. |
5 |
|
|
36 |
/* floatformats for IEEE single and double, big and little endian. */ |
/* floatformats for IEEE single and double, big and little endian. */ |
37 |
const struct floatformat floatformat_ieee_single_big = |
const struct floatformat floatformat_ieee_single_big = |
38 |
{ |
{ |
39 |
floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no |
floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23, |
40 |
|
floatformat_intbit_no, |
41 |
|
"floatformat_ieee_single_big" |
42 |
}; |
}; |
43 |
const struct floatformat floatformat_ieee_single_little = |
const struct floatformat floatformat_ieee_single_little = |
44 |
{ |
{ |
45 |
floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no |
floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23, |
46 |
|
floatformat_intbit_no, |
47 |
|
"floatformat_ieee_single_little" |
48 |
}; |
}; |
49 |
const struct floatformat floatformat_ieee_double_big = |
const struct floatformat floatformat_ieee_double_big = |
50 |
{ |
{ |
51 |
floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no |
floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52, |
52 |
|
floatformat_intbit_no, |
53 |
|
"floatformat_ieee_double_big" |
54 |
}; |
}; |
55 |
const struct floatformat floatformat_ieee_double_little = |
const struct floatformat floatformat_ieee_double_little = |
56 |
{ |
{ |
57 |
floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no |
floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52, |
58 |
|
floatformat_intbit_no, |
59 |
|
"floatformat_ieee_double_little" |
60 |
}; |
}; |
61 |
|
|
62 |
/* floatformat for IEEE double, little endian byte order, with big endian word |
/* floatformat for IEEE double, little endian byte order, with big endian word |
64 |
|
|
65 |
const struct floatformat floatformat_ieee_double_littlebyte_bigword = |
const struct floatformat floatformat_ieee_double_littlebyte_bigword = |
66 |
{ |
{ |
67 |
floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no |
floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52, |
68 |
|
floatformat_intbit_no, |
69 |
|
"floatformat_ieee_double_little" |
70 |
}; |
}; |
71 |
|
|
72 |
const struct floatformat floatformat_i387_ext = |
const struct floatformat floatformat_i387_ext = |
73 |
{ |
{ |
74 |
floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64, |
floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64, |
75 |
floatformat_intbit_yes |
floatformat_intbit_yes, |
76 |
|
"floatformat_i387_ext" |
77 |
}; |
}; |
78 |
const struct floatformat floatformat_m68881_ext = |
const struct floatformat floatformat_m68881_ext = |
79 |
{ |
{ |
80 |
/* Note that the bits from 16 to 31 are unused. */ |
/* Note that the bits from 16 to 31 are unused. */ |
81 |
floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64, floatformat_intbit_yes |
floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64, |
82 |
|
floatformat_intbit_yes, |
83 |
|
"floatformat_m68881_ext" |
84 |
}; |
}; |
85 |
const struct floatformat floatformat_i960_ext = |
const struct floatformat floatformat_i960_ext = |
86 |
{ |
{ |
87 |
/* Note that the bits from 0 to 15 are unused. */ |
/* Note that the bits from 0 to 15 are unused. */ |
88 |
floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64, |
floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64, |
89 |
floatformat_intbit_yes |
floatformat_intbit_yes, |
90 |
|
"floatformat_i960_ext" |
91 |
}; |
}; |
92 |
const struct floatformat floatformat_m88110_ext = |
const struct floatformat floatformat_m88110_ext = |
93 |
{ |
{ |
95 |
/* Harris uses raw format 128 bytes long, but the number is just an ieee |
/* Harris uses raw format 128 bytes long, but the number is just an ieee |
96 |
double, and the last 64 bits are wasted. */ |
double, and the last 64 bits are wasted. */ |
97 |
floatformat_big,128, 0, 1, 11, 0x3ff, 0x7ff, 12, 52, |
floatformat_big,128, 0, 1, 11, 0x3ff, 0x7ff, 12, 52, |
98 |
floatformat_intbit_no |
floatformat_intbit_no, |
99 |
|
"floatformat_m88110_ext(harris)" |
100 |
#else |
#else |
101 |
floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64, |
floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64, |
102 |
floatformat_intbit_yes |
floatformat_intbit_yes, |
103 |
|
"floatformat_m88110_ext" |
104 |
#endif /* HARRIS_FLOAT_FORMAT */ |
#endif /* HARRIS_FLOAT_FORMAT */ |
105 |
}; |
}; |
106 |
const struct floatformat floatformat_arm_ext = |
const struct floatformat floatformat_arm_ext = |
107 |
{ |
{ |
108 |
/* Bits 1 to 16 are unused. */ |
/* Bits 1 to 16 are unused. */ |
109 |
floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64, |
floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64, |
110 |
floatformat_intbit_yes |
floatformat_intbit_yes, |
111 |
|
"floatformat_arm_ext" |
112 |
}; |
}; |
113 |
|
|
114 |
static unsigned long get_field PARAMS ((unsigned char *, |
static unsigned long get_field PARAMS ((unsigned char *, |
145 |
--cur_byte; |
--cur_byte; |
146 |
|
|
147 |
/* Move towards the most significant part of the field. */ |
/* Move towards the most significant part of the field. */ |
148 |
while (cur_bitshift < len) |
while ((unsigned int) cur_bitshift < len) |
149 |
{ |
{ |
150 |
if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT) |
if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT) |
151 |
/* This is the last byte; zero out the bits which are not part of |
/* This is the last byte; zero out the bits which are not part of |
196 |
mant_off = fmt->man_start; |
mant_off = fmt->man_start; |
197 |
dto = 0.0; |
dto = 0.0; |
198 |
|
|
199 |
special_exponent = exponent == 0 || exponent == fmt->exp_nan; |
special_exponent = exponent == 0 || (unsigned long) exponent == fmt->exp_nan; |
200 |
|
|
201 |
/* Don't bias zero's, denorms or NaNs. */ |
/* Don't bias zero's, denorms or NaNs. */ |
202 |
if (!special_exponent) |
if (!special_exponent) |
272 |
--cur_byte; |
--cur_byte; |
273 |
|
|
274 |
/* Move towards the most significant part of the field. */ |
/* Move towards the most significant part of the field. */ |
275 |
while (cur_bitshift < len) |
while ((unsigned int) cur_bitshift < len) |
276 |
{ |
{ |
277 |
if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT) |
if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT) |
278 |
{ |
{ |
352 |
If we are discarding a zero, we should be (but are not) creating |
If we are discarding a zero, we should be (but are not) creating |
353 |
a denormalized number which means adjusting the exponent |
a denormalized number which means adjusting the exponent |
354 |
(I think). */ |
(I think). */ |
355 |
if (mant_bits_left == fmt->man_len |
if ((unsigned int) mant_bits_left == fmt->man_len |
356 |
&& fmt->intbit == floatformat_intbit_no) |
&& fmt->intbit == floatformat_intbit_no) |
357 |
{ |
{ |
358 |
mant_long &= 0x7fffffff; |
mant_long &= 0x7fffffff; |