ARM Technical Support Knowledge Articles

RET_PSTK DIRECTIVE

Applies to: C51 C Compiler

Answer


Information in this article applies to:


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 initilize 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

Article last edited on: 2002-04-08 00:00:00

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