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

来源:互联网 发布:avi转gif软件 编辑:程序博客网 时间:2024/05/17 16:57

声明:

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

2、请勿用于商业用途。

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

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

STRING Compiler Directive

Abbreviation

None.

Arguments

)(CODE), (XDATA), or (FAR)

Default

STRING (CODE)

µVision

Options — C51 — Misc controls.

Description

The STRING directive specifies the memory type used for implicit strings. By default, implicit strings are located in code memory. For example:

void main (void) {  printf ("hello world\n");}

in this example, the string "hello world" is located in code memory.

The STRING directive changes the default location for implicitly located strings. This directive must be used carefully, since existing programs might use memory typed pointers to access strings.

One good reason to consider changing the default location of implicit strings (to thexdata or far memory areas) to avoid using code banking. This directive is useful especially for extended 8051 devices like the NXP 80C51MX.

OptionDescriptionCODEImplicit strings are located in code space. This is the default setting of theCx51 Compiler.XDATAImplicit strings are located in const xdata space.FARImplicit strings are located in const far space.

 Note

  • The XDATA and FAR options require that you use the OMF2 directive.
See Also

XCROM

Example
C51 SAMPLE.C STRING (XDATA)#pragma STRING (FAR)

 Related Knowledgebase Articles

  • C51: MEMORY CLASSES FOR STRINGS AND STRING POINTERS
  • C51: CODE STRINGS IN STRUCTS ARE NOT MERGED
  • C51: ADDRESS SPACE OVERFLOW WITH FAR CONST
  • C51: LOCATING VARIABLES TO FAR CONST SPACE


STRING 编译器伪指令

缩写

无。

参数

)(CODE), (XDATA), or (FAR)

缺省

STRING (CODE)

µVision

Options — C51 — Misc controls.

描述

STRING 伪指令指定隐式串的存储器类型。缺省情况下,隐式串定位在code存储器。例如:

void main (void) {  printf ("hello world\n");}

在这个示例中, "hello world"存储器定位在code存储器。

STRING 伪指令改变隐式串的定位位置。使用这个伪指令必须小心,因为已存在的程序可能使用指定存储器类型的指针访问串。 

考虑改变隐式串的缺省位置 (到xdata 或 far 存储器区域) 的好处时避免使用代码分组。 象NXP 80C51MX这样的扩展8051器件,这个伪指令非常有用。

选项描述CODE隐式串定位在code 空间。这是Cx51编译器的缺省设置。XDATA隐式串定义在 const xdata 空间。FAR隐式串定位在const far 空间。

 这样

  • XDATA 和 FAR 选项需要用户使用 OMF2 伪指令。
参考

XCROM

示例
C51 SAMPLE.C STRING (XDATA)#pragma STRING (FAR)

 相关知识库标题

  • C51: MEMORY CLASSES FOR STRINGS AND STRING POINTERS
  • C51: CODE STRINGS IN STRUCTS ARE NOT MERGED
  • C51: ADDRESS SPACE OVERFLOW WITH FAR CONST
  • C51: LOCATING VARIABLES TO FAR CONST SPACE



原创粉丝点击