CX51 用户手册----RET_XSTK伪指令

来源:互联网 发布:李聪明 知乎 编辑:程序博客网 时间:2024/06/04 19:53

声明:

1、本翻译仅供个人学习使用,本人没有提供技术支持的义务,也不承担由此引发的任何后果。

2、请勿用于商业用途。

3、英文来自:http://www.keil.com/support/man/docs/c51/。

4、欢迎大家共同与我交流探讨(290207203@qq.com)。

RET_XSTK Compiler Directive

Abbreviation

RX

Arguments

None.

Default

None.

µVision

Options — C51 — Misc controls.

Description

The RET_XSTK directive instructs the compiler to use the xdata (Large 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_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 # 50003 120000      E     LCALL   func2                                     ; SOURCE LINE # 60006 020000      E     LJMP    ?C?RET_XBP             ; 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_PSTK

Example
C51 SAMPLE.C RET_XSTK



RET_XSTK 编译器伪指令

缩写

RX

参数

None.

缺省

None.

µVision

Options — C51 — Misc controls.

描述

RET_XSTK 伪指令告诉编译器对返回地址使用 xdata (Large 模型) 重入栈。一般情况下,返回地址保存在 8051硬件栈中。当指定这个伪指令时,编译器生成的代码从硬件栈中弹出返回地址,并保存到重入栈中。例如: 

   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 # 50003 120000      E     LCALL   func2                                     ; SOURCE LINE # 60006 020000      E     LJMP    ?C?RET_XBP             ; FUNCTION func (END)

 注意

  • 用户可以使用这个伪指令从片上或硬件栈中卸载返回地址。对包含深入嵌套栈的模块可以有选择地使用。
  • 如果用户使用这个伪指令,必须初始化定义在启动代码中的重入栈指针。如何初始化重入栈的更多信息,参考 STARTUP.A51 。
参考

RET_PSTK

示例
C51 SAMPLE.C RET_XSTK



原创粉丝点击