51單片機(jī)keilC中頭文件absacc.h作用
在程序中,用“#include”即可使用其中定義的宏來訪問絕對(duì)地址,包括:CBYTE、XBYTE、PWORD、DBYTE、CWORD、XWORD、PBYTE、DWORD
本文引用地址:http://m.butianyuan.cn/article/201611/321017.htm例如:
rval=CBYTE[0x0002];指向程序存貯器的0002h地址
rval=XWORD [0x0002];指向外RAM的0004h地址
KEIL 中ABSACC.H 定義如下:
#ifndef __ABSACC_H__
#define __ABSACC_H__
#define CBYTE ((unsigned char volatile code *) 0)
#define DBYTE ((unsigned char volatile data *) 0)
#define PBYTE ((unsigned char volatile pdata *) 0)
#define XBYTE ((unsigned char volatile xdata *) 0)
#define CWORD ((unsigned int volatile code *) 0)
#define DWORD ((unsigned int volatile data *) 0)
#define PWORD ((unsigned int volatile pdata *) 0)
#define XWORD ((unsigned int volatile xdata *) 0)
#ifdef __CX51__
#define FVAR(object, addr)
#define FARRAY(object, base) ((object volatile far *) (base))
#define FCVAR(object, addr)
#define FCARRAY(object, base) ((object const far *) (base))
#else
#define FVAR(object, addr)
#define FCVAR(object, addr)
#define FARRAY(object, base) ((object volatile far *) ((base)+0x10000L))
#define FCARRAY(object, base) ((object const far *) ((base)+0x810000L))
#endif
#endif
再如:
#define COM8255 XBYTE[0X060FF]
#define PA8255 XBYTE[0X000FF]
#define PB8255 XBYTE[0X020FF]
#define PC8255 XBYTE[0X040FF]
評(píng)論