Search code examples
cembeddedinline-assemblygreenhills

How to use global variable in Inline Assembly in Greenhills Compiler?


I want to use a global variable in inline assembly.

asm(" LDR R0,g_TsInitStackPointerAddress");

Here g_TsInitStackPointerAddress is a global variable. While compiling its not showing any error .

But while linking it shows the following error

[elxr] (error) out of range: 0x1001326 (unsigned) didn't fit in 12 bits while performing relocation type R_ARM_POOL (4) at address 0x10013e0 from InitStack+0x20 (drv.o(.text)+0x1a4), to g_TsInitStackPointerAddress+0x0 ((COMMON)+0xb6)

Here My function name is InitStack and File name is drv. I am unable to understand the error.

Processor Used : Cortex R4
Compiler : Greenhills


Solution

  • Got the Solution

    __asm("g_TsInitStackPointerAddress_a: DCD g_TsInitStackPointerAddress ");

    Give this statement inside that function then it'll take that variable in the inline assembly