]>
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 | |
6c9638b4 | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
cab7a417 | 19 | |
cab7a417 | 20 | #include "defs.h" |
cab7a417 JG |
21 | #include "frame.h" |
22 | #include "inferior.h" | |
23 | #include "language.h" | |
24 | #include "gdbcore.h" | |
eae3f093 | 25 | #include "floatformat.h" |
cab7a417 JG |
26 | |
27 | /* FIXME: Eliminate these routines when we have the time to change all | |
28 | the callers. */ | |
1ab3bf1b | 29 | |
cab7a417 JG |
30 | void |
31 | i387_to_double (from, to) | |
1ab3bf1b JG |
32 | char *from; |
33 | char *to; | |
cab7a417 | 34 | { |
eae3f093 | 35 | floatformat_to_double (&floatformat_i387_ext, from, (double *)to); |
cab7a417 JG |
36 | } |
37 | ||
38 | void | |
39 | double_to_i387 (from, to) | |
1ab3bf1b JG |
40 | char *from; |
41 | char *to; | |
cab7a417 | 42 | { |
eae3f093 | 43 | floatformat_from_double (&floatformat_i387_ext, (double *)from, to); |
cab7a417 JG |
44 | } |
45 | ||
46 | void | |
47 | print_387_control_word (control) | |
1ab3bf1b | 48 | unsigned int control; |
cab7a417 | 49 | { |
199b2450 TL |
50 | printf_unfiltered ("control %s: ", local_hex_string(control)); |
51 | printf_unfiltered ("compute to "); | |
cab7a417 JG |
52 | switch ((control >> 8) & 3) |
53 | { | |
199b2450 TL |
54 | case 0: printf_unfiltered ("24 bits; "); break; |
55 | case 1: printf_unfiltered ("(bad); "); break; | |
56 | case 2: printf_unfiltered ("53 bits; "); break; | |
57 | case 3: printf_unfiltered ("64 bits; "); break; | |
cab7a417 | 58 | } |
199b2450 | 59 | printf_unfiltered ("round "); |
cab7a417 JG |
60 | switch ((control >> 10) & 3) |
61 | { | |
199b2450 TL |
62 | case 0: printf_unfiltered ("NEAREST; "); break; |
63 | case 1: printf_unfiltered ("DOWN; "); break; | |
64 | case 2: printf_unfiltered ("UP; "); break; | |
65 | case 3: printf_unfiltered ("CHOP; "); break; | |
cab7a417 JG |
66 | } |
67 | if (control & 0x3f) | |
68 | { | |
199b2450 TL |
69 | printf_unfiltered ("mask:"); |
70 | if (control & 0x0001) printf_unfiltered (" INVALID"); | |
71 | if (control & 0x0002) printf_unfiltered (" DENORM"); | |
72 | if (control & 0x0004) printf_unfiltered (" DIVZ"); | |
73 | if (control & 0x0008) printf_unfiltered (" OVERF"); | |
74 | if (control & 0x0010) printf_unfiltered (" UNDERF"); | |
75 | if (control & 0x0020) printf_unfiltered (" LOS"); | |
76 | printf_unfiltered (";"); | |
cab7a417 | 77 | } |
199b2450 | 78 | printf_unfiltered ("\n"); |
318bf84f | 79 | if (control & 0xe080) warning ("reserved bits on: %s\n", |
d8b3b00e | 80 | local_hex_string(control & 0xe080)); |
cab7a417 JG |
81 | } |
82 | ||
83 | void | |
84 | print_387_status_word (status) | |
1ab3bf1b | 85 | unsigned int status; |
cab7a417 | 86 | { |
199b2450 | 87 | printf_unfiltered ("status %s: ", local_hex_string (status)); |
cab7a417 JG |
88 | if (status & 0xff) |
89 | { | |
199b2450 TL |
90 | printf_unfiltered ("exceptions:"); |
91 | if (status & 0x0001) printf_unfiltered (" INVALID"); | |
92 | if (status & 0x0002) printf_unfiltered (" DENORM"); | |
93 | if (status & 0x0004) printf_unfiltered (" DIVZ"); | |
94 | if (status & 0x0008) printf_unfiltered (" OVERF"); | |
95 | if (status & 0x0010) printf_unfiltered (" UNDERF"); | |
96 | if (status & 0x0020) printf_unfiltered (" LOS"); | |
97 | if (status & 0x0040) printf_unfiltered (" FPSTACK"); | |
98 | printf_unfiltered ("; "); | |
cab7a417 | 99 | } |
199b2450 | 100 | printf_unfiltered ("flags: %d%d%d%d; ", |
cab7a417 JG |
101 | (status & 0x4000) != 0, |
102 | (status & 0x0400) != 0, | |
103 | (status & 0x0200) != 0, | |
104 | (status & 0x0100) != 0); | |
2c7ab4ca | 105 | |
199b2450 | 106 | printf_unfiltered ("top %d\n", (status >> 11) & 7); |
cab7a417 | 107 | } |