home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / INCLUDE.ZIP / _MATH.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  5.6 KB  |  256 lines

  1. /*------------------------------------------------------------------------
  2.  * filename - _math.h
  3.  *
  4.  *    Access to the Floating Point Support Library.
  5.  *
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987, 1990 by Borland International        |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18. /*
  19.  * Parameters must be supplied on the iNDP stack and are consumed.
  20.  * Result will be in the iNDP TOS.
  21. */
  22.  
  23. /*
  24.  *  An iNDP_image is put into memory by the FSTENV instruction.
  25. */
  26.  
  27. typedef struct
  28. {
  29.     unsigned  control;
  30.     unsigned  status_;
  31.     unsigned  tags;
  32.     unsigned  ip;
  33.     unsigned  ip_opcode;
  34.     unsigned  dp;
  35.     unsigned  dptop;
  36. }
  37.     iNDP_env;
  38.  
  39. #ifdef __OS2__
  40.  
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. void _f87_Sine(void);
  45. void _f87_Cosine(void);
  46. void _f87_Tangent(void);
  47. void _f87_ArcTan(void);
  48.  
  49. void _f87_Log(void);
  50. void _f87_Log2(void);
  51. void _f87_Log10(void);
  52.  
  53. void _f87_Exp(void);
  54. void _f87_Exp2(void);
  55. void _f87_Exp10(void);
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59.  
  60. #else
  61. /*
  62. These shortcut codes are like emulated 8087 instructions, but they enter
  63. the emulator at a level which bypasses simulation of that chip's status
  64. registers.  Therefore the emulation is not strict.  Also the addressing
  65. modes are fixed, none of the '87 flexibility is available (nor do you pay
  66. the time penalty of emulating the instruction decode).  They are designed
  67. to match the sequences the compiler frequently generates.
  68.  
  69. These shortcuts MUST be called in a fixed pattern.  For most operations
  70. the sequence is:
  71. */
  72.  
  73. #define _FAST_(shortCode)  int    3Eh;  asm db    shortCode, 90h
  74.  
  75. /*
  76. A few operations require a 4-byte sequence with two trailing bytes.
  77. The second trailing byte supplies a register count or some other parameter.
  78. */
  79.  
  80. #define _FAST4_(shortCode,rNum)   int    3Eh; asm db  shortCode, rNum
  81.  
  82. #define    shortcutInt    0x3E
  83.  
  84. typedef enum  _shortCodes_
  85. {
  86.     _FSCALEAX_    = 0xA2,
  87.     _FCOM_        = 0xA4,
  88.     _FSTCWAX_    = 0xA6,
  89.     _FLDSTN_    = 0xA8,        /* FAST4    */
  90.  
  91.     _FASC2BIN_    = 0xAA,
  92.     _FBIN2ASC_    = 0xAC,
  93.  
  94.     _FNINIT_    = 0xAE,
  95.     _FLDCW_        = 0xB0,
  96.     _FSTSWAX_    = 0xB2,
  97.     _FERROR_    = 0xB4,
  98.  
  99.     _FFRAC_        = 0xB6,
  100.  
  101.     _FSTPRI_    = 0xB8,
  102.     _FSTPRUI_    = 0xBA,
  103.     _FSTPRL_    = 0xBC,
  104.     _FSTPRUL_    = 0xBE,
  105.  
  106.     _FSTPTI_    = 0xC0,
  107.     _FSTPTUI_    = 0xC2,
  108.     _FSTPTL_    = 0xC4,
  109.     _FSTPTUL_    = 0xC6,
  110.  
  111.     _FLDI_        = 0xC8,
  112.     _FLDUI_        = 0xCA,
  113.     _FLDL_        = 0xCC,
  114.     _FLDUL_        = 0xCE,
  115.  
  116.     _FLDLEC_    = 0xD0,
  117.     _FLDULEC_    = 0xD2,
  118.  
  119.     _FLDSDA_    = 0xD4,
  120.     _FLDSEC_    = 0xD6,
  121.     _FSTPSDA_    = 0xD8,
  122.  
  123.     _FXCHN_        = 0xDA,        /* FAST4    */
  124.  
  125. /*  The following 8 compiler-support short-cuts are supported by the
  126.     emulator even when true emulation is used and the other short-cuts
  127.     are suppressed.
  128. */
  129.     _FSPILLN_    = 0xDC,        /* FAST4    */
  130.     _FRELOADN_    = 0xDE,        /* FAST4    */
  131.  
  132.     _FCMPPS_    = 0xE0,
  133.     _FCMPPD_    = 0xE2,
  134.     _FCMPP_        = 0xE4,
  135.     _FCMP_        = 0xE6,
  136.     _FTST_        = 0xE8,
  137.     _FXAM_        = 0xEA,
  138.  
  139. /*  The following 10 transcendental short-cuts are supported by the
  140.     emulator even when true emulation is used and the other short-cuts
  141.     are suppressed.
  142. */
  143.     _FSIN_        = 0xEC,
  144.     _FCOS_        = 0xEE,
  145.     _FTAN_        = 0xF0,
  146.     _FATAN_        = 0xF2,
  147.     _FLOG_        = 0xF4,
  148.     _FLOG2_        = 0xF6,
  149.     _FLOG10_    = 0xF8,
  150.     _FEXP_        = 0xFA,
  151.     _FEXP2_        = 0xFC,
  152.     _FEXP10_    = 0xFE,
  153.  
  154. /* negatives have no simple in-line equivalents, though some (like FXCHN)
  155.    will be patched in-line.  Positives can be inline patched by a uniform
  156.    look-up table.
  157. */
  158.     _FSADD_        = 0x00,
  159.     _FSSUB_        = 0x02,
  160.     _FSSUBR_    = 0x04,
  161.     _FSMUL_        = 0x06,
  162.     _FSDIV_        = 0x08,
  163.     _FSDIVR_    = 0x0A,
  164.     _FSSQRT_    = 0x0C,
  165.  
  166.     _FLDSES_    = 0x0E,
  167.     _FLDSCS_    = 0x10,
  168.     _FLDSSS_    = 0x12,
  169.     _FLDSDS_    = 0x14,
  170.  
  171.     _FLDDES_    = 0x16,
  172.     _FLDDCS_    = 0x18,
  173.     _FLDDSS_    = 0x1A,
  174.     _FLDDDS_    = 0x1C,
  175.  
  176.     _FLDXES_    = 0x1E,
  177.     _FLDXCS_    = 0x20,
  178.     _FLDXSS_    = 0x22,
  179.     _FLDXDS_    = 0x24,
  180.  
  181.     _FLDCES_    = 0x26,
  182.     _FLDCCS_    = 0x28,
  183.     _FLDCSS_    = 0x2A,
  184.     _FLDCDS_    = 0x2C,
  185.  
  186.     _FLDBXES_    = 0x2E,
  187.     _FLDBXCS_    = 0x30,
  188.     _FLDBXSS_    = 0x32,
  189.     _FLDBXDS_    = 0x34,
  190.  
  191.     _FSTPSES_    = 0x36,
  192.     _FSTPSCS_    = 0x38,
  193.     _FSTPSSS_    = 0x3A,
  194.     _FSTPSDS_    = 0x3C,
  195.  
  196.     _FSTPDES_    = 0x3E,
  197.     _FSTPDCS_    = 0x40,
  198.     _FSTPDSS_    = 0x42,
  199.     _FSTPDDS_    = 0x44,
  200.  
  201.     _FSTPXES_    = 0x46,
  202.     _FSTPXCS_    = 0x48,
  203.     _FSTPXSS_    = 0x4A,
  204.     _FSTPXDS_    = 0x4C,
  205.  
  206.     _FSTPCES_    = 0x4E,
  207.     _FSTPCCS_    = 0x50,
  208.     _FSTPCSS_    = 0x52,
  209.     _FSTPCDS_    = 0x54,
  210.  
  211.     _FADD_        = 0x56,
  212.     _FSUB_        = 0x58,
  213.     _FSUBR_        = 0x5A,
  214.     _FMUL_        = 0x5C,
  215.     _FDIV_        = 0x5E,
  216.     _FDIVR_        = 0x60,
  217.     _FSQRT_        = 0x62,
  218.  
  219.     _FCHS_        = 0x64,
  220.     _FABS_        = 0x66,
  221.  
  222.     _FLDST0_    = 0x68,
  223.     _FSTPST0_    = 0x6A,
  224.     _FXCH_        = 0x6C,
  225.     _FRNDINT_    = 0x6E,
  226.  
  227.     _FLDZ_        = 0x70,
  228.     _FLD1_        = 0x72,
  229.     _FPREM_        = 0x74,
  230.     _FXTRACT_    = 0x76,
  231.     _FLDPI_        = 0x78,
  232. };
  233. #endif
  234.  
  235. /* The flag _8087 says whether coprocessor is in use.
  236.    It is only valid floating point is used in the program.
  237.    The values are:
  238.      0 - nocoprocessor, or ignored because of SET 87=N.
  239.      1 - 8087 or 80187, or using coprocessor because of SET 87=Y.
  240.      2 - 80287
  241.      3 - 80387
  242. */
  243.  
  244. extern int cdecl _8087;
  245.  
  246. /* some 80387 opcodes */
  247.  
  248. #define OPCODE_FSIN            0D9h, 0FEh
  249. #define OPCODE_FCOS            0D9h, 0FFh
  250. #define OPCODE_FSINCOS        0D9h, 0FBh
  251. #define OPCODE_FSTSWAX        0D9h, 0FFh
  252.  
  253. #if    MSC
  254. #include "msc.h"
  255. #endif
  256.