1991-09-18 23:00:51 +00: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
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "frame.h"
|
|
|
|
#include "inferior.h"
|
|
|
|
#include "language.h"
|
|
|
|
#include "gdbcore.h"
|
|
|
|
#include "ieee-float.h"
|
|
|
|
|
|
|
|
#ifdef USG
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
#include <sys/reg.h>
|
|
|
|
|
|
|
|
struct ext_format ext_format_i387 = {
|
|
|
|
/* tot sbyte smask expbyte manbyte */
|
|
|
|
10, 9, 0x80, 9,8, 4,0 /* i387 */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* FIXME: Eliminate these routines when we have the time to change all
|
|
|
|
the callers. */
|
1992-02-22 01:46:16 +00:00
|
|
|
|
1991-09-18 23:00:51 +00:00
|
|
|
void
|
|
|
|
i387_to_double (from, to)
|
1992-02-22 01:46:16 +00:00
|
|
|
char *from;
|
|
|
|
char *to;
|
1991-09-18 23:00:51 +00:00
|
|
|
{
|
|
|
|
ieee_extended_to_double (&ext_format_i387, from, (double *)to);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
double_to_i387 (from, to)
|
1992-02-22 01:46:16 +00:00
|
|
|
char *from;
|
|
|
|
char *to;
|
1991-09-18 23:00:51 +00:00
|
|
|
{
|
1991-10-15 23:29:34 +00:00
|
|
|
double_to_ieee_extended (&ext_format_i387, (double *)from, to);
|
1991-09-18 23:00:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
print_387_control_word (control)
|
1992-02-22 01:46:16 +00:00
|
|
|
unsigned int control;
|
1991-09-18 23:00:51 +00:00
|
|
|
{
|
1991-09-19 07:39:54 +00:00
|
|
|
printf ("control %s: ", local_hex_string(control));
|
1991-09-18 23:00:51 +00:00
|
|
|
printf ("compute to ");
|
|
|
|
switch ((control >> 8) & 3)
|
|
|
|
{
|
|
|
|
case 0: printf ("24 bits; "); break;
|
|
|
|
case 1: printf ("(bad); "); break;
|
|
|
|
case 2: printf ("53 bits; "); break;
|
|
|
|
case 3: printf ("64 bits; "); break;
|
|
|
|
}
|
|
|
|
printf ("round ");
|
|
|
|
switch ((control >> 10) & 3)
|
|
|
|
{
|
|
|
|
case 0: printf ("NEAREST; "); break;
|
|
|
|
case 1: printf ("DOWN; "); break;
|
|
|
|
case 2: printf ("UP; "); break;
|
|
|
|
case 3: printf ("CHOP; "); break;
|
|
|
|
}
|
|
|
|
if (control & 0x3f)
|
|
|
|
{
|
|
|
|
printf ("mask:");
|
|
|
|
if (control & 0x0001) printf (" INVALID");
|
|
|
|
if (control & 0x0002) printf (" DENORM");
|
|
|
|
if (control & 0x0004) printf (" DIVZ");
|
|
|
|
if (control & 0x0008) printf (" OVERF");
|
|
|
|
if (control & 0x0010) printf (" UNDERF");
|
|
|
|
if (control & 0x0020) printf (" LOS");
|
|
|
|
printf (";");
|
|
|
|
}
|
|
|
|
printf ("\n");
|
1992-03-15 01:09:14 +00:00
|
|
|
if (control & 0xe080) warning ("reserved bits on: %s\n",
|
1991-09-19 07:39:54 +00:00
|
|
|
local_hex_string(control & 0xe080));
|
1991-09-18 23:00:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
print_387_status_word (status)
|
1992-02-22 01:46:16 +00:00
|
|
|
unsigned int status;
|
1991-09-18 23:00:51 +00:00
|
|
|
{
|
1991-09-19 07:39:54 +00:00
|
|
|
printf ("status %s: ", local_hex_string (status));
|
1991-09-18 23:00:51 +00:00
|
|
|
if (status & 0xff)
|
|
|
|
{
|
|
|
|
printf ("exceptions:");
|
|
|
|
if (status & 0x0001) printf (" INVALID");
|
|
|
|
if (status & 0x0002) printf (" DENORM");
|
|
|
|
if (status & 0x0004) printf (" DIVZ");
|
|
|
|
if (status & 0x0008) printf (" OVERF");
|
|
|
|
if (status & 0x0010) printf (" UNDERF");
|
|
|
|
if (status & 0x0020) printf (" LOS");
|
|
|
|
if (status & 0x0040) printf (" FPSTACK");
|
|
|
|
printf ("; ");
|
|
|
|
}
|
|
|
|
printf ("flags: %d%d%d%d; ",
|
|
|
|
(status & 0x4000) != 0,
|
|
|
|
(status & 0x0400) != 0,
|
|
|
|
(status & 0x0200) != 0,
|
|
|
|
(status & 0x0100) != 0);
|
|
|
|
|
|
|
|
printf ("top %d\n", (status >> 11) & 7);
|
|
|
|
}
|