Is there any way to declare a symbolic constant as 'an external number' in Keil C51 source code so that the compiler generates object file using instructions with # symbol prefix (e.g. mov r0,#symbol) and therefore the value of this symbol can be supplied on the linker level (from another obj file, where the symbol is given a value and declared as public) ? (Including file with #defines into the source code does not solve the issue - symbols must be defined at the compile time.) Note: in assembler it is easy ... file1.a51 : (file1.obj defines particular values of needed constants for a concrete project)
... public SYMBOL SYMBOL equ 5 ...
... extrn number (SYMBOL) ... mov a,#SYMBOL ...
extern char idata* c; #define symbol_c ( (char)(&c) ) This will work if you can create 'c' at a specific address in another module. How do you do this in C? I think you could create a separate module for each variable and use the section/class controls of the linker to put it in a phantom RAM location but it would be confusing, hard to document and maintain. Is there another way? Thanks