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

Create successful ePaper yourself

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

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

7.37 Differences between expressions in embedded assembler and C or C++<br />

The following differences exist between embedded assembly and C or C++:<br />

• Assembler expressions are always unsigned. The same expression might have different<br />

values between assembler and C or C++. For example:<br />

MOV r0, #(-33554432 / 2) // result is 0x7f000000 MOV r0, #__cpp(-33554432 /<br />

2) // result is 0xff000000<br />

• Assembler numbers with leading zeros are still decimal. For example:<br />

MOV r0, #0700 // decimal 700 MOV r0, #__cpp(0700) //<br />

octal 0700 == decimal 448<br />

• Assembler operator precedence differs from C and C++. For example:<br />

MOV r0, #(0x23 :AND: 0xf + 1) // ((0x23 & 0xf) + 1) => 4 MOV r0, #__cpp(0x23 &<br />

0xf + 1) // (0x23 & (0xf + 1)) => 0<br />

• Assembler strings are not NUL-terminated:<br />

DCB "Hello world!"<br />

// 12 bytes (no trailing NUL) DCB __cpp("Hello<br />

world!")<br />

// 13 bytes (trailing NUL)<br />

Note<br />

The assembler rules apply outside __cpp, and <strong>the</strong> C or C++ rules apply inside __cpp.<br />

7.37.1 See also<br />

Concepts<br />

• Access to C and C++ compile-time constant expressions from embedded assembler on<br />

page 7-43<br />

• <strong>Compiler</strong> support <strong>for</strong> embedded assembler on page 7-36.<br />

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

ID061811<br />

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!