找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2048|回复: 4
收起左侧

请问code int nums[]={....};和int code nums[]={...}; 有区别吗

[复制链接]
ID:518902 发表于 2020-10-16 20:05 | 显示全部楼层 |阅读模式
大家好,我查到 code的意思是固化在rom里 ,我想: 那么应该是不可写了? 岂不是const了
由此想到了标题这个问题

不知道顺序的变化是否会影响代码,这里的num应该是个常量指针,不可改。。。

回复

使用道具 举报

ID:155507 发表于 2020-10-16 22:18 | 显示全部楼层
code 顺序的变化是不会影响代码的

  1. code

  2. The code memory type may be used for constants and functions. This memory is accessed using 16-bit addresses and may be on-chip or external.

  3. For constants (ROM variables), code memory is limited to 64K. Objects are limited to 64K and may not cross a 64K boundary. Constant variables declared code are located in the CODE memory class.
  4. For program code (functions), code memory is limited to 64K. Program functions are stored in the CODE memory class by default. The code memory type specifier is not required.
  5. Declare code objects as follows:

  6. unsigned char code code_constant;

  7. unsigned int func (void)
  8. {
  9.    return (0);
  10. }

  11. ============================================
  12. The Cx51 Compiler conforms to the ANSI definition of const objects.

  13. Variables declared with the const type qualifier alone are stored in the memory area (data, idata, xdata, and so on) associated with their definition.

  14. Variables you want to locate in ROM must be declared with the code memory type. For example:
  15. code char test[] = "This is a text string";

复制代码

回复

使用道具 举报

ID:518902 发表于 2020-10-16 22:56 | 显示全部楼层
angmall 发表于 2020-10-16 22:18
code 顺序的变化是不会影响代码的

哇塞! 这个文档看起来好像很厉害的样子 请问在哪里可以看到?
回复

使用道具 举报

ID:155507 发表于 2020-10-16 23:44 | 显示全部楼层
laopihappy123 发表于 2020-10-16 22:56
哇塞! 这个文档看起来好像很厉害的样子 请问在哪里可以看到?

这里
https://www.keil.com/support/man/docs/c51/c51_le_code.htm
回复

使用道具 举报

ID:518902 发表于 2020-10-17 00:08 | 显示全部楼层
angmall 发表于 2020-10-16 23:44
这里
https://www.keil.com/support/man/docs/c51/c51_le_code.htm

感恩大佬!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表