| |||||
Technical Support Support Resources
Product Information | C51: LOCATING THE STACK AFTER IDATA VARIABLESInformation in this article applies to:
QUESTIONI'm using some idata variables in my program. I want to make sure that the stack doesn't overwrite them. What do I need to do? ANSWERThe following example program declares variables as you describe:
int idata var1;
int idata var2;
int idata var3;
void main (void)
{
}
When compiled and linked, the following Link Map is generated in the MAP file output by the linker. TYPE BASE LENGTH RELOCATION SEGMENT NAME ----------------------------------------------------- * * * * * * * D A T A M E M O R Y * * * * * * * REG 0000H 0008H ABSOLUTE "REG BANK 0" IDATA 0008H 0006H UNIT ?ID?MAIN IDATA 000EH 0001H UNIT ?STACK * * * * * * * C O D E M E M O R Y * * * * * * * CODE 0000H 0003H ABSOLUTE CODE 0003H 000CH UNIT ?C_C51STARTUP CODE 000FH 0001H UNIT ?PR?MAIN?MAIN Note that the idata variables declared come before the stack. The stack on the 8051 grows up. Therefore, there is nothing you must do to avoid overwriting your idata variables. SEE ALSO
Last Reviewed: Monday, July 18, 2005 | ||||
| |||||