]>
Commit | Line | Data |
---|---|---|
cab7a417 JG |
1 | /* Intel 387 floating point stuff. |
2 | Copyright (C) 1988, 1989, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | ||
20 | #include <stdio.h> | |
21 | #include "defs.h" | |
cab7a417 JG |
22 | #include "frame.h" |
23 | #include "inferior.h" | |
24 | #include "language.h" | |
25 | #include "gdbcore.h" | |
26 | #include "ieee-float.h" | |
27 | ||
28 | #ifdef USG | |
29 | #include <sys/types.h> | |
30 | #endif | |
31 | ||
32 | #include <sys/param.h> | |
33 | #include <sys/dir.h> | |
34 | #include <signal.h> | |
35 | #include <sys/user.h> | |
36 | #include <sys/ioctl.h> | |
37 | #include <fcntl.h> | |
38 | ||
39 | #include <sys/file.h> | |
40 | #include <sys/stat.h> | |
41 | ||
42 | #include <sys/reg.h> | |
43 | ||
44 | struct ext_format ext_format_i387 = { | |
45 | /* tot sbyte smask expbyte manbyte */ | |
46 | 10, 9, 0x80, 9,8, 4,0 /* i387 */ | |
47 | }; | |
48 | ||
49 | /* FIXME: Eliminate these routines when we have the time to change all | |
50 | the callers. */ | |
51 | void | |
52 | i387_to_double (from, to) | |
53 | char *from, *to; | |
54 | { | |
55 | ieee_extended_to_double (&ext_format_i387, from, (double *)to); | |
56 | } | |
57 | ||
58 | void | |
59 | double_to_i387 (from, to) | |
60 | char *from, *to; | |
61 | { | |
afe4ca15 | 62 | double_to_ieee_extended (&ext_format_i387, (double *)from, to); |
cab7a417 JG |
63 | } |
64 | ||
65 | void | |
66 | print_387_control_word (control) | |
67 | unsigned short control; | |
68 | { | |
d8b3b00e | 69 | printf ("control %s: ", local_hex_string(control)); |
cab7a417 JG |
70 | printf ("compute to "); |
71 | switch ((control >> 8) & 3) | |
72 | { | |
73 | case 0: printf ("24 bits; "); break; | |
74 | case 1: printf ("(bad); "); break; | |
75 | case 2: printf ("53 bits; "); break; | |
76 | case 3: printf ("64 bits; "); break; | |
77 | } | |
78 | printf ("round "); | |
79 | switch ((control >> 10) & 3) | |
80 | { | |
81 | case 0: printf ("NEAREST; "); break; | |
82 | case 1: printf ("DOWN; "); break; | |
83 | case 2: printf ("UP; "); break; | |
84 | case 3: printf ("CHOP; "); break; | |
85 | } | |
86 | if (control & 0x3f) | |
87 | { | |
88 | printf ("mask:"); | |
89 | if (control & 0x0001) printf (" INVALID"); | |
90 | if (control & 0x0002) printf (" DENORM"); | |
91 | if (control & 0x0004) printf (" DIVZ"); | |
92 | if (control & 0x0008) printf (" OVERF"); | |
93 | if (control & 0x0010) printf (" UNDERF"); | |
94 | if (control & 0x0020) printf (" LOS"); | |
95 | printf (";"); | |
96 | } | |
97 | printf ("\n"); | |
98 | if (control & 0xe080) printf ("warning: reserved bits on: %s\n", | |
d8b3b00e | 99 | local_hex_string(control & 0xe080)); |
cab7a417 JG |
100 | } |
101 | ||
102 | void | |
103 | print_387_status_word (status) | |
104 | unsigned short status; | |
105 | { | |
d8b3b00e | 106 | printf ("status %s: ", local_hex_string (status)); |
cab7a417 JG |
107 | if (status & 0xff) |
108 | { | |
109 | printf ("exceptions:"); | |
110 | if (status & 0x0001) printf (" INVALID"); | |
111 | if (status & 0x0002) printf (" DENORM"); | |
112 | if (status & 0x0004) printf (" DIVZ"); | |
113 | if (status & 0x0008) printf (" OVERF"); | |
114 | if (status & 0x0010) printf (" UNDERF"); | |
115 | if (status & 0x0020) printf (" LOS"); | |
116 | if (status & 0x0040) printf (" FPSTACK"); | |
117 | printf ("; "); | |
118 | } | |
119 | printf ("flags: %d%d%d%d; ", | |
120 | (status & 0x4000) != 0, | |
121 | (status & 0x0400) != 0, | |
122 | (status & 0x0200) != 0, | |
123 | (status & 0x0100) != 0); | |
124 | ||
125 | printf ("top %d\n", (status >> 11) & 7); | |
126 | } |