Keil Logo

RET_PSTK Compiler Directive

Abbreviation

RP

Arguments

None.

Default

None.

µVision

Options — C51 — Misc controls.

Description

The RET_PSTK directive instructs the compiler to use the pdata (Compact Model) reentrant stack for return addresses. Normally, return addresses are stored on the 8051's hardware stack. When this directive is specified the compiler generates code that pops the return address from the hardware stack and stores it on the reentrant stack. For example:

   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)

Note

  • You may use this directive to unload return addresses from the on-chip or hardware stack. It may be selectively used on modules that contain the deepest stack nesting.
  • If you use this directive you must initialize the reentrant stack pointer defined in the startup code. Refer to STARTUP.A51 for more information on how to initialize the reentrant stacks.
See Also

RET_XSTK

Example
C51 SAMPLE.C RET_PSTK
  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.