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.17 Expansion of inline assembler instructions that use constants<br />

The constant in an instruction with a constant operand is not limited to <strong>the</strong> values permitted by<br />

<strong>the</strong> instruction. Instead, <strong>the</strong> compiler translates <strong>the</strong> instruction into a sequence of instructions<br />

with <strong>the</strong> same effect. For example:<br />

ADD r0,r0,#1023<br />

might be translated into:<br />

ADD r0,r0,#1024 SUB r0,r0,#1<br />

Ano<strong>the</strong>r example of expansion possibility is:<br />

MOV rn,0x12345678<br />

With <strong>the</strong> exception of coprocessor instructions, all <strong>ARM</strong> instructions with a constant operand<br />

support instruction expansion. In addition, <strong>the</strong> MUL instruction can be expanded into a sequence<br />

of adds and shifts when <strong>the</strong> third operand is a constant.<br />

The effect of updating <strong>the</strong> CPSR by an expanded instruction is:<br />

• arithmetic instructions set <strong>the</strong> NZCV flags correctly<br />

• logical instructions:<br />

— set <strong>the</strong> NZ flags correctly<br />

— do not change <strong>the</strong> V flag<br />

— corrupt <strong>the</strong> C flag.<br />

7.17.1 See also<br />

Concepts<br />

• Inline assembler and instruction expansion in C and C++ code on page 7-21<br />

• <strong>Compiler</strong> support <strong>for</strong> inline assembly language on page 7-4.<br />

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

ID061811<br />

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!