1 /* 2 * This file is part of ms-dos port for XaoS 3 * ctrl87.h 4 * 5 */ 6 7 8 #ifndef __CONTROL87_H__ 9 10 11 #define __CONTROL87_H__ 12 13 14 #ifdef __CONTROL87_C__ 15 #define EXTERN 16 #else 17 #define EXTERN extern 18 #endif 19 20 21 /* 8087/80287 Status Word format */ 22 23 #define SW_INVALID 0x0001 /* Invalid operation */ 24 #define SW_DENORMAL 0x0002 /* Denormalized operand */ 25 #define SW_ZERODIVIDE 0x0004 /* Zero divide */ 26 #define SW_OVERFLOW 0x0008 /* Overflow */ 27 #define SW_UNDERFLOW 0x0010 /* Underflow */ 28 #define SW_INEXACT 0x0020 /* Precision (Inexact result) */ 29 30 /* 8087/80287 Control Word format */ 31 32 #define MCW_EM 0x003f /* interrupt Exception Masks */ 33 #define EM_INVALID 0x0001 /* invalid */ 34 #define EM_DENORMAL 0x0002 /* denormal */ 35 #define EM_ZERODIVIDE 0x0004 /* zero divide */ 36 #define EM_OVERFLOW 0x0008 /* overflow */ 37 #define EM_UNDERFLOW 0x0010 /* underflow */ 38 #define EM_INEXACT 0x0020 /* inexact (precision) */ 39 40 #define MCW_IC 0x1000 /* Infinity Control */ 41 #define IC_AFFINE 0x1000 /* affine */ 42 #define IC_PROJECTIVE 0x0000 /* projective */ 43 44 #define MCW_RC 0x0c00 /* Rounding Control */ 45 #define RC_CHOP 0x0c00 /* chop */ 46 #define RC_UP 0x0800 /* up */ 47 #define RC_DOWN 0x0400 /* down */ 48 #define RC_NEAR 0x0000 /* near */ 49 50 #define MCW_PC 0x0300 /* Precision Control */ 51 #define PC_24 0x0000 /* 24 bits */ 52 #define PC_53 0x0200 /* 53 bits */ 53 #define PC_64 0x0300 /* 64 bits */ 54 55 /**************************************************************************/ 56 /************************* Type declarations **************************/ 57 /**************************************************************************/ 58 59 /**************************************************************************/ 60 /************************ Function declarations ***********************/ 61 /**************************************************************************/ 62 63 /* 64 _control87 changes floating-point control word. 65 66 Declaration: 67 ------------ 68 unsigned short _control87(unsigned short newcw, unsigned short mask); 69 70 Remarks: 71 -------- 72 _control87 retrieves or changes the floating-point control word. 73 74 The floating-point control word is an unsigned short that specifies the 75 following modes in the 80x87 FPU: 76 o allowed exceptions 77 o infinity mode 78 o rounding mode 79 o precision mode 80 81 Changing these modes allows you to mask or unmask floating-point exceptions. 82 83 _control87 matches the bits in mask to the bits in newcw. 84 85 If any mask bit = 1, the corresponding bit in newcw contains the new value 86 for the same bit in the floating-point control word. 87 88 If mask = 0000, _control87 returns the floating-point control word without 89 altering it. 90 91 Examples: 92 --------- 93 Switching to projective infinity mode: 94 _control87(IC_PROJECTIVE, MCW_IC); 95 96 Disabling all exceptions: 97 _control87(MCW_EM, MCW_EM); 98 99 Return Value: 100 ------------- 101 The bits in the value returned reflect the new floating-point control word. 102 */ 103 EXTERN unsigned short _control87(unsigned short, unsigned short); 104 105 106 /**************************************************************************/ 107 /************************** Global variables **************************/ 108 /**************************************************************************/ 109 110 111 112 #ifdef __CONTROL87_C__ 113 #else 114 #endif 115 116 117 #undef EXTERN 118 119 120 #endif 121