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.

MSP430F5436 CODE SPACE.

Other Parts Discussed in Thread: MSP430F5436

MSP430f5436 MICRO CODE SPACE

Can the msp430 compiler generate fully relocatable code for programs located above 64K in flash memory? We need a program linked to run in Bank 1 to be able to run in Bank 2 of main code memory.  Is there any way to tell the compiler or linker to use relative addressing only and not use 20-bit absolute addressing?

Thanks

 

  • I can speak for the IAR compiler.  It does not support generating Position Independent code for MSP430X.

    The customer may have to approach the problem in a different way.  Folks on this forum can help if you don't mind describing the problem.

    Jeff

  • Saeb Abdallah said:
    Can the msp430 compiler generate fully relocatable code for programs located above 64K in flash memory?

    Yes and no. First, there is no 'the MSP compiler'. There's CodeCompose, IAR and mspgcc. All three have different advantages and disadvantages.

    However, all three will produce fully relocatable code under some circumstances. However, you're responsible to maintain these circumstances:

    • the code may not call other relocatable functions by name (obviously), only by a pointer that is relocated
    • the code may not be called by name (obviously too), only by a relocated pointer.
    • You need to find a way to determine the size of the funciton
    • You may not use some optimizations, such as global subexpression elimination. Some compilers 'fuse' the tail of two funcitons when the code is idetical, or call common expressions as a subfunction from different functions. This happens only for functions in the same compilation unit (.c file) as these are usually treated as a more or less monolithic block when linked.
    • the code may not use any inplicit static constants, such as format strings in a printf statement. Some compilers put these constant string right behind the function and use relative addressing, some put them 'somewhere' and use absolute addressing. Unless you know what's going on, define golbal constants and use their pointer instead. The latter is no problem, but if relative addressign is used, the constants need to be moved together with the code. Without knowing th ememory map, this migh tbe difficult to automate.

    Saeb Abdallah said:
    Is there any way to tell the compiler or linker to use relative addressing only and not use 20-bit absolute addressing?

    No. The linker just fills-in what the compiler has generated. If the instruciton is a 20 bit instruction, then the linker will fill-in a 20 bit address. If it's an absooute instruciton, the linker fills an absolute address. For the compilers, there is no way to use relative addressing, as the relative position of a code relative to a relative positioned code is hard to determine :) On MSP, there is no default runtime-relocation code as it is on e.g. PC programs, and it doesn't make much sense on a system where code is executed directly form the storage area.

    Best way for relocatable code is writing the code in assembly language.

    In any case, you'll need some sort of startup code that does the relocation and generates a vector table, so the caller function konws where to find the called function.

    Can you explain in more detail what your problem is? Perhaps there is a different solution.

**Attention** This is a public forum