1991-09-19 01:00:51 +02:00
|
|
|
/* Intel 387 floating point stuff.
|
|
|
|
Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
1995-08-02 05:41:12 +02:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1991-09-19 01:00:51 +02:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "frame.h"
|
|
|
|
#include "inferior.h"
|
|
|
|
#include "language.h"
|
|
|
|
#include "gdbcore.h"
|
1994-02-28 07:02:11 +01:00
|
|
|
#include "floatformat.h"
|
1991-09-19 01:00:51 +02:00
|
|
|
|
|
|
|
/* FIXME: Eliminate these routines when we have the time to change all
|
|
|
|
the callers. */
|
1992-02-22 02:46:16 +01:00
|
|
|
|
1991-09-19 01:00:51 +02:00
|
|
|
void
|
|
|
|
i387_to_double (from, to)
|
1992-02-22 02:46:16 +01:00
|
|
|
char *from;
|
|
|
|
char *to;
|
1991-09-19 01:00:51 +02:00
|
|
|
{
|
1994-02-28 07:02:11 +01:00
|
|
|
floatformat_to_double (&floatformat_i387_ext, from, (double *)to);
|
1991-09-19 01:00:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
double_to_i387 (from, to)
|
1992-02-22 02:46:16 +01:00
|
|
|
char *from;
|
|
|
|
char *to;
|
1991-09-19 01:00:51 +02:00
|
|
|
{
|
1994-02-28 07:02:11 +01:00
|
|
|
floatformat_from_double (&floatformat_i387_ext, (double *)from, to);
|
1991-09-19 01:00:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
print_387_control_word (control)
|
1992-02-22 02:46:16 +01:00
|
|
|
unsigned int control;
|
1991-09-19 01:00:51 +02:00
|
|
|
{
|
1993-11-01 23:25:23 +01:00
|
|
|
printf_unfiltered ("control %s: ", local_hex_string(control));
|
|
|
|
printf_unfiltered ("compute to ");
|
1991-09-19 01:00:51 +02:00
|
|
|
switch ((control >> 8) & 3)
|
|
|
|
{
|
1993-11-01 23:25:23 +01:00
|
|
|
case 0: printf_unfiltered ("24 bits; "); break;
|
|
|
|
case 1: printf_unfiltered ("(bad); "); break;
|
|
|
|
case 2: printf_unfiltered ("53 bits; "); break;
|
|
|
|
case 3: printf_unfiltered ("64 bits; "); break;
|
1991-09-19 01:00:51 +02:00
|
|
|
}
|
1993-11-01 23:25:23 +01:00
|
|
|
printf_unfiltered ("round ");
|
1991-09-19 01:00:51 +02:00
|
|
|
switch ((control >> 10) & 3)
|
|
|
|
{
|
1993-11-01 23:25:23 +01:00
|
|
|
case 0: printf_unfiltered ("NEAREST; "); break;
|
|
|
|
case 1: printf_unfiltered ("DOWN; "); break;
|
|
|
|
case 2: printf_unfiltered ("UP; "); break;
|
|
|
|
case 3: printf_unfiltered ("CHOP; "); break;
|
1991-09-19 01:00:51 +02:00
|
|
|
}
|
|
|
|
if (control & 0x3f)
|
|
|
|
{
|
1993-11-01 23:25:23 +01:00
|
|
|
printf_unfiltered ("mask:");
|
|
|
|
if (control & 0x0001) printf_unfiltered (" INVALID");
|
|
|
|
if (control & 0x0002) printf_unfiltered (" DENORM");
|
|
|
|
if (control & 0x0004) printf_unfiltered (" DIVZ");
|
|
|
|
if (control & 0x0008) printf_unfiltered (" OVERF");
|
|
|
|
if (control & 0x0010) printf_unfiltered (" UNDERF");
|
|
|
|
if (control & 0x0020) printf_unfiltered (" LOS");
|
|
|
|
printf_unfiltered (";");
|
1991-09-19 01:00:51 +02:00
|
|
|
}
|
1993-11-01 23:25:23 +01:00
|
|
|
printf_unfiltered ("\n");
|
1992-03-15 02:09:14 +01:00
|
|
|
if (control & 0xe080) warning ("reserved bits on: %s\n",
|
1991-09-19 09:39:54 +02:00
|
|
|
local_hex_string(control & 0xe080));
|
1991-09-19 01:00:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
print_387_status_word (status)
|
1992-02-22 02:46:16 +01:00
|
|
|
unsigned int status;
|
1991-09-19 01:00:51 +02:00
|
|
|
{
|
1993-11-01 23:25:23 +01:00
|
|
|
printf_unfiltered ("status %s: ", local_hex_string (status));
|
1991-09-19 01:00:51 +02:00
|
|
|
if (status & 0xff)
|
|
|
|
{
|
1993-11-01 23:25:23 +01:00
|
|
|
printf_unfiltered ("exceptions:");
|
|
|
|
if (status & 0x0001) printf_unfiltered (" INVALID");
|
|
|
|
if (status & 0x0002) printf_unfiltered (" DENORM");
|
|
|
|
if (status & 0x0004) printf_unfiltered (" DIVZ");
|
|
|
|
if (status & 0x0008) printf_unfiltered (" OVERF");
|
|
|
|
if (status & 0x0010) printf_unfiltered (" UNDERF");
|
|
|
|
if (status & 0x0020) printf_unfiltered (" LOS");
|
|
|
|
if (status & 0x0040) printf_unfiltered (" FPSTACK");
|
|
|
|
printf_unfiltered ("; ");
|
1991-09-19 01:00:51 +02:00
|
|
|
}
|
1993-11-01 23:25:23 +01:00
|
|
|
printf_unfiltered ("flags: %d%d%d%d; ",
|
1991-09-19 01:00:51 +02:00
|
|
|
(status & 0x4000) != 0,
|
|
|
|
(status & 0x0400) != 0,
|
|
|
|
(status & 0x0200) != 0,
|
|
|
|
(status & 0x0100) != 0);
|
1993-06-22 01:46:49 +02:00
|
|
|
|
1993-11-01 23:25:23 +01:00
|
|
|
printf_unfiltered ("top %d\n", (status >> 11) & 7);
|
1991-09-19 01:00:51 +02:00
|
|
|
}
|