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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Application Level Programmers’ Model<br />

elsif IsOnes(exp) then<br />

if IsZero(frac) then<br />

type = FPType_Infinity; value = 2^1000000;<br />

else<br />

type = if frac == ‘1’ then FPType_QNaN else FPType_SNaN;<br />

value = 0.0;<br />

else<br />

type = FPType_Nonzero; value = 2^(UInt(exp)-127) * (1.0 + UInt(frac) * 2^-23));<br />

else // N == 64<br />

sign = fpval;<br />

exp = fpval;<br />

frac = fpval;<br />

if IsZero(exp) then<br />

// Produce zero if value is zero or flush-to-zero is selected.<br />

if IsZero(frac) || fpscr_val == ‘1’ then<br />

type = FPType_Zero; value = 0.0;<br />

if !IsZero(frac) then // Denormalized input flushed to zero<br />

FPProcessException(FPExc_InputDenorm, fpscr_val);<br />

else<br />

type = FPType_Nonzero; value = 2^-1022 * (UInt(frac) * 2^-52);<br />

elsif IsOnes(exp) then<br />

if IsZero(frac) then<br />

type = FPType_Infinity; value = 2^1000000;<br />

else<br />

type = if frac == ‘1’ then FPType_QNaN else FPType_SNaN;<br />

value = 0.0;<br />

else<br />

type = FPType_Nonzero; value = 2^(UInt(exp)-1023) * (1.0 + UInt(frac) * 2^-52));<br />

if sign == ‘1’ then value = -value;<br />

return (type, sign, value);<br />

Floating-point exception <strong>and</strong> NaN h<strong>and</strong>ling<br />

The FPProcessException() procedure checks whether a floating-point exception is trapped, <strong>and</strong> h<strong>and</strong>les it<br />

accordingly:<br />

enumeration FPExc (FPExc_InvalidOp, FPExc_DivideByZero, FPExc_Overflow,<br />

FPExc_Underflow, FPExc_Inexact, FPExc_InputDenorm};<br />

// FPProcessException()<br />

// ====================<br />

//<br />

// The ‘fpscr_val’ argument supplies FPSCR control bits. Status information is<br />

// updated directly in the FPSCR where appropriate.<br />

FPProcessException(FPExc exception, bits(32) fpscr_val)<br />

// Get appropriate FPSCR bit numbers<br />

case exception of<br />

when FPExc_InvalidOp enable = 8; cumul = 0;<br />

when FPExc_DivideByZero enable = 9; cumul = 1;<br />

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

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

Saved successfully!

Ooh no, something went wrong!