Hello
The linker allows you to specify memory area which should not be touched by the startup code.
So basically here you need to:
1- Define the variable in a user defined data segment.
For example:
#pragma DATA_SEG KeepData
int MyVar;
#pragma DATA_SEG DEFAULT
2- Make sure you are specifying the same section name in the variable declaration.
For example:
#pragma DATA_SEG KeepData
extern int MyVar;
#pragma DATA_SEG DEFAULT
3- In your .prm file define a memory area with attribute NO_INIT instead of READ_WRITE.
For Example:
SEGMENTS /* here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
Z_RAM = READ_WRITE 0x0050 TO 0x00FF;
RAM_NOINIT = NO_INIT 0x0100 TO 0x0101;
RAM = READ_WRITE 0x0102 TO 0x023F;
ROM = READ_ONLY 0xB000 TO 0xFDFF;
END
4- Place your section in the above defined memory area.
For example:
PLACEMENT
DEFAULT_ROM INTO ROM;
DEFAULT_RAM INTO RAM;
KeepData INTO RAM_NOINIT;
_DATA_ZEROPAGE, MY_ZEROPAGE INTO Z_RAM;
END
That should do it.
CrasyCat