Init variable's memory content during comiple-link stage

Hello,

Some of the variables that my program uses(may contain also big ,multidimensional arrays) have default values, which are used during the code operations and may be modified during the program's runtime.

defining a variables using:

volatile xdata arrayName = [0x01, 0x03, 0x02, 0x04...];
Will case code generation that will occupy more then twice the size of the array. It will generate code are that will hold the array's default values, as well as code that in the beginning of the program startup will copy theses values into the arrays themselves.

On the other side, writing the code as follows:
volatile code arrayName = [0x01, 0x03, 0x02, 0x04...];

(Use of code area, instead of xdata area)

Will cause the array to be generated as part of the code.
There will not be any code line that will init the array into these values, and the init values will be directly located at the generated HEX file, at the place where the array is located, during the compile-link stage.
This is good since it saves time (of the variables init) and more important – it uses much less memory area.
The problem is that defining a variable as code, will prevent it from being modified.

My question:
Is there a way to define variables, that the init value of them will be located in the array's place during the compile-link stage, and that will be modifiable during the program runtime ? can you please tell me the syntax for such a declaration ?

Thanks.
Amit A.

Parents Reply Children
No data
More questions in this forum