CCS编译器语句请教

2020-02-09 09:26发布

今天看别人的程序的时候 有几条不是很明白 语句是

#byte PORTA = 0x05
#byte PORTB = 0x06
#byte PORTC = 0x07
#byte OPTION = 0x81

我用的编译器是HI-TECH版的 上面的语句是基于CCS编译器的吧 哪位大侠指点下 谢谢啦
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
2条回答
piccode
1楼-- · 2020-02-09 11:13
Syntax:
#BYTE id = x

Elements:
id is a valid C identifier,
x is a C variable or a constant

Purpose:
If the id is already known as a C variable then this will locate the variable at address x.  In this case the variable type does not change from the original definition.  If the id is not known a new C variable is created and placed at address x with the type int (8 bit)

Warning: In both cases memory at x is not exclusive to this variable.  Other variables may be located at the same location.  In fact when x is a variable, then id and x share the same memory location.

Examples:
#byte  status = 3

#byte  b_port = 6


struct  {

  short int r_w;

  short int c_d;

   int unused : 2;

  int data    : 4 ; } a _port;

#byte a_port = 5

...

a_port.c_d = 1;
stevenxia
2楼-- · 2020-02-09 12:49
呵呵 恩 知道了 是定义PORTA B C的地址 datasheet看少了

一周热门 更多>