I am using Keil V7.07 C compiler. Problem Regarding Absolute Variable Initialization.
An Absolute Variable Can be defined as:
unsigned char code xyz _at_ 0xFE01;
A Normal Variable can be initialized as:
unsigned char code xyz = 76;
Is there any possibility that an absolute variable in code memory can be initialized ?? like
unsigned char code xyz _at_ 0xFE01 = 76; OR unsigned char code xyz = 76 _at_ 0xFE01;
Above both methods are wrong. On Page 104 (C51 Users Guide), it is clearly written that Absolute Variables cannot be initialized. Is there any other way to initialize absolute variables?
This is not just about the "definition" in the source language sense - it's about the complete specification form the overall system perspective.
In effect, you have a "partial" definition in the source code. That definition is sufficient to allow the code to access the variable, but is not sufficient to provide a complete definition from the overall system perspective - in particular, it doesn't tell you either that the specific location of this variable is important, nor what that location is.
Generally, it is "better" (in particular, easier to maintain), if everything about a particular "object" is defined in a single place...
This is not just about...
<Snip>
So, where *does* the variable definition reside?
Like I said, the complete definition is split between 2 places:
1. The source code - contains the type & initialisation;
2. The linker directives - set the specific location.
For this particular requirement, neither of these provides a complete definition at the overall system level.
Doing it in assembler could provide a single, complete definition.
I think you'll find that (1) contains all the imformation associated with any conventional interpretation of the expression 'variable definition'.
The location of a variable is quite dissociated from its definition no matter how you wish to try and dress it up. This all started with an assertion that:
Doing it with the linker, while perfectly legit, put (one) variable(s) outside the place where all other definitions reside.
To which I responded 'No it doesn't'. This seems to me to be a perfectly accurate correction.