分类: C/C++
2010-06-02 17:06:32
Keil C 位变量外部引用的方法:具体可以参考keil 的help.
1.变量定义在可位寻址区:
int bdata ibase; /* Bit-addressable int */
char bdata bary [4]; /* Bit-addressable array */
2.在位字节的基础上定义位变量:
sbit mybit0 = ibase ^ 0; /* bit 0 of ibase */
sbit mybit15 = ibase ^ 15; /* bit 15 of ibase */
sbit Ary07 = bary[0] ^ 7; /* bit 7 of bary[0] */
sbit Ary37 = bary[3] ^ 7; /* bit 7 of bary[3] */
3.其它的文件引用位变量:extern bit mybit0; /* bit 0 of ibase */
extern bit mybit15; /* bit 15 of ibase */
extern bit Ary07; /* bit 7 of bary[0] */
extern bit Ary37; /* bit 7 of bary[3] */
4.对位变量操作:Ary37 = 0; /* clear bit 7 in bary[3] */
bary[3] = 'a'; /* Byte addressing */
ibase = -1; /* Word addressing */
mybit15 = 1; /* set bit 15 in ibase */
结束。