29.10.2014 Views

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

<strong>Compiler</strong> Features<br />

4.11 Overflow and carry status flags <strong>for</strong> C and C++ code<br />

The implementation of <strong>the</strong> European Telecommunications Standards Institute (ETSI) basic<br />

operations in dspfns.h exposes <strong>the</strong> status flags Overflow and Carry. These flags are available as<br />

global variables <strong>for</strong> use in your own C or C++ programs. For example:<br />

#include /* include ETSI intrinsics */<br />

#include <br />

...<br />

const int BUFLEN=255;<br />

int a[BUFLEN], b[BUFLEN], c[BUFLEN];<br />

...<br />

Overflow = 0; /* clear overflow flag */<br />

<strong>for</strong> (i = 0; i < BUFLEN; ++i) {<br />

c[i] = L_add(a[i], b[i]); /* saturated add of a[i] and b[i] */<br />

}<br />

if (Overflow)<br />

{<br />

fprintf(stderr, "Overflow on saturated addition\n");<br />

}<br />

Generally, saturating functions have a sticky effect on overflow. That is, <strong>the</strong> overflow flag<br />

remains set until it is explicitly cleared.<br />

<strong>ARM</strong> DUI 0375C Copyright © 2007-2008, 2011 <strong>ARM</strong>. All rights reserved. 4-14<br />

ID061811<br />

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!