<<<    Index    >>>
F-21
GUIDELINES FOR WRITING SIMD FLOATING-POINT EXCEPTION
      // overflow trap
      if (!(exc_env->exc_masks & OVERFLOW_MASK) &&  result_huge) {
        dbl_res24 = TWO_TO_M192 * dbl_res24; // exact
        exc_env->status_flag_overflow = 1;
        exc_env->exception_cause = OVERFLOW;
        exc_env->result_fval = (float)dbl_res24; // exact 
        if (sw & PRECISION_MASK) exc_env->status_flag_inexact = 1;
        return (RAISE_EXCEPTION);
      } 
      // set control word with rounding mode set to exc_env->rounding_mode, 
      // double precision, and all exceptions disabled
      cw = cw | 0x0200; // set precision to double
      __asm {
        fldcw WORD PTR cw;
      }
      switch (exc_env->operation) {
        case ADDPS:
        case ADDSS:
          // perform the addition
          __asm {
            // load input operands
            fld DWORD PTR opd1; // may set the denormal status flag
            fld DWORD PTR opd2; // may set the denormal status flag
            faddp st(1), st(0); // rounded to 53 bits, may set the inexact 
                                // status flag
            // store result
            fstp  QWORD PTR dbl_res; // exact, will not set any flag
          }
          break;
        case SUBPS:
        case SUBSS:
          // perform the subtraction
          __asm {
            // load input operands
            fld DWORD PTR opd1; // may set the denormal status flag
            fld DWORD PTR opd2; // may set the denormal status flag
            fsubp st(1), st(0); // rounded to 53 bits, may set the inexact
                                //  status flag
            // store result
            fstp  QWORD PTR dbl_res; // exact, will not set any flag
          }
          break;
<<<    Index    >>>