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

徘徊边缘 提交于 2019-12-13 04:58:39

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/11201410/how-to-use-global-variable-in-inline-assembly-in-greenhills-compiler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!