| |||
| Home > Using the Inline and Embedded Assemblers of the ARM Compiler > Differences between expressions in embedded assembler and C or C++ | |||
The following differences exist between embedded assembly and C or C++:
Assembler expressions are always unsigned. The same expression might have different values between assembler and C or C++. For example:
MOV r0, #(-33554432 / 2) // result is 0x7f000000MOV r0, #__cpp(-33554432 / 2) // result is 0xff000000
Assembler numbers with leading zeros are still decimal. For example:
MOV r0, #0700 // decimal 700MOV r0, #__cpp(0700) // octal 0700 == decimal 448
Assembler operator precedence differs from C and C++. For example:
MOV r0, #(0x23 :AND: 0xf + 1) // ((0x23 & 0xf) + 1) => 4MOV r0, #__cpp(0x23 & 0xf + 1) // (0x23 & (0xf + 1)) => 0
Assembler strings are not NUL-terminated:
DCB "Hello world!" // 12 bytes (no trailing NUL)DCB __cpp("Hello world!") // 13 bytes (trailing NUL)
The assembler rules apply outside __cpp,
and the C or C++ rules apply inside __cpp.