打印

请教kei uvision3 的一个错误

[复制链接]
1815|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
yioujie|  楼主 | 2010-12-10 20:27 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
沙发
gaohq| | 2010-12-10 21:15 | 只看该作者
这一句的前面那一句漏写了   ;

使用特权

评论回复
板凳
yioujie|  楼主 | 2010-12-11 07:51 | 只看该作者
Variables may be located at absolute memory locations in your C program

source modules using the _at_ keyword. The usage for this feature is:

type _memory_space_ variable_name _at_ constant;

where:

memory_space is the memory space for the variable. If missing from the

declaration, the default memory space is used. Refer to

“Memory Models” on page 94 for more information about

the default memory space.

type is the variable type.

variable_name is the variable name.

constant is the address at which to locate the variable.

The absolute address following _at_ must conform to the physical boundaries of

the memory space for the variable. The Cx51 compiler checks for invalid

address specifications.
这上面的用法没有分号啊,不过加了分号后不再报错,只是不知at函数用上没....

使用特权

评论回复
地板
yioujie|  楼主 | 2010-12-11 08:50 | 只看该作者
#include<reg52.h>
#define uchar unsigned char
加了这些的啊,我看网上别人绝对地址命令,也这样啊,真不懂。。。

使用特权

评论回复
5
yioujie|  楼主 | 2010-12-11 09:10 | 只看该作者
The _at_ Keyword
The _at_ keyword allows you to specify the address for uninitialized variables in your C source files. The following example demonstrates how to locate several different variable types using the _at_ keyword.

struct link  {
  struct link idata *next;
  char        code  *test;
};

struct link list idata _at_ 0x40;     /* list at idata 0x40 */
char xdata text[256]   _at_ 0xE000;   /* array at xdata 0xE000 */
int xdata i1           _at_ 0x8000;   /* int at xdata 0x8000 */

void main ( void ) {
  link.next = (void *) 0;
  i1        = 0x1234;
  text [0]  = 'a';
}

解决了,以上是keil 里的注释
我的问题是_at_后面的常量得空一格uchar idata sbuf[10] _at_ 0x50;
keil里的help还真是个好东西啊

使用特权

评论回复
6
airwill| | 2010-12-11 09:23 | 只看该作者
教训: 写代码要注意格式, 空格也不能随便丢.

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

87

帖子

0

粉丝