04.01.2015 Views

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

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.

Compiler-specific Features<br />

Where:<br />

ptr<br />

points to the address of the data to be loaded from memory. To specify the<br />

type of the data to be loaded, cast the parameter to an appropriate pointer<br />

type.<br />

Table 4-8 Access widths supported by the __ldrex intrinsic<br />

Instruction Size of data loaded C cast<br />

LDREXB unsigned byte (unsigned char *)<br />

LDREXB signed byte (signed char *)<br />

LDREXH unsigned halfword (unsigned short *)<br />

LDREXH signed halfword (short *)<br />

LDREX word (int *)<br />

Return value<br />

The __ldrex intrinsic returns the data loaded from the memory address pointed to by<br />

ptr.<br />

Errors<br />

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

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

error in this case.<br />

The __ldrex intrinsic does not support access to doubleword data. The compiler<br />

generates an error if you specify an access width that is not supported.<br />

Example<br />

int foo(void)<br />

{<br />

int loc = 0xff;<br />

return __ldrex((volatile char *)loc);<br />

}<br />

Compiling this code with the command-line option --cpu=6k produces<br />

<strong>ARM</strong> DUI 0348C Copyright © 2007-2010 <strong>ARM</strong>. All rights reserved. 4-85<br />

ID101213<br />

Non-Confidential,

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

Saved successfully!

Ooh no, something went wrong!