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.

ARM Compiler and Immediate Adressing Mode instructions: incorrect base register value

Other Parts Discussed in Thread: TMS570LS3137

Hi,

I'm working with a TMS570LS3137 with the TI ARM Compiler v5.1.1.

When turning on the optimization flags "-o=4" and "-mf=5" at the same time,
the compiler generates assembly instructions that use Immediate Addressing relative to
a base register to access system registers.

For example when I try to write a value to systemREG1->PLLCTL1, the compiler generates:

0000536c:   E307C700 MOVW            R12, #30464
00005370:   E342C005 MOVT             R12, #8197
00005374:   E584CF8B STR               R12, [R4, #3979]

The value of R12 is irrelevant in this case.
The address of PLLCTL1 is 0xFFFF'FF70,
so the value in R4, which is used as the base register should be 0xFFFF'EFE5 (0xFFFF'EFE5+3979 = 0xFFFF'FF70) to get the correct result.
However, R4 is not loaded with that value automatically, but is left unchanged at the value it was initialized with in the startup code (in this case 0).

My question is:
Why is the compiler not generating an instruction to set up the base register correctly?
Is there a special mechanism needed to load R4 with the correct value?

Any help would be greatly appreciated.

Thanks very much,
Johannes

  • Johannes Krimmel said:
    Is there a special mechanism needed to load R4 with the correct value?

    No.

    Johannes Krimmel said:
    Why is the compiler not generating an instruction to set up the base register correctly?

    I don't know.  I need to build a test case which allows me to see this for myself.  Please preprocess the function which generates this code and attach it to your next post.  I also need to see all of the compiler options exactly as the compiler sees them.

    Thanks and regards,

    -George

  • Hello George,

    thanks for the clarification that there's no special mechanism needed.

    It turned out that the problem has been caused by inline assembly code that was overwriting the base address value in R4 that i haven't noticed.

    Best regards,

    Johannes