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.

Compiler/TMS570LS1224: Assembler Usage Question

Part Number: TMS570LS1224


Tool/software: TI C/C++ Compiler

I'm full of questions today...

Here's another: I want to access a global variable declared in a C file from an assembly language file.

The variable, compmode, is declared as "uint32_t compmode" in a C file. I have the following assembler code:

 .ref  compmode            ; reference to a variable defined in C file

    .asmfunc
testmode
    ldr   r1,compmode      ; error occurs here!
    ldr   r1,[r1]
.
.
.

When this file gets assembled, I get an error "ERROR!   at line xx: [E0001] Address must be defined in the current section".

How do I fix this so it assembles correctly?

Thanks!

  • Hi Jerry,

    Since this is a question specifically about the assembler tools and CCS, I am going to move it to the CCS code gen tools forum. They will have a better perspective to provide more comprehensive answers to your questions about the compiler and assembler tools that are not specific to the Hercules device.
  • For those reading along, TMS570LS1224 is a Hercules with ARM Cortex-R4F

    The easiest way to resolve such things is to let the compiler do the work for you. Make a simple program:

    int compmode;
    int func() { return compmode; }

    let's see what the compiler does with this function:

    armcl  -k func.c -mv7r4 --embedded_constants=off
    func:
           MOVW      V9, compmode+0  
           MOVT      V9, compmode+0
           LDR       A1, [V9, #0]    
           BX        LR

    So the expected way to do what you want is with a MOVW/MOVT pair to get the address into a register.

    I confess that the embedded constants option is not obvious, but I think CCS sets this for you by default in a Cortex-R4F project.

  • That worked. Thanks! I'll have to remember the technique of looking at the assembly the C compiler generates.