質問

I have the following asm code that gets linked into my cpp project:

Some_Variable EQU 0x0F00F0F0
...

Now I would like to access Some_Variable from C code. I was not lucky with extern uint32_t Some_Variable. How do you exactly do this? Is this even possible?

役に立ちましたか?

解決

One way to do this is indeed using variable that has constant value assigned to it. Not sure about your assembler but for nasm you can do the following:

Some_Variable equ 0x0F00F0F0

global _somevar
_somevar dd Some_Variable

And then in C:

extern int somevar

Most assemblers have similar keywords so I hope this helps.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top