ARM Technical Support Knowledge Articles

LOCATING THE STACK AFTER IDATA VARIABLES

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

I'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?

ANSWER

The 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

Article last edited on: 2005-07-18 16:56:49

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential