delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/31/00:15:56

Message-ID: <35C14346.6A03@icrdl.net>
From: Michel Huot <huotm AT icrdl DOT net>
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: 80x87 detection in DJGPP programs
Lines: 24
Date: Fri, 31 Jul 1998 04:09:18 GMT
NNTP-Posting-Host: 207.236.233.104
NNTP-Posting-Date: Fri, 31 Jul 1998 00:09:18 EDT
Organization: Bell Solutions
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi Im  making a 3d engine and i needed a sqrt routine. 
The DJGPP library sqrt() is fast when the machine have 
a coprocessor, but the emulation is terribly slow. Since 
i works with fixed point i wrote an integer sqrt routine, 
which is faster. On the other hand, it is slower than a 80x87.

So my question is: how can I detect a 80x87 in a DJGPP program?

The following code works fine on a machine that own a 80x87 
but i get an SIGOFP exception when running it on a machine 
that dont own one:

int Test8087(void)
{
 int a= 0;
  __asm__ __volatile__ ( "finit
                          fstcw (%%ebx)
                          : : "b" (&a));
  return(((a>> 8)& 0xff)== 3);
}

Anyone knows how to get it works on a machine that dont own a 80x87?

PS. Sorry for my bad english im french

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019