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

Create successful ePaper yourself

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

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

Example<br />

typedef struct s_foo { int i; short j; } foo;<br />

typedef __packed struct s_bar { int i; short j; } bar;<br />

return __ALIGNOF(struct s_foo); // returns 4<br />

return __ALIGNOF(foo); // returns 4<br />

return __ALIGNOF(bar); // returns 1<br />

See also<br />

• __alignof__ on page 4-3.<br />

4.1.4 __asm<br />

This keyword is used to pass information from the compiler to the <strong>ARM</strong> assembler<br />

armasm.<br />

The precise action of this keyword depends on its usage.<br />

Usage<br />

Embedded assembler<br />

The __asm keyword can be used to declare or define an embedded<br />

assembly function. For example:<br />

__asm void my_strcpy(const char *src, char *dst);<br />

See Embedded assembler on page 6-17 in the <strong>Compiler</strong> User <strong>Guide</strong> for<br />

more information.<br />

Inline assembler<br />

The __asm keyword can be used to incorporate inline assembly into a<br />

function. For example:<br />

int qadd(int i, int j)<br />

{<br />

int res;<br />

__asm<br />

{<br />

QADD res, i, j<br />

}<br />

return res;<br />

}<br />

SeeInline assembler on page 6-2 in the <strong>Compiler</strong> User <strong>Guide</strong> for more<br />

information.<br />

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

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!