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?

Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top