网上找了之后有各种说法,我做如下总结,转载请注明出处:
1、The XBYTE macro accesses individual bytes in the
external data memory of the 8051. You may use this macro in your
programs as follows:
#include
.
.
.
rval = XBYTE [0x0002];
XBYTE [0x0002] = 57;
.
.
.
This example reads and writes the contents of the byte in
external data memory at address 0002h.
The range of valid index values for this macro is 0-65535.
(以上为官方定义)
2、在中的定义是
#define XBYTE ((unsigned
char volatile xdata *) 0)
可以使用XBYTE去访问外部的RAM,也可以用XBYTE去访问扩展的I/0设备
注意:这里是利用的英特尔总线进行访问的,那么就会有时序的问题,在C语言中,这些都帮你做完了,所以无需考虑
3、关于I/O的控制如下,低字节表示的是P0端口,高字节表示的是P2端口。P2端口通常作为控制端口,而P0通常作为数据端口
eg:XBYTE[0x8800] =
buz_stu;
其中用P2做控制,P0的数据就是buz_stu的状态