Detecting Presence of 80x87 Math Coprocessor

Last reviewed: July 17, 1997
Article ID: Q38285
5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a | 1.00 1.50
MS-DOS                      | OS/2            | WINDOWS
kbprg

The information in this article applies to:

  • Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax
  • Microsoft C for OS/2, versions 5.1, 6.0, and 6.0a
  • Microsoft C/C++ for MS-DOS, version 7.0
  • Microsoft Visual C++ for Windows, version 1.0 and 1.5

SUMMARY

There is no direct way to query the Microsoft C floating-point libraries to determine whether a math coprocessor is being used. Compiling using /FPi indicates that you don't want to worry about whether a coprocessor is present. Consequently, the compiler generates code that will do the following:

  1. Checks to see if a 80x87 coprocessor is present.

  2. If so, uses it.

  3. If not, emulates it with software routines.

There is nothing in this algorithm to tell your program what it found. The only way you'll know it's emulating the coprocessor is by observing how slowly your program runs.

MORE INFORMATION

If you want to know whether a coprocessor is present, you'll have to test it yourself. For more information on how to test for the presence of an 80x87 coprocessor, please consult Intel's "80286 and 80287 Programmer's Reference Manual," pages 3-2 and 3-3 (in the second half of the book). This section is titled "System-Level Numeric Programming," and states that your program can detect the presence of the 80287 NPX. It then gives an assembly-language example that works correctly for both 8086- and 80286-based machines.

You can use this routine in your program as follows:

  1. During initialization of your program, call the short Intel routine to see if a coprocessor is present.

  2. If there is a coprocessor, proceed normally.

  3. If there is no coprocessor, put up a message box explaining the following to the user:

    Your computer lacks a coprocessor, but <my_app> will emulate it in software; this emulation will slow down the calculations that <my_app> needs to perform. To increase the performance of <my_app>, as well as other programs, add a numeric coprocessor to your system.

  4. Proceed with your program as you normally would. The C run-time libraries will automatically adjust for the presence or lack of an 80x87.


Additional reference words: kbinf 1.00 1.50 5.10 6.00 6.00a 6.00ax 7.00
8087 80287 80387
KBCategory: kbprg
KBSubcategory: CLngIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.