root/drivers/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,1994                                              |
   7  |                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      |
   8  |                       Australia.  E-mail   billm@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 CONST_1    = { SIGN_POS, TW_Valid, EXP_BIAS,
  20                             0x00000000, 0x80000000 };
  21 FPU_REG const CONST_2    = { SIGN_POS, TW_Valid, EXP_BIAS+1,
  22                             0x00000000, 0x80000000 };
  23 FPU_REG const CONST_HALF = { SIGN_POS, TW_Valid, EXP_BIAS-1,
  24                             0x00000000, 0x80000000 };
  25 FPU_REG const CONST_L2T  = { SIGN_POS, TW_Valid, EXP_BIAS+1,
  26                             0xcd1b8afe, 0xd49a784b };
  27 FPU_REG const CONST_L2E  = { SIGN_POS, TW_Valid, EXP_BIAS,
  28                             0x5c17f0bc, 0xb8aa3b29 };
  29 FPU_REG const CONST_PI   = { SIGN_POS, TW_Valid, EXP_BIAS+1,
  30                             0x2168c235, 0xc90fdaa2 };
  31 FPU_REG const CONST_PI2  = { SIGN_POS, TW_Valid, EXP_BIAS,
  32                             0x2168c235, 0xc90fdaa2 };
  33 FPU_REG const CONST_PI4  = { SIGN_POS, TW_Valid, EXP_BIAS-1,
  34                             0x2168c235, 0xc90fdaa2 };
  35 FPU_REG const CONST_LG2  = { SIGN_POS, TW_Valid, EXP_BIAS-2,
  36                             0xfbcff799, 0x9a209a84 };
  37 FPU_REG const CONST_LN2  = { SIGN_POS, TW_Valid, EXP_BIAS-1,
  38                             0xd1cf79ac, 0xb17217f7 };
  39 
  40 /* Extra bits to take pi/2 to more than 128 bits precision. */
  41 FPU_REG const CONST_PI2extra = { SIGN_NEG, TW_Valid, EXP_BIAS-66,
  42                             0xfc8f8cbb, 0xece675d1 };
  43 
  44 /* Only the sign (and tag) is used in internal zeroes */
  45 FPU_REG const CONST_Z    = { SIGN_POS, TW_Zero, EXP_UNDER, 0x0, 0x0 };
  46 
  47 /* Only the sign and significand (and tag) are used in internal NaNs */
  48 /* The 80486 never generates one of these 
  49 FPU_REG const CONST_SNAN = { SIGN_POS, TW_NaN, EXP_OVER, 0x00000001, 0x80000000 };
  50  */
  51 /* This is the real indefinite QNaN */
  52 FPU_REG const CONST_QNaN = { SIGN_NEG, TW_NaN, EXP_OVER, 0x00000000, 0xC0000000 };
  53 
  54 /* Only the sign (and tag) is used in internal infinities */
  55 FPU_REG const CONST_INF  = { SIGN_POS, TW_Infinity, EXP_OVER, 0x00000000, 0x80000000 };
  56 
  57 
  58 
  59 static void fld_const(FPU_REG const *c)
     /* [previous][next][first][last][top][bottom][index][help] */
  60 {
  61   FPU_REG *st_new_ptr;
  62 
  63   if ( STACK_OVERFLOW )
  64     {
  65       stack_overflow();
  66       return;
  67     }
  68   push();
  69   reg_move(c, FPU_st0_ptr);
  70   clear_C1();
  71 }
  72 
  73 
  74 static void fld1(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  75 {
  76   fld_const(&CONST_1);
  77 }
  78 
  79 static void fldl2t(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  80 {
  81   fld_const(&CONST_L2T);
  82 }
  83 
  84 static void fldl2e(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  85 {
  86   fld_const(&CONST_L2E);
  87 }
  88 
  89 static void fldpi(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  90 {
  91   fld_const(&CONST_PI);
  92 }
  93 
  94 static void fldlg2(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  95 {
  96   fld_const(&CONST_LG2);
  97 }
  98 
  99 static void fldln2(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 100 {
 101   fld_const(&CONST_LN2);
 102 }
 103 
 104 static void fldz(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 105 {
 106   fld_const(&CONST_Z);
 107 }
 108 
 109 static FUNC constants_table[] = {
 110   fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, FPU_illegal
 111 };
 112 
 113 void fconst(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 114 {
 115   (constants_table[FPU_rm])();
 116 }

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