This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Help me: how to determine constant value at link time?

In ASM51, the following code is every useful:


-------- file1.asm ---------
public MAX
MAX EQU 10

-------- file2.asm ---------
extrn number(MAX)
MOV	A,#MAX

The point is that the constant value of MAX in file2.asm can be determined at link time.

I want the same effect in C51, that's to say, to define a constant as "extern". I have tried a lot of ways. One of them is:

-------- file2.C -----------
extern code MAX;
#define MAX_NUMBER ((unsigned char)&MAX)

C51 is trying to treat MAX_NUMBER as a constant, but the compiled result is much longer than the original one. Is there any better way???

0