Keil Logo

C51: RET_XSTK DIRECTIVE


Information in this article applies to:

  • C51 Version 6.01

QUESTION

What does the RET_XSTK directive do?

ANSWER

The RET_XSTK directive causes the xdata reentrant stack to be used for return address. Normally, return addresses are stored on the 8051's hardware stack. This directive instructs the compiler to generate code that pops the return address from the hardware stack and stores it on the xdata reentrant stack.

You may use the RET_XSTK directive to unload return addresses from the on-chip (hardware) stack. This directive may be selectively used on the modules that contain the deepest stack nesting. If you use this directive, you must initilize the ?C_XBP reentrant stack pointer defined in the startup code.

The following example demonstrates the code generated to push and pop the return address on the pdata stack.

   1          #pragma RET_XSTK
   2          extern void func2 (void);
   3
   4          void func (void)  {
   5   1        func2 ();
   6   1      }

ASSEMBLY LISTING OF GENERATED OBJECT CODE
             ; FUNCTION func (BEGIN)
0000 120000      E     LCALL   ?C?CALL_XBP
                                     ; SOURCE LINE # 5
0003 120000      E     LCALL   func2
                                     ; SOURCE LINE # 6
0006 020000      E     LJMP    ?C?RET_XBP
             ; FUNCTION func (END)

SEE ALSO

FORUM THREADS

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

Last Reviewed: Monday, April 8, 2002


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.