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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Using</strong> <strong>the</strong> Inline and Embedded Assemblers of <strong>the</strong> <strong>ARM</strong> <strong>Compiler</strong><br />

7.5 Inline assembly language syntax with <strong>the</strong> asm keyword in C++<br />

When compiling C++, <strong>the</strong> compiler supports <strong>the</strong> asm syntax proposed in <strong>the</strong> ISO C++ Standard.<br />

You can specify inline assembler code using <strong>the</strong> following <strong>for</strong>mats:<br />

• On a single line, <strong>for</strong> example:<br />

asm("instruction[;instruction]");<br />

asm{instruction[;instruction]}<br />

You cannot include comments.<br />

• <strong>Using</strong> multiple adjacent strings, <strong>for</strong> example:<br />

asm("ADD x, x, #1\n"<br />

"MOV y, x\n");<br />

This enables you to use macros to generate inline assembly, <strong>for</strong> example:<br />

#define ADDLSL(x, y, shift) asm ("ADD " #x ", " #y ", LSL " #shift)<br />

• On multiple lines, <strong>for</strong> example:<br />

asm<br />

{<br />

...<br />

instruction<br />

...<br />

}<br />

You can use C or C++ comments anywhere in an inline assembly language block.<br />

You can use an asm statement wherever a statement is expected.<br />

7.5.1 See also<br />

Concepts<br />

• Inline assembler rules <strong>for</strong> compiler keywords __asm and asm on page 7-9<br />

• Inline assembler support in <strong>the</strong> compiler on page 7-5.<br />

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

ID061811<br />

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!