如何在Greenhills编译器的内联汇编中使用全局变量? [英] 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);
asm(" LDR R0,g_TsInitStackPointerAddress");
此处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 ](错误)超出范围:0x1001326(无符号)不适合12个
位,同时从InitStack + 0x20执行重定位类型R_ARM_POOL(4),地址为
0x10013e0(drv.o(.text) + 0x1a4)到
g_TsInitStackPointerAddress + 0x0((COMMON)+ 0xb6)
[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)
这里我的函数名是InitStack和File名字叫drv。我无法理解该错误。
Here My function name is InitStack and File name is drv. I am unable to understand the error.
使用的处理器:Cortex R4
编译器:Greenhills
Processor Used : Cortex R4
Compiler : Greenhills
推荐答案
解决方案
__ asm( g_TsInitStackPointerAddress_a:DCD g_TsInitStackPointerAddress) ;
__asm("g_TsInitStackPointerAddress_a: DCD g_TsInitStackPointerAddress ");
在该函数中提供此语句,然后将该变量放入内联汇编中
Give this statement inside that function then it'll take that variable in the inline assembly
这篇关于如何在Greenhills编译器的内联汇编中使用全局变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!