29.12.2014 Views

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

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.

<strong>Compiler</strong>-specific Features<br />

Example<br />

int foo(void)<br />

{<br />

int loc=0xff;<br />

return(__swp(0x20, (volatile int *)loc));<br />

}<br />

Compiling this code produces<br />

||foo|| PROC<br />

MOV r1, #0xff<br />

MOV r0, #0x20<br />

SWP r0, r0, [r1]<br />

BX lr<br />

ENDP<br />

See also<br />

• SWP and SWPB on page 4-39 in the Assembler <strong>Guide</strong>.<br />

4.7.42 __usat<br />

This intrinsic inserts a USAT instruction into the instruction stream generated by the<br />

compiler. It enables you to saturate an unsigned value from within your C or C++ code.<br />

Syntax<br />

int __usat(unsigned int val, unsigned int sat)<br />

Where:<br />

val<br />

sat<br />

Is the value to be saturated.<br />

Is the bit position to saturate to.<br />

usat must be in the range 0 to 31.<br />

Return value<br />

The __usat intrinsic returns val saturated to the unsigned range 0 ≤ x ≤ 2 sat–1 –1.<br />

Errors<br />

The compiler does not recognize the __usat intrinsic when compiling for a target that<br />

does not support the USAT instruction. The compiler generates either a warning or an<br />

error in this case.<br />

<strong>ARM</strong> DUI 0348A Copyright © 2007, 2010 <strong>ARM</strong> Limited. All rights reserved. 4-93<br />

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!