我混合使用C和ASM代码在STCubeIDE中编写STM32H745.
我有以下 struct 来确保在两个核心CM4和CM7之间共享的变量的严格排序:
struct miscSharedMemoryStruct {
volatile uint32_t triggerPtr;
volatile uint32_t bufferHead;
}
__attribute__((section(".sram3"))) struct miscSharedMemoryStruct miscSharedMemory;
第.sram3
节是在链接器脚本中定义的,在两个内核的C代码中访问我的变量效果很好.到现在为止还好.然而..
为了允许访问miscSharedMemory
个条目,我在ASM代码中将变量设置为全局:
.global miscSharedMemory
为了使汇编器能够识别正确的地址,我在头文件中添加了以下定义语句,其中定义了上面的 struct :
#define BUFFER_HEAD_ADR ((uintptr_t)(&miscSharedMemory.bufferHead))
最后,我们的 idea 是将上述地址中的数据放入ASM代码中的一个寄存器中:
ldr R1, =BUFFER_HEAD_ADR
但是,在编译我的代码时,我得到一个
未定义对‘BUFFER_HEAD_ADR’的引用
What is the correct way to make the assembler recognize the right address to my variable in the struct?我可能不需要做.global
语句,只要BUFFER_HEAD_ADR
中存储的地址是正确的,并被汇编程序识别,但我只是不知道如何让它工作.