root/kernel/FPU-emu/reg_mul.c

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

DEFINITIONS

This source file includes following definitions.
  1. reg_mul

   1 /*---------------------------------------------------------------------------+
   2  |  reg_mul.c                                                                |
   3  |                                                                           |
   4  | Multiply one FPU_REG by another, put the result in a destination FPU_REG. |
   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 /*---------------------------------------------------------------------------+
  14  | The destination may be any FPU_REG, including one of the source FPU_REGs. |
  15  +---------------------------------------------------------------------------*/
  16 
  17 #include "exception.h"
  18 #include "reg_constant.h"
  19 #include "fpu_emu.h"
  20 #include "fpu_system.h"
  21 
  22 
  23 /* This routine must be called with non-empty source registers */
  24 void reg_mul(FPU_REG *a, FPU_REG *b, FPU_REG *dest, unsigned int control_w)
     /* [previous][next][first][last][top][bottom][index][help] */
  25 {
  26   char sign = (a->sign ^ b->sign);
  27 
  28   if (!(a->tag | b->tag))
  29     {
  30       /* This should be the most common case */
  31       reg_u_mul(a, b, dest, control_w);
  32       dest->sign = sign;
  33       return;
  34     }
  35   else if ((a->tag <= TW_Zero) && (b->tag <= TW_Zero))
  36     {
  37 #ifdef DENORM_OPERAND
  38       if ( ((b->tag == TW_Valid) && (b->exp <= EXP_UNDER)) ||
  39           ((a->tag == TW_Valid) && (a->exp <= EXP_UNDER)) )
  40         {
  41           if ( denormal_operand() ) return;
  42         }
  43 #endif DENORM_OPERAND
  44       /* Must have either both arguments == zero, or
  45          one valid and the other zero.
  46          The result is therefore zero. */
  47       reg_move(&CONST_Z, dest);
  48 #ifdef PECULIAR_486
  49       /* The 80486 book says that the answer is +0, but a real
  50          80486 appears to behave this way... */
  51       dest->sign = sign;
  52 #endif PECULIAR_486
  53       return;
  54     }
  55 #if 0  /* TW_Denormal is not used yet... perhaps never will be. */
  56   else if ((a->tag <= TW_Denormal) && (b->tag <= TW_Denormal))
  57     {
  58       /* One or both arguments are de-normalized */
  59       /* Internal de-normalized numbers are not supported yet */
  60       EXCEPTION(EX_INTERNAL|0x105);
  61       reg_move(&CONST_Z, dest);
  62     }
  63 #endif
  64   else
  65     {
  66       /* Must have infinities, NaNs, etc */
  67       if ( (a->tag == TW_NaN) || (b->tag == TW_NaN) )
  68         { real_2op_NaN(a, b, dest); return; }
  69       else if (a->tag == TW_Infinity)
  70         {
  71           if (b->tag == TW_Zero)
  72             { arith_invalid(dest); return; }  /* Zero*Infinity is invalid */
  73           else
  74             {
  75 #ifdef DENORM_OPERAND
  76               if ( (b->tag == TW_Valid) && (b->exp <= EXP_UNDER) &&
  77                   denormal_operand() )
  78                 return;
  79 #endif DENORM_OPERAND
  80               reg_move(a, dest);
  81               dest->sign = sign;
  82             }
  83           return;
  84         }
  85       else if (b->tag == TW_Infinity)
  86         {
  87           if (a->tag == TW_Zero)
  88             { arith_invalid(dest); return; }  /* Zero*Infinity is invalid */
  89           else
  90             {
  91 #ifdef DENORM_OPERAND
  92               if ( (a->tag == TW_Valid) && (a->exp <= EXP_UNDER) &&
  93                   denormal_operand() )
  94                 return;
  95 #endif DENORM_OPERAND
  96               reg_move(b, dest);
  97               dest->sign = sign;
  98             }
  99           return;
 100         }
 101 #ifdef PARANOID
 102       else
 103         {
 104           EXCEPTION(EX_INTERNAL|0x102);
 105         }
 106 #endif PARANOID
 107     }
 108 }

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