Keil Logo

C51: RET_PSTK Directive


Information in this article applies to:

  • C51 Version 6.01 and later

QUESTION

What does the RET_PSTK directive do?

ANSWER

The RET_PSTK directive causes the pdata 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 pdata reentrant stack.

You may use the RET_PSTK 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 initialize the ?C_PBP 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_PSTK
   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_PBP
                                     ; SOURCE LINE # 5
0003 120000      E     LCALL   func2
                                     ; SOURCE LINE # 6
0006 020000      E     LJMP    ?C?RET_PBP
             ; FUNCTION func (END)

SEE ALSO


Last Reviewed: Thursday, February 25, 2021


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.