reg52.h文件内容
时间: 2023-09-17 14:06:38 浏览: 378
reg52.h是Keil C51编译器中的一个头文件,用于定义与8051单片机寄存器相关的常量、宏和函数等,其内容如下:
```c
/* 8051 SFR declarations */
__sfr __at (0x80) P0;
__sfr __at (0x81) SP;
__sfr __at (0x82) DPL;
__sfr __at (0x83) DPH;
__sfr __at (0x87) PCON;
__sfr __at (0x88) TCON;
__sfr __at (0x89) TMOD;
__sfr __at (0x8A) TL0;
__sfr __at (0x8B) TL1;
__sfr __at (0x8C) TH0;
__sfr __at (0x8D) TH1;
__sfr __at (0x90) P1;
__sfr __at (0x98) SCON;
__sfr __at (0x99) SBUF;
__sfr __at (0xA0) P2;
__sfr __at (0xA8) IE;
__sfr __at (0xB0) P3;
__sfr __at (0xB8) IP;
__sfr __at (0xD0) PSW;
__sfr __at (0xE0) ACC;
__sfr __at (0xF0) B;
/* 8052 SFR declarations */
__sfr __at (0x81) SP;
__sfr __at (0x82) DPL;
__sfr __at (0x83) DPH;
__sfr __at (0x87) PCON;
__sfr __at (0x88) TCON;
__sfr __at (0x89) TMOD;
__sfr __at (0x8A) TL0;
__sfr __at (0x8B) TL1;
__sfr __at (0x8C) TH0;
__sfr __at (0x8D) TH1;
__sfr __at (0x90) P1;
__sfr __at (0x98) SCON;
__sfr __at (0x99) SBUF;
__sfr __at (0xA0) P2;
__sfr __at (0xA8) IE;
__sfr __at (0xB0) P3;
__sfr __at (0xB8) IP;
__sfr __at (0xD0) PSW;
__sfr __at (0xE0) ACC;
__sfr __at (0xF0) B;
/* 8051 Bit addressable SFR declarations */
__sbit __at (0x80+0) P0_0;
__sbit __at (0x80+1) P0_1;
__sbit __at (0x80+2) P0_2;
__sbit __at (0x80+3) P0_3;
__sbit __at (0x80+4) P0_4;
__sbit __at (0x80+5) P0_5;
__sbit __at (0x80+6) P0_6;
__sbit __at (0x80+7) P0_7;
__sbit __at (0x90+0) P1_0;
__sbit __at (0x90+1) P1_1;
__sbit __at (0x90+2) P1_2;
__sbit __at (0x90+3) P1_3;
__sbit __at (0x90+4) P1_4;
__sbit __at (0x90+5) P1_5;
__sbit __at (0x90+6) P1_6;
__sbit __at (0x90+7) P1_7;
__sbit __at (0xA0+0) P2_0;
__sbit __at (0xA0+1) P2_1;
__sbit __at (0xA0+2) P2_2;
__sbit __at (0xA0+3) P2_3;
__sbit __at (0xA0+4) P2_4;
__sbit __at (0xA0+5) P2_5;
__sbit __at (0xA0+6) P2_6;
__sbit __at (0xA0+7) P2_7;
__sbit __at (0xB0+0) P3_0;
__sbit __at (0xB0+1) P3_1;
__sbit __at (0xB0+2) P3_2;
__sbit __at (0xB0+3) P3_3;
__sbit __at (0xB0+4) P3_4;
__sbit __at (0xB0+5) P3_5;
__sbit __at (0xB0+6) P3_6;
__sbit __at (0xB0+7) P3_7;
__sbit __at (0xD0+0) CY;
__sbit __at (0xD0+1) AC;
__sbit __at (0xD0+2) F0;
__sbit __at (0xD0+3) RS1;
__sbit __at (0xD0+4) RS0;
__sbit __at (0xD0+5) OV;
__sbit __at (0xD0+6) F1;
__sbit __at (0xD0+7) P;
/* 8052 Bit addressable SFR declarations */
__sbit __at (0x80+0) P0_0;
__sbit __at (0x80+1) P0_1;
__sbit __at (0x80+2) P0_2;
__sbit __at (0x80+3) P0_3;
__sbit __at (0x80+4) P0_4;
__sbit __at (0x80+5) P0_5;
__sbit __at (0x80+6) P0_6;
__sbit __at (0x80+7) P0_7;
__sbit __at (0x90+0) P1_0;
__sbit __at (0x90+1) P1_1;
__sbit __at (0x90+2) P1_2;
__sbit __at (0x90+3) P1_3;
__sbit __at (0x90+4) P1_4;
__sbit __at (0x90+5) P1_5;
__sbit __at (0x90+6) P1_6;
__sbit __at (0x90+7) P1_7;
__sbit __at (0xA0+0) P2_0;
__sbit __at (0xA0+1) P2_1;
__sbit __at (0xA0+2) P2_2;
__sbit __at (0xA0+3) P2_3;
__sbit __at (0xA0+4) P2_4;
__sbit __at (0xA0+5) P2_5;
__sbit __at (0xA0+6) P2_6;
__sbit __at (0xA0+7) P2_7;
__sbit __at (0xB0+0) P3_0;
__sbit __at (0xB0+1) P3_1;
__sbit __at (0xB0+2) P3_2;
__sbit __at (0xB0+3) P3_3;
__sbit __at (0xB0+4) P3_4;
__sbit __at (0xB0+5) P3_5;
__sbit __at (0xB0+6) P3_6;
__sbit __at (0xB0+7) P3_7;
__sbit __at (0xD0+0) CY;
__sbit __at (0xD0+1) AC;
__sbit __at (0xD0+2) F0;
__sbit __at (0xD0+3) RS1;
__sbit __at (0xD0+4) RS0;
__sbit __at (0xD0+5) OV;
__sbit __at (0xD0+6) F1;
__sbit __at (0xD0+7) P;
```
其中,__sfr和__sbit是Keil C51编译器特有的类型定义,用于将一个特定的地址与一个变量或位相关联。8051单片机的SFR寄存器分为两类:可寻址寄存器和不可寻址寄存器。可寻址寄存器可以通过其地址直接访问,而不可寻址寄存器必须通过一定的方式访问。__sfr和__sbit的作用就是将这些寄存器的地址与变量或位相关联,使得程序开发者可以直接访问这些寄存器。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044833.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)