1 /* Intel 387 floating point stuff.
2 Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include "ieee-float.h"
29 #include <sys/types.h>
32 #include <sys/param.h>
36 #include <sys/ioctl.h>
44 struct ext_format ext_format_i387 = {
45 /* tot sbyte smask expbyte manbyte */
46 10, 9, 0x80, 9,8, 4,0 /* i387 */
49 /* FIXME: Eliminate these routines when we have the time to change all
53 i387_to_double (from, to)
57 ieee_extended_to_double (&ext_format_i387, from, (double *)to);
61 double_to_i387 (from, to)
65 double_to_ieee_extended (&ext_format_i387, (double *)from, to);
69 print_387_control_word (control)
72 printf ("control %s: ", local_hex_string(control));
73 printf ("compute to ");
74 switch ((control >> 8) & 3)
76 case 0: printf ("24 bits; "); break;
77 case 1: printf ("(bad); "); break;
78 case 2: printf ("53 bits; "); break;
79 case 3: printf ("64 bits; "); break;
82 switch ((control >> 10) & 3)
84 case 0: printf ("NEAREST; "); break;
85 case 1: printf ("DOWN; "); break;
86 case 2: printf ("UP; "); break;
87 case 3: printf ("CHOP; "); break;
92 if (control & 0x0001) printf (" INVALID");
93 if (control & 0x0002) printf (" DENORM");
94 if (control & 0x0004) printf (" DIVZ");
95 if (control & 0x0008) printf (" OVERF");
96 if (control & 0x0010) printf (" UNDERF");
97 if (control & 0x0020) printf (" LOS");
101 if (control & 0xe080) printf ("warning: reserved bits on: %s\n",
102 local_hex_string(control & 0xe080));
106 print_387_status_word (status)
109 printf ("status %s: ", local_hex_string (status));
112 printf ("exceptions:");
113 if (status & 0x0001) printf (" INVALID");
114 if (status & 0x0002) printf (" DENORM");
115 if (status & 0x0004) printf (" DIVZ");
116 if (status & 0x0008) printf (" OVERF");
117 if (status & 0x0010) printf (" UNDERF");
118 if (status & 0x0020) printf (" LOS");
119 if (status & 0x0040) printf (" FPSTACK");
122 printf ("flags: %d%d%d%d; ",
123 (status & 0x4000) != 0,
124 (status & 0x0400) != 0,
125 (status & 0x0200) != 0,
126 (status & 0x0100) != 0);
128 printf ("top %d\n", (status >> 11) & 7);