root/kernel/FPU-emu/reg_constant.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. fld_const
  2. fld1
  3. fldl2t
  4. fldl2e
  5. fldpi
  6. fldlg2
  7. fldln2
  8. fldz
  9. fconst

   1 /*---------------------------------------------------------------------------+
   2  |  reg_constant.c                                                           |
   3  |                                                                           |
   4  | All of the constant FPU_REGs                                              |
   5  |                                                                           |
   6  | Copyright (C) 1992,1993                                                   |
   7  |                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      |
   8  |                       Australia.  E-mail apm233m@vaxc.cc.monash.edu.au    |
   9  |                                                                           |
  10  |                                                                           |
  11  +---------------------------------------------------------------------------*/
  12 
  13 #include "fpu_system.h"
  14 #include "fpu_emu.h"
  15 #include "status_w.h"
  16 #include "reg_constant.h"
  17 
  18 
  19 FPU_REG CONST_1    = { SIGN_POS, TW_Valid, EXP_BIAS,
  20                             0x00000000, 0x80000000 };
  21 FPU_REG CONST_2    = { SIGN_POS, TW_Valid, EXP_BIAS+1,
  22                             0x00000000, 0x80000000 };
  23 FPU_REG CONST_HALF = { SIGN_POS, TW_Valid, EXP_BIAS-1,
  24                             0x00000000, 0x80000000 };
  25 FPU_REG CONST_L2T  = { SIGN_POS, TW_Valid, EXP_BIAS+1,
  26                             0xcd1b8afe, 0xd49a784b };
  27 FPU_REG CONST_L2E  = { SIGN_POS, TW_Valid, EXP_BIAS,
  28                             0x5c17f0bc, 0xb8aa3b29 };
  29 FPU_REG CONST_PI   = { SIGN_POS, TW_Valid, EXP_BIAS+1,
  30                             0x2168c235, 0xc90fdaa2 };
  31 FPU_REG CONST_PI2  = { SIGN_POS, TW_Valid, EXP_BIAS,
  32                             0x2168c235, 0xc90fdaa2 };
  33 FPU_REG CONST_PI4  = { SIGN_POS, TW_Valid, EXP_BIAS-1,
  34                             0x2168c235, 0xc90fdaa2 };
  35 FPU_REG CONST_LG2  = { SIGN_POS, TW_Valid, EXP_BIAS-2,
  36                             0xfbcff799, 0x9a209a84 };
  37 FPU_REG CONST_LN2  = { SIGN_POS, TW_Valid, EXP_BIAS-1,
  38                             0xd1cf79ac, 0xb17217f7 };
  39 
  40 /* Only the sign (and tag) is used in internal zeroes */
  41 FPU_REG CONST_Z    = { SIGN_POS, TW_Zero, 0,          0x0,        0x0 };
  42 
  43 /* Only the sign and significand (and tag) are used in internal NaNs */
  44 /* The 80486 never generates one of these 
  45 FPU_REG CONST_SNAN = { SIGN_POS, TW_NaN, EXP_OVER, 0x00000001, 0x80000000 };
  46  */
  47 /* This is the real indefinite QNaN */
  48 FPU_REG CONST_QNaN = { SIGN_NEG, TW_NaN, EXP_OVER, 0x00000000, 0xC0000000 };
  49 
  50 /* Only the sign (and tag) is used in internal infinities */
  51 FPU_REG CONST_INF  = { SIGN_POS, TW_Infinity, EXP_OVER, 0x00000000, 0x80000000 };
  52 
  53 
  54 
  55 static void fld_const(FPU_REG *c)
     /* [previous][next][first][last][top][bottom][index][help] */
  56 {
  57   FPU_REG *st_new_ptr;
  58 
  59   if ( STACK_OVERFLOW )
  60     {
  61       stack_overflow();
  62       return;
  63     }
  64   push();
  65   reg_move(c, FPU_st0_ptr);
  66   status_word &= ~SW_C1;
  67 }
  68 
  69 
  70 static void fld1(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  71 {
  72   fld_const(&CONST_1);
  73 }
  74 
  75 static void fldl2t(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  76 {
  77   fld_const(&CONST_L2T);
  78 }
  79 
  80 static void fldl2e(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  81 {
  82   fld_const(&CONST_L2E);
  83 }
  84 
  85 static void fldpi(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  86 {
  87   fld_const(&CONST_PI);
  88 }
  89 
  90 static void fldlg2(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  91 {
  92   fld_const(&CONST_LG2);
  93 }
  94 
  95 static void fldln2(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  96 {
  97   fld_const(&CONST_LN2);
  98 }
  99 
 100 static void fldz(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 101 {
 102   fld_const(&CONST_Z);
 103 }
 104 
 105 static FUNC constants_table[] = {
 106   fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, Un_impl
 107 };
 108 
 109 void fconst(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 110 {
 111   (constants_table[FPU_rm])();
 112 }

/* [previous][next][first][last][top][bottom][index][help] */