This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM: Inline Assembly for LDR Rd,=const

Hi All,

I am using an ARM Cortex M4 MCU with an inline assembly code segment shown in the following code:

__asm {
      MOVS r0,#1;
      LSLS r0,r0,#9;
      STRH r0, [r1,#0x1a];
      LDR r2,=56000000;
 }


The LDR line is causing the error message: error #29: expected an expression.

I've tried replacing it with the MOVS opcode instead which appears to perform the operation of an LDR when converted to the generated assembly (.s file), as 32 bit's is outside the range for a MOVS instruction. The issue with this however, is that the generated assembly is inefficient:

        LDR      r0,|L1.128|
        MOVS     r6,r0
|L1.128|
        DCD      0x03567e00


There shouldn't be a move instruction there, that is an unnecessary instruction.

Any help would be greatly appreciated,
thanks.

0