Keil Logo

C51: CREATING A FIXED STACK SEGMENT


Information in this article applies to:

  • C51 All Versions

QUESTION

Is it possible to define a fixed stack location for the 8051's hardware stack?

ANSWER

Yes. The easiest way to do this is to modify the STARTUP code so the stack is an absolute segment at a fixed location. For example:

In the STARTUP code, change the following:

?STACK          SEGMENT   IDATA
                RSEG    ?STACK
                DS      100h-080h

to:

ISEG    AT      0xA0
?STACK: DS      0x100 - ?STACK

This creates an absolute segment for the stack. Then, you can change the 0xA0 to the address where you want the stack to reside. This has the advantage that if your C program variables overlap with the stack, the linker emits a warning.

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Saturday, May 1, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.