05.02.2013 Views

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Application Level Programmers’ Model<br />

// Underflow occurs if exponent is too small before rounding, <strong>and</strong> result is inexact or<br />

// the Underflow exception is trapped.<br />

if biased_exp == 0 && (error != 0.0 || fpscr_val == ‘1’) then<br />

FPProcessException(FPExc_Underflow, fpscr_val);<br />

// Round result according to rounding mode.<br />

case fpscr_val of<br />

when ‘00’ // Round to Nearest (rounding to even if exactly halfway)<br />

round_up = (error > 0.5 || (error == 0.5 && int_mant == ‘1’));<br />

overflow_to_inf = TRUE;<br />

when ‘01’ // Round towards Plus Infinity<br />

round_up = (error != 0.0 && sign == ‘0’);<br />

overflow_to_inf = (sign == ‘0’);<br />

when ‘10’ // Round towards Minus Infinity<br />

round_up = (error != 0.0 && sign == ‘1’);<br />

overflow_to_inf = (sign == ‘1’);<br />

when ‘11’ // Round towards Zero<br />

round_up = FALSE;<br />

overflow_to_inf = FALSE;<br />

if round_up then<br />

int_mant = int_mant + 1;<br />

if int_mant == 2^F then // Rounded up from denormalized to normalized<br />

biased_exp = 1;<br />

if int_mant == 2^(F+1) then // Rounded up to next exponent<br />

biased_exp = biased_exp + 1; int_mant = int_mant DIV 2;<br />

// Deal with overflow <strong>and</strong> generate result.<br />

if N != 16 || fpscr_val == ‘0’ then // Single, double or IEEE half precision<br />

if biased_exp >= 2^E - 1 then<br />

result = if overflow_to_inf then FPInfinity(sign, N) else FPMaxNormal(sign, N);<br />

FPProcessException(FPExc_Overflow, fpscr_val);<br />

else<br />

result = sign : biased_exp : int_mant;<br />

else // Alternative half precision<br />

if biased_exp >= 2^E then<br />

result = sign : Ones(15);<br />

FPProcessException(FPExc_InvalidOp, fpscr_val);<br />

error = 0.0; // avoid an Inexact exception<br />

else<br />

result = sign : biased_exp : int_mant;<br />

// Deal with Inexact exception.<br />

if error != 0 then<br />

FPProcessException(FPExc_Inexact, fpscr_val);<br />

return result;<br />

Selection of <strong>ARM</strong> st<strong>and</strong>ard floating-point arithmetic<br />

St<strong>and</strong>ardFPSCRValue is an FPSCR value that selects <strong>ARM</strong> st<strong>and</strong>ard floating-point arithmetic. Most of the<br />

arithmetic functions have a boolean fpscr_controlled argument that is TRUE for VFP operations <strong>and</strong> FALSE<br />

for Advanced SIMD operations, <strong>and</strong> that selects between using the real FPSCR value <strong>and</strong> this value.<br />

A2-52 Copyright © 1996-1998, 2000, 2004-2008 <strong>ARM</strong> Limited. All rights reserved. <strong>ARM</strong> DDI 0406B

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!