ia-32_volume1_basic-arch

Cw 0x043f round down single precision exceptions

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: E-29 GUIDELINES FOR WRITING SIMD FLOATING-POINT EXCEPTION HANDLERS ; // will never occur } // calculate result for the case an inexact trap has to be taken, or // when no trap occurs (second IEEE rounding) res = (float)dbl_res; // may set P, U or O; may also involve denormalizing the result // read status word __asm { fstsw WORD PTR sw; } // if inexact traps are enabled and result is inexact, take inexact trap if (!(exc_env->exc_masks & PRECISION_MASK) && ((sw & PRECISION_MASK) || (exc_env->ftz && result_tiny))) { exc_env->status_flag_inexact = 1; exc_env->exception_cause = INEXACT; if (result_tiny) { exc_env->status_flag_underflow = 1; // // // // if if ftz = 1 and result is tiny, result = 0.0 (no need to check for underflow traps disabled: result tiny and underflow traps enabled would have caused taking an underflow trap above) (exc_env->ftz) { if (res > 0.0) res = ZEROF; else if (res < 0.0) res = NZEROF; // else leave res unchanged } } if (result_huge) exc_env->status_flag_overflow = 1; exc_env->result_fval = res; return (RAISE_EXCEPTION); } // // // // // // // // // // // // if it got here, then there is no trap to be taken; the following must hold: ((the MXCSR U exceptions are disabled or the MXCSR underflow exceptions are enabled and the underflow flag is clear and (the inexact flag is set or the inexact flag is clear and the 24-bit result with unbounded exponent is not tiny))) and (the MXCSR overflow traps are disabled or the overflow flag is clear) and (the MXCSR inexact traps are disabled or the inexact flag is clear) in this case, the result has to be delivered (the status flags are sticky, so they are all set correctly already) E-30 Vol. 1 GUIDELINES FOR WRITING SIMD FLOATING-POINT EXCEPTION HANDLERS // read status word to see if result is inexact __asm { fstsw WORD PTR sw; } if (sw & UNDERFLOW_MASK) exc_env->status_flag_underflow = 1; if (sw & OVERFLOW_MASK) exc_env->status_flag_overflow = 1; if (sw & PRECISION_MASK) exc_env->status_flag_inexact = 1; // if ftz = 1, and result is tiny (underflow traps must be disabled), // result = 0.0 if (exc_env->ftz && result_tiny) { if (res > 0.0) res = ZEROF; else if (res < 0.0) res = NZEROF; // else leave res unchanged exc_env->status_flag_inexact = 1; exc_env->status_flag_underflow = 1; } exc_env->result_fval = res; if (sw & ZERODIVIDE_MASK) exc_env->status_flag_divide_by_zero = 1; if (sw & DENORMAL_MASK) exc_env->status_flag_denormal= 1; if (sw & INVALID_MASK) exc_env->status_flag_invalid_operation = 1; return (DO_NOT_RAISE_EXCEPTION); break; case CMPPS: case CMPSS: ... break; case COMISS: case UCOMISS: ... break; case CVTPI2PS: case CVTSI2SS: ... break; case CVTPS2PI: Vol. 1 E-31 GUIDELINES FOR WRITING SIMD FLOATING-POINT EXCEPTION HANDLERS case CVTSS2SI: case CVTTPS2PI: case CVTTSS2SI: ... break; case case case case ... break; case SQRTPS: case SQRTSS: ... break; ... case UNSPEC: ......
View Full Document

This note was uploaded on 10/01/2013 for the course CPE 103 taught by Professor Watlins during the Winter '11 term at Mississippi State.

Ask a homework question - tutors are online