This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Mixing C/ASM for CCS5.3 ARM Cortex-M4

Hi,

 How to get the address of a variable using ARM assembler?

;svar is defined in the main.c

The code below generate compiler error.

    .global svar

myfunc:  .asmfunc

      MOVW  R0,#svar

      MOVT   R0,#svar

       MOVW R0,#(svar & 0xFFFF)

       MOVT R0,#(svar >> 16)

       BX  LR

      ..endasmfunc

  

 

 

  • You create a const pointer in assembly.

      .ref    bUA_Expected
    pUA_Expect  .word   bUA_Expected

      LDR     R2,pUA_Expect

    ;R2 now contains the address of bUA_Expected

       LDRB    R2,[R2]

    ;R2 now contains the value of bUA_Expected