]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/i387-tdep.c
import gdb-1999-07-07 post reformat
[thirdparty/binutils-gdb.git] / gdb / i387-tdep.c
1 /* Intel 387 floating point stuff.
2 Copyright (C) 1988, 1989, 1991, 1998 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,
19 Boston, MA 02111-1307, USA. */
20
21 #include "defs.h"
22 #include "frame.h"
23 #include "inferior.h"
24 #include "language.h"
25 #include "gdbcore.h"
26 #include "floatformat.h"
27
28 void i387_to_double PARAMS ((char *, char *));
29
30 void double_to_i387 PARAMS ((char *, char *));
31
32 /* FIXME: Eliminate these routines when we have the time to change all
33 the callers. */
34
35 void
36 i387_to_double (from, to)
37 char *from;
38 char *to;
39 {
40 floatformat_to_double (&floatformat_i387_ext, from, (double *) to);
41 }
42
43 void
44 double_to_i387 (from, to)
45 char *from;
46 char *to;
47 {
48 floatformat_from_double (&floatformat_i387_ext, (double *) from, to);
49 }
50
51 void
52 print_387_control_word (control)
53 unsigned int control;
54 {
55 printf_unfiltered ("control %s: ", local_hex_string (control));
56 printf_unfiltered ("compute to ");
57 switch ((control >> 8) & 3)
58 {
59 case 0:
60 printf_unfiltered ("24 bits; ");
61 break;
62 case 1:
63 printf_unfiltered ("(bad); ");
64 break;
65 case 2:
66 printf_unfiltered ("53 bits; ");
67 break;
68 case 3:
69 printf_unfiltered ("64 bits; ");
70 break;
71 }
72 printf_unfiltered ("round ");
73 switch ((control >> 10) & 3)
74 {
75 case 0:
76 printf_unfiltered ("NEAREST; ");
77 break;
78 case 1:
79 printf_unfiltered ("DOWN; ");
80 break;
81 case 2:
82 printf_unfiltered ("UP; ");
83 break;
84 case 3:
85 printf_unfiltered ("CHOP; ");
86 break;
87 }
88 if (control & 0x3f)
89 {
90 printf_unfiltered ("mask:");
91 if (control & 0x0001)
92 printf_unfiltered (" INVALID");
93 if (control & 0x0002)
94 printf_unfiltered (" DENORM");
95 if (control & 0x0004)
96 printf_unfiltered (" DIVZ");
97 if (control & 0x0008)
98 printf_unfiltered (" OVERF");
99 if (control & 0x0010)
100 printf_unfiltered (" UNDERF");
101 if (control & 0x0020)
102 printf_unfiltered (" LOS");
103 printf_unfiltered (";");
104 }
105 printf_unfiltered ("\n");
106 if (control & 0xe080)
107 warning ("reserved bits on: %s\n",
108 local_hex_string (control & 0xe080));
109 }
110
111 void
112 print_387_status_word (status)
113 unsigned int status;
114 {
115 printf_unfiltered ("status %s: ", local_hex_string (status));
116 if (status & 0xff)
117 {
118 printf_unfiltered ("exceptions:");
119 if (status & 0x0001)
120 printf_unfiltered (" INVALID");
121 if (status & 0x0002)
122 printf_unfiltered (" DENORM");
123 if (status & 0x0004)
124 printf_unfiltered (" DIVZ");
125 if (status & 0x0008)
126 printf_unfiltered (" OVERF");
127 if (status & 0x0010)
128 printf_unfiltered (" UNDERF");
129 if (status & 0x0020)
130 printf_unfiltered (" LOS");
131 if (status & 0x0040)
132 printf_unfiltered (" FPSTACK");
133 printf_unfiltered ("; ");
134 }
135 printf_unfiltered ("flags: %d%d%d%d; ",
136 (status & 0x4000) != 0,
137 (status & 0x0400) != 0,
138 (status & 0x0200) != 0,
139 (status & 0x0100) != 0);
140
141 printf_unfiltered ("top %d\n", (status >> 11) & 7);
142 }