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.

MSP430F5529: Calling C function from assembler #17003-D

Part Number: MSP430F5529

I'm trying to port FunkOS from F2xx series to F5xx series and I came upon an warning #17003-D. The size of the code is about 1.5kB and RAM usage is 547B. The warning message is:
"../port/MSP430_CC/F2xx/taskportasm.asm", line 69: warning #17003-D: relocation from assembly code range "$../port/MSP430_CC/F2xx/taskportasm.asm:68:84$" to symbol "Task_SetScheduler" overflowed; the 17-bit relocated address 0x1057c is too large to encode in the 16-bit field (type = 'R_MSP430X_ABS16' (15), file = "./port/MSP430_CC/F2xx/taskportasm.obj", offset = 0x00000004, section = ".text")
I can't understand where the 17-bit address 0x1057c comes from since the code is only 1.5kB. Can you help me with this code ot give me a hint how I can call the C function from assembler in a way that will not produce this warning?

I searched the forum and one thng that I found was to change processor options --near_data to none. This did not help

Here is my project:

spFunkOS(1).zip

  • Ok, I think I know what is going on here. MSP430F5529 has two program sections. One is FLASH : origin = 0x4400, length = 0xBB80 and another is FLASH2 : origin = 0x10000,length = 0x143F8. How can I force the linker to put all of my code to FLASH so I can fit in 16 bytes?

  • I can't understand where the 17-bit address 0x1057c comes from since the code is only 1.5kB.

    The MSP430F5529 has a CPUXV2 with 20-bit registers and 128K of flash, some of which have an address >= 64 KB.

    The lnk_msp430f5529.cmd linker command file allows the placement of code at addresses >= 64 KB in the FLASH2 memory region when the code memory model is set to large.

    Can you help me with this code ot give me a hint how I can call the C function from assembler in a way that will not produce this warning?

    Setting the code and data model both to small will mean only flash in the lower 64 KB is used:

    Since the FunkOS taskportasm.asm had been written for a msp (16-bit) rather than mspx (20-bit) CPU the assembler is only saving 16-bit registers. To be on the safe side think the C compiler should also set the silicon version to msp.

    A longer term fix could be change FunkOS to support the mspx CPU.

  • Thank you Chester! This is exactly what I need. I'm not so familiar with assembly - are there any tricks to save  the 20-bit registers?

  • It appears that the code you are using uses the old one register saved per instruction. So your first step would be to use the CPUX extension that lets you move multiple registers with a single instruction. Saves space and time. pushm defaults to moving word data unless you tell it otherwise with pushm.a. That of course will take twice as much time to save a register so don't do it unless you have to.

    All described in detail in the documentation.

**Attention** This is a public forum