Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top