floatformat.h revision 38889
133965Sjdp/* IEEE floating point support declarations, for GDB, the GNU Debugger. 233965Sjdp Copyright (C) 1991 Free Software Foundation, Inc. 333965Sjdp 433965SjdpThis file is part of GDB. 533965Sjdp 633965SjdpThis program is free software; you can redistribute it and/or modify 733965Sjdpit under the terms of the GNU General Public License as published by 833965Sjdpthe Free Software Foundation; either version 2 of the License, or 933965Sjdp(at your option) any later version. 1033965Sjdp 1133965SjdpThis program is distributed in the hope that it will be useful, 1233965Sjdpbut WITHOUT ANY WARRANTY; without even the implied warranty of 1333965SjdpMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1433965SjdpGNU General Public License for more details. 1533965Sjdp 1633965SjdpYou should have received a copy of the GNU General Public License 1733965Sjdpalong with this program; if not, write to the Free Software 1833965SjdpFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 1933965Sjdp 2033965Sjdp#if !defined (FLOATFORMAT_H) 2133965Sjdp#define FLOATFORMAT_H 1 2233965Sjdp 2333965Sjdp#include "ansidecl.h" 2433965Sjdp 2533965Sjdp/* A floatformat consists of a sign bit, an exponent and a mantissa. Once the 2633965Sjdp bytes are concatenated according to the byteorder flag, then each of those 2733965Sjdp fields is contiguous. We number the bits with 0 being the most significant 2833965Sjdp (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field 2933965Sjdp contains with the *_start and *_len fields. */ 3033965Sjdp 3138889Sjdp/* What is the order of the bytes. */ 3233965Sjdp 3338889Sjdpenum floatformat_byteorders { 3438889Sjdp 3538889Sjdp /* Standard little endian byte order. 3638889Sjdp EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */ 3738889Sjdp 3838889Sjdp floatformat_little, 3938889Sjdp 4038889Sjdp /* Standard big endian byte order. 4138889Sjdp EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */ 4238889Sjdp 4338889Sjdp floatformat_big, 4438889Sjdp 4538889Sjdp /* Little endian byte order but big endian word order. 4638889Sjdp EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */ 4738889Sjdp 4838889Sjdp floatformat_littlebyte_bigword 4938889Sjdp 5038889Sjdp}; 5138889Sjdp 5233965Sjdpenum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no }; 5333965Sjdp 5433965Sjdpstruct floatformat 5533965Sjdp{ 5633965Sjdp enum floatformat_byteorders byteorder; 5733965Sjdp unsigned int totalsize; /* Total size of number in bits */ 5833965Sjdp 5933965Sjdp /* Sign bit is always one bit long. 1 means negative, 0 means positive. */ 6033965Sjdp unsigned int sign_start; 6133965Sjdp 6233965Sjdp unsigned int exp_start; 6333965Sjdp unsigned int exp_len; 6433965Sjdp /* Amount added to "true" exponent. 0x3fff for many IEEE extendeds. */ 6533965Sjdp unsigned int exp_bias; 6633965Sjdp /* Exponent value which indicates NaN. This is the actual value stored in 6733965Sjdp the float, not adjusted by the exp_bias. This usually consists of all 6833965Sjdp one bits. */ 6933965Sjdp unsigned int exp_nan; 7033965Sjdp 7133965Sjdp unsigned int man_start; 7233965Sjdp unsigned int man_len; 7333965Sjdp 7433965Sjdp /* Is the integer bit explicit or implicit? */ 7533965Sjdp enum floatformat_intbit intbit; 7633965Sjdp}; 7733965Sjdp 7833965Sjdp/* floatformats for IEEE single and double, big and little endian. */ 7933965Sjdp 8033965Sjdpextern const struct floatformat floatformat_ieee_single_big; 8133965Sjdpextern const struct floatformat floatformat_ieee_single_little; 8233965Sjdpextern const struct floatformat floatformat_ieee_double_big; 8333965Sjdpextern const struct floatformat floatformat_ieee_double_little; 8433965Sjdp 8538889Sjdp/* floatformat for ARM IEEE double, little endian bytes and big endian words */ 8638889Sjdp 8738889Sjdpextern const struct floatformat floatformat_ieee_double_littlebyte_bigword; 8838889Sjdp 8933965Sjdp/* floatformats for various extendeds. */ 9033965Sjdp 9133965Sjdpextern const struct floatformat floatformat_i387_ext; 9233965Sjdpextern const struct floatformat floatformat_m68881_ext; 9333965Sjdpextern const struct floatformat floatformat_i960_ext; 9433965Sjdpextern const struct floatformat floatformat_m88110_ext; 9533965Sjdpextern const struct floatformat floatformat_arm_ext; 9633965Sjdp 9733965Sjdp/* Convert from FMT to a double. 9833965Sjdp FROM is the address of the extended float. 9933965Sjdp Store the double in *TO. */ 10033965Sjdp 10133965Sjdpextern void 10233965Sjdpfloatformat_to_double PARAMS ((const struct floatformat *, char *, double *)); 10333965Sjdp 10433965Sjdp/* The converse: convert the double *FROM to FMT 10533965Sjdp and store where TO points. */ 10633965Sjdp 10733965Sjdpextern void 10833965Sjdpfloatformat_from_double PARAMS ((const struct floatformat *, 10933965Sjdp double *, char *)); 11033965Sjdp 11133965Sjdp#endif /* defined (FLOATFORMAT_H) */ 112