1998-10-16 Jason Molenda (jsm@bugshack.cygnus.com)
[deliverable/binutils-gdb.git] / gdb / i387-tdep.c
CommitLineData
cab7a417 1/* Intel 387 floating point stuff.
24418cfb 2 Copyright (C) 1988, 1989, 1991, 1998 Free Software Foundation, Inc.
cab7a417
JG
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
6c9638b4 18Foundation, 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 26
24418cfb
JM
27void i387_to_double PARAMS ((char *, char *));
28
29void double_to_i387 PARAMS ((char *, char *));
30
cab7a417
JG
31/* FIXME: Eliminate these routines when we have the time to change all
32 the callers. */
1ab3bf1b 33
cab7a417
JG
34void
35i387_to_double (from, to)
1ab3bf1b
JG
36 char *from;
37 char *to;
cab7a417 38{
eae3f093 39 floatformat_to_double (&floatformat_i387_ext, from, (double *)to);
cab7a417
JG
40}
41
42void
43double_to_i387 (from, to)
1ab3bf1b
JG
44 char *from;
45 char *to;
cab7a417 46{
eae3f093 47 floatformat_from_double (&floatformat_i387_ext, (double *)from, to);
cab7a417
JG
48}
49
50void
51print_387_control_word (control)
1ab3bf1b 52 unsigned int control;
cab7a417 53{
199b2450
TL
54 printf_unfiltered ("control %s: ", local_hex_string(control));
55 printf_unfiltered ("compute to ");
cab7a417
JG
56 switch ((control >> 8) & 3)
57 {
199b2450
TL
58 case 0: printf_unfiltered ("24 bits; "); break;
59 case 1: printf_unfiltered ("(bad); "); break;
60 case 2: printf_unfiltered ("53 bits; "); break;
61 case 3: printf_unfiltered ("64 bits; "); break;
cab7a417 62 }
199b2450 63 printf_unfiltered ("round ");
cab7a417
JG
64 switch ((control >> 10) & 3)
65 {
199b2450
TL
66 case 0: printf_unfiltered ("NEAREST; "); break;
67 case 1: printf_unfiltered ("DOWN; "); break;
68 case 2: printf_unfiltered ("UP; "); break;
69 case 3: printf_unfiltered ("CHOP; "); break;
cab7a417
JG
70 }
71 if (control & 0x3f)
72 {
199b2450
TL
73 printf_unfiltered ("mask:");
74 if (control & 0x0001) printf_unfiltered (" INVALID");
75 if (control & 0x0002) printf_unfiltered (" DENORM");
76 if (control & 0x0004) printf_unfiltered (" DIVZ");
77 if (control & 0x0008) printf_unfiltered (" OVERF");
78 if (control & 0x0010) printf_unfiltered (" UNDERF");
79 if (control & 0x0020) printf_unfiltered (" LOS");
80 printf_unfiltered (";");
cab7a417 81 }
199b2450 82 printf_unfiltered ("\n");
318bf84f 83 if (control & 0xe080) warning ("reserved bits on: %s\n",
d8b3b00e 84 local_hex_string(control & 0xe080));
cab7a417
JG
85}
86
87void
88print_387_status_word (status)
1ab3bf1b 89 unsigned int status;
cab7a417 90{
199b2450 91 printf_unfiltered ("status %s: ", local_hex_string (status));
cab7a417
JG
92 if (status & 0xff)
93 {
199b2450
TL
94 printf_unfiltered ("exceptions:");
95 if (status & 0x0001) printf_unfiltered (" INVALID");
96 if (status & 0x0002) printf_unfiltered (" DENORM");
97 if (status & 0x0004) printf_unfiltered (" DIVZ");
98 if (status & 0x0008) printf_unfiltered (" OVERF");
99 if (status & 0x0010) printf_unfiltered (" UNDERF");
100 if (status & 0x0020) printf_unfiltered (" LOS");
101 if (status & 0x0040) printf_unfiltered (" FPSTACK");
102 printf_unfiltered ("; ");
cab7a417 103 }
199b2450 104 printf_unfiltered ("flags: %d%d%d%d; ",
cab7a417
JG
105 (status & 0x4000) != 0,
106 (status & 0x0400) != 0,
107 (status & 0x0200) != 0,
108 (status & 0x0100) != 0);
2c7ab4ca 109
199b2450 110 printf_unfiltered ("top %d\n", (status >> 11) & 7);
cab7a417 111}
This page took 0.370659 seconds and 4 git commands to generate.