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   if (!(a->tag | b->tag))
  27     {
  28       /* This should be the most common case */
  29       dest->sign = (a->sign ^ b->sign);
  30       reg_u_mul(a, b, dest, control_w);
  31       dest->exp += - EXP_BIAS + 1;
  32 /*      dest->tag = TW_Valid; ****** */
  33       if ( dest->exp <= EXP_UNDER )
  34         { arith_underflow(FPU_st0_ptr); }
  35       else if ( dest->exp >= EXP_OVER )
  36         { arith_overflow(FPU_st0_ptr); }
  37       return;
  38     }
  39   else if ((a->tag <= TW_Zero) && (b->tag <= TW_Zero))
  40     {
  41       /* Must have either both arguments == zero, or
  42          one valid and the other zero.
  43          The result is therefore zero. */
  44       reg_move(&CONST_Z, dest);
  45     }
  46   else if ((a->tag <= TW_Denormal) && (b->tag <= TW_Denormal))
  47     {
  48       /* One or both arguments are de-normalized */
  49       /* Internal de-normalized numbers are not supported yet */
  50       EXCEPTION(EX_INTERNAL|0x105);
  51       reg_move(&CONST_Z, dest);
  52     }
  53   else
  54     {
  55       /* Must have infinities, NaNs, etc */
  56       if ( (a->tag == TW_NaN) || (b->tag == TW_NaN) )
  57         { real_2op_NaN(a, b, dest); return; }
  58       else if (a->tag == TW_Infinity)
  59         {
  60           if (b->tag == TW_Zero)
  61             { arith_invalid(dest); return; }
  62           else
  63             {
  64               reg_move(a, dest);
  65               dest->sign = a->sign == b->sign ? SIGN_POS : SIGN_NEG;
  66             }
  67         }
  68       else if (b->tag == TW_Infinity)
  69         {
  70           if (a->tag == TW_Zero)
  71             { arith_invalid(dest); return; }
  72           else
  73             {
  74               reg_move(b, dest);
  75               dest->sign = a->sign == b->sign ? SIGN_POS : SIGN_NEG;
  76             }
  77         }
  78 #ifdef PARANOID
  79       else
  80         {
  81           EXCEPTION(EX_INTERNAL|0x102);
  82         }
  83 #endif PARANOID
  84       dest->sign = (a->sign ^ b->sign);
  85     }
  86 }

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