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.

C Pointer to assembly inline

Other Parts Discussed in Thread: MSP430F5529

Hi there,

I started to study some concepts about RTOS, and for that I started to write some code to help to understand.

I am using the MSP430F5529 LaunchPad and de Code Composer Studio V6 with the compiler TI V4.4.3.

The question is:  when I need to make a call to an assmbly instruction inline that I need to pass a memory address, I am getting
 a warning about relocation like this:

warning #17003-D: relocation to symbol "_main" overflowed; the 18-bit relocated address 0x23a21 is too large to encode in the 16-bit field (type = 'R_RELWORD' (16), file = "x.obj", offset = 0x00000000, section = ".data")

The code I am trying to use is this:

uInt16 *temp;

temp = stackPointer[currentTask];

asm("   mov.w temp, r1");

The warning ocurrs in the asm line, I execute the code and the value that is stored in the SP(r1) registes is 0xFFFF, no matter the real value in
 the C pointer.

Anybody had a problem like this?

Thank you all.

  • The TI MSP430 compiler does not support referring to local variables such as temp from within an asm statement.  In this particular case, it is likely that temp is allocated to a register.  There is no method for referring to that compiler allocated register from within the asm statement.  Please read further in the section titled Use Caution With asm Statements in Optimized Code of the MSP430 compiler manual.

    Thanks and regards,

    -George

  • Hi George,

    I am having simliar problem. I using cc26xxr2 lauchpad and CCS compiler. I am working OAD and need to jump to program entry point, which I get in some variable from BIM(Boot Image manager). For IAR compiler I am using following
    __asm volatile( "LDR R2, [%0]\n\t" :: "r" (entry));

    the entry is the pointer to the address the program needs to jump. But CCS I am getting compier error. Can you please suggest how I should do this CCS version 7.1.0.

    Thanks,
    Indra
  • Unfortunately, the TI compiler does not support the GCC-like __asm syntax like ...

    Indra Gauba56 said:
    __asm volatile( "LDR R2, [%0]\n\t" :: "r" (entry));

    Indra Gauba56 said:
    Can you please suggest how I should do this CCS version 7.1.0.

    Well, there is no method to directly emit code that loads the entry symbol into R2.  Is it OK to use a CALL instruction?  If so, you could write something like ...

    void entry(void); // declaration
                      // many lines later
        entry();      // call entry

    Thanks and regards,

    -George