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 />

when FPExc_Overflow enable = 10; cumul = 2;<br />

when FPExc_Underflow enable = 11; cumul = 3;<br />

when FPExc_Inexact enable = 12; cumul = 4;<br />

when FPExc_InputDenorm enable = 15; cumul = 7;<br />

if fpscr_val then<br />

IMPLEMENTATION_DEFINED floating-point trap h<strong>and</strong>ling;<br />

else<br />

FPSCR = ‘1’;<br />

return;<br />

The FPProcessNaN() function processes a NaN oper<strong>and</strong>, producing the correct result value <strong>and</strong> generating an<br />

Invalid Operation exception if necessary:<br />

// FPProcessNaN()<br />

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

//<br />

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

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

bits(N) FPProcessNaN(FPType type, bits(N) oper<strong>and</strong>, bits(32) fpscr_val)<br />

assert N == 32 || N == 64;<br />

topfrac = if N == 32 then 22 else 51;<br />

result = oper<strong>and</strong>;<br />

if type = FPType_SNaN then<br />

result = ‘1’;<br />

FPProcessException(FPExc_InvalidOp, fpscr_val);<br />

if fpscr_val == ‘1’ then // DefaultNaN requested<br />

result = FPDefaultNaN(N);<br />

return result;<br />

The FPProcessNaNs() function performs the st<strong>and</strong>ard NaN processing for a two-oper<strong>and</strong> operation:<br />

// FPProcessNaNs()<br />

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

//<br />

// The boolean part of the return value says whether a NaN has been found <strong>and</strong><br />

// processed. The bits(N) part is only relevant if it has <strong>and</strong> supplies the<br />

// result of the operation.<br />

//<br />

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

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

(boolean, bits(N)) FPProcessNaNs(FPType type1, FPType type2,<br />

bits(N) op1, bits(N) op2,<br />

bits(32) fpscr_val)<br />

assert N == 32 || N == 64;<br />

if type1 == FPType_SNaN then<br />

done = TRUE; result = FPProcessNaN(type1, op1, fpscr_val);<br />

elsif type2 == FPType_SNaN then<br />

done = TRUE; result = FPProcessNaN(type2, op2, fpscr_val);<br />

elsif type1 == FPType_QNaN then<br />

done = TRUE; result = FPProcessNaN(type1, op1, fpscr_val);<br />

elsif type2 == FPType_QNaN then<br />

done = TRUE; result = FPProcessNaN(type2, op2, fpscr_val);<br />

A2-50 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!