Accessing Assembly Constants in C Preprocessor

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello,

   

My firmware is mainly written in assembly with some c-functions included. To have several similiar products covered I use conditional source in assembly.

   

Now I need to use on condition as well in assembly as in  C, using the precompiler.But, it seems impossible to use a constant defined by "equ" in assembly in C-Code.

   

Is there a way to do that, or do I have to define the constant a second time in C-code using "#define"?

   

Thanks for any hints!

0 Likes
4 Replies
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

A partial answer......attached.

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

C and assembler can only commun icate via the linker to each other. So neither a #define in C nor an EQU in asm will be seen by the other.

   

 

   

Bob (feeling bad to spread bad news)

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Found this to be interesting -

   

 

   

http://www.psocdeveloper.com/forums/viewtopic.php?t=5679&f=45

   

 

   

Looks like you could use conditionals in C to effect asm, although that was not the

   

topic of the link.

   

 

   

Regards, Dana.

0 Likes
Rolf_Nooteboom
Level 5
Level 5
10 sign-ins 5 solutions authored First solution authored

 Depending on the compiler you use....

   

For HI-TECH, you should declare your variable in C like:

   

unsigned int   foo;

   

And use it in assembly using:

   

clr [_foo+1],7

   

rrc [_foo+1]

   

 

   

Regards,

   

Rolf

0 Likes