| 1 |
106 |
markom |
/* IEEE floating point support declarations, for GDB, the GNU Debugger.
|
| 2 |
|
|
Copyright (C) 1991 Free Software Foundation, Inc.
|
| 3 |
|
|
|
| 4 |
|
|
This file is part of GDB.
|
| 5 |
|
|
|
| 6 |
|
|
This program is free software; you can redistribute it and/or modify
|
| 7 |
|
|
it under the terms of the GNU General Public License as published by
|
| 8 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
| 9 |
|
|
(at your option) any later version.
|
| 10 |
|
|
|
| 11 |
|
|
This program is distributed in the hope that it will be useful,
|
| 12 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
|
|
GNU General Public License for more details.
|
| 15 |
|
|
|
| 16 |
|
|
You should have received a copy of the GNU General Public License
|
| 17 |
|
|
along with this program; if not, write to the Free Software
|
| 18 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
| 19 |
|
|
|
| 20 |
|
|
#if !defined (FLOATFORMAT_H)
|
| 21 |
|
|
#define FLOATFORMAT_H 1
|
| 22 |
|
|
|
| 23 |
|
|
#include "ansidecl.h"
|
| 24 |
|
|
|
| 25 |
|
|
/* A floatformat consists of a sign bit, an exponent and a mantissa. Once the
|
| 26 |
|
|
bytes are concatenated according to the byteorder flag, then each of those
|
| 27 |
|
|
fields is contiguous. We number the bits with 0 being the most significant
|
| 28 |
|
|
(i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field
|
| 29 |
|
|
contains with the *_start and *_len fields. */
|
| 30 |
|
|
|
| 31 |
|
|
/* What is the order of the bytes. */
|
| 32 |
|
|
|
| 33 |
|
|
enum floatformat_byteorders {
|
| 34 |
|
|
|
| 35 |
|
|
/* Standard little endian byte order.
|
| 36 |
|
|
EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */
|
| 37 |
|
|
|
| 38 |
|
|
floatformat_little,
|
| 39 |
|
|
|
| 40 |
|
|
/* Standard big endian byte order.
|
| 41 |
|
|
EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */
|
| 42 |
|
|
|
| 43 |
|
|
floatformat_big,
|
| 44 |
|
|
|
| 45 |
|
|
/* Little endian byte order but big endian word order.
|
| 46 |
|
|
EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */
|
| 47 |
|
|
|
| 48 |
|
|
floatformat_littlebyte_bigword
|
| 49 |
|
|
|
| 50 |
|
|
};
|
| 51 |
|
|
|
| 52 |
|
|
enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no };
|
| 53 |
|
|
|
| 54 |
|
|
struct floatformat
|
| 55 |
|
|
{
|
| 56 |
|
|
enum floatformat_byteorders byteorder;
|
| 57 |
|
|
unsigned int totalsize; /* Total size of number in bits */
|
| 58 |
|
|
|
| 59 |
|
|
/* Sign bit is always one bit long. 1 means negative, 0 means positive. */
|
| 60 |
|
|
unsigned int sign_start;
|
| 61 |
|
|
|
| 62 |
|
|
unsigned int exp_start;
|
| 63 |
|
|
unsigned int exp_len;
|
| 64 |
|
|
/* Amount added to "true" exponent. 0x3fff for many IEEE extendeds. */
|
| 65 |
|
|
unsigned int exp_bias;
|
| 66 |
|
|
/* Exponent value which indicates NaN. This is the actual value stored in
|
| 67 |
|
|
the float, not adjusted by the exp_bias. This usually consists of all
|
| 68 |
|
|
one bits. */
|
| 69 |
|
|
unsigned int exp_nan;
|
| 70 |
|
|
|
| 71 |
|
|
unsigned int man_start;
|
| 72 |
|
|
unsigned int man_len;
|
| 73 |
|
|
|
| 74 |
|
|
/* Is the integer bit explicit or implicit? */
|
| 75 |
|
|
enum floatformat_intbit intbit;
|
| 76 |
|
|
};
|
| 77 |
|
|
|
| 78 |
|
|
/* floatformats for IEEE single and double, big and little endian. */
|
| 79 |
|
|
|
| 80 |
|
|
extern const struct floatformat floatformat_ieee_single_big;
|
| 81 |
|
|
extern const struct floatformat floatformat_ieee_single_little;
|
| 82 |
|
|
extern const struct floatformat floatformat_ieee_double_big;
|
| 83 |
|
|
extern const struct floatformat floatformat_ieee_double_little;
|
| 84 |
|
|
|
| 85 |
|
|
/* floatformat for ARM IEEE double, little endian bytes and big endian words */
|
| 86 |
|
|
|
| 87 |
|
|
extern const struct floatformat floatformat_ieee_double_littlebyte_bigword;
|
| 88 |
|
|
|
| 89 |
|
|
/* floatformats for various extendeds. */
|
| 90 |
|
|
|
| 91 |
|
|
extern const struct floatformat floatformat_i387_ext;
|
| 92 |
|
|
extern const struct floatformat floatformat_m68881_ext;
|
| 93 |
|
|
extern const struct floatformat floatformat_i960_ext;
|
| 94 |
|
|
extern const struct floatformat floatformat_m88110_ext;
|
| 95 |
|
|
extern const struct floatformat floatformat_arm_ext;
|
| 96 |
|
|
|
| 97 |
|
|
/* Convert from FMT to a double.
|
| 98 |
|
|
FROM is the address of the extended float.
|
| 99 |
|
|
Store the double in *TO. */
|
| 100 |
|
|
|
| 101 |
|
|
extern void
|
| 102 |
|
|
floatformat_to_double PARAMS ((const struct floatformat *, char *, double *));
|
| 103 |
|
|
|
| 104 |
|
|
/* The converse: convert the double *FROM to FMT
|
| 105 |
|
|
and store where TO points. */
|
| 106 |
|
|
|
| 107 |
|
|
extern void
|
| 108 |
|
|
floatformat_from_double PARAMS ((const struct floatformat *,
|
| 109 |
|
|
double *, char *));
|
| 110 |
|
|
|
| 111 |
|
|
#endif /* defined (FLOATFORMAT_H) */
|