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.

St<strong>and</strong>ardFPSCRValue()<br />

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

bits(32) St<strong>and</strong>ardFPSCRValue()<br />

return ‘00000’ : FPSCR : ‘11000000000000000000000000’;<br />

Comparisons<br />

Application Level Programmers’ Model<br />

The FPCompare() function compares two floating-point numbers, producing an (N,Z,C,V) flags result as<br />

shown in Table A2-8:<br />

This result is used to define the VCMP instruction in the VFP extension. The VCMP instruction writes these flag<br />

values in the FPSCR. After using a VMRS instruction to transfer them to the APSR, they can be used to control<br />

conditional execution as shown in Table A8-1 on page A8-8.<br />

// FPCompare()<br />

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

Table A2-8 VFP comparison flag values<br />

Comparison result N Z C V<br />

Equal 0 1 1 0<br />

Less than 1 0 0 0<br />

Greater than 0 0 1 0<br />

Unordered 0 0 1 1<br />

(bit, bit, bit, bit) FPCompare(bits(N) op1, bits(N) op2, boolean quiet_nan_exc,<br />

boolean fpscr_controlled)<br />

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

fpscr_val = if fpscr_controlled then FPSCR else St<strong>and</strong>ardFPSCRValue();<br />

(type1,sign1,value1) = FPUnpack(op1, fpscr_val);<br />

(type2,sign2,value2) = FPUnpack(op2, fpscr_val);<br />

if type1==FPType_SNaN || type1==FPType_QNaN || type2==FPType_SNaN || type2==FPType_QNaN then<br />

result = (‘0’,’0’,’1’,’1’);<br />

if type1==FPType_SNaN || type2==FPType_SNaN || quiet_nan_exc then<br />

FPProcessException(FPExc_InvalidOp, fpscr_val);<br />

else<br />

// All non-NaN cases can be evaluated on the values produced by FPUnpack()<br />

if value1 == value2 then<br />

result = (‘0’,’1’,’1’,’0’);<br />

elsif value1 < value2 then<br />

result = (‘1’,’0’,’0’,’0’);<br />

else // value1 > value2<br />

result = (‘0’,’0’,’1’,’0’);<br />

return result;<br />

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

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

Saved successfully!

Ooh no, something went wrong!