C51 pointers
来源:互联网 发布:mva ips 知乎 编辑:程序博客网 时间:2024/05/24 05:03
Pointers
The Cx51 Compiler supports the declaration of variable pointers using the * character. The Cx51 Compiler pointers may be used to perform all operations available in standard C. However, because of the unique architecture of the 8051 and its derivatives, the Cx51 Compiler provides two different types of pointers:
generic pointers
memory-specific pointers
Comparison: Memory Specific & Generic Pointers
You can significantly accelerate an 8051 C program by using memory specific pointers. The following sample program shows the differences in code & data size and execution time for various pointer declarations.
Description idata Pointerxdata Pointer Generic Pointer
Sample Program char idata *ip;
char val;
val = *ip; char xdata *xp;
char val;
val = *xp; char *p;
char val;
val = *p;
8051 Program Code
Generated MOV R0,ip
MOV val,@R0 MOV DPL,xp +1
MOV DPH,xp
MOV A,@DPTR
MOV val,A MOV R1,p + 2
MOV R2,p + 1
MOV R3,p
CALL CLDPTR
Pointer Size
Code Size
Execution Time 1 byte
4 bytes
4 cycles 2 bytes
9 bytes
7 cycles 3 bytes
11 bytes + library call
13 cycles
C51的指针,用不好,就是祸害。
Posted by ian at 07:53 Tagged with: pointer
The Cx51 Compiler supports the declaration of variable pointers using the * character. The Cx51 Compiler pointers may be used to perform all operations available in standard C. However, because of the unique architecture of the 8051 and its derivatives, the Cx51 Compiler provides two different types of pointers:
generic pointers
memory-specific pointers
Comparison: Memory Specific & Generic Pointers
You can significantly accelerate an 8051 C program by using memory specific pointers. The following sample program shows the differences in code & data size and execution time for various pointer declarations.
Description idata Pointerxdata Pointer Generic Pointer
Sample Program char idata *ip;
char val;
val = *ip; char xdata *xp;
char val;
val = *xp; char *p;
char val;
val = *p;
8051 Program Code
Generated MOV R0,ip
MOV val,@R0 MOV DPL,xp +1
MOV DPH,xp
MOV A,@DPTR
MOV val,A MOV R1,p + 2
MOV R2,p + 1
MOV R3,p
CALL CLDPTR
Pointer Size
Code Size
Execution Time 1 byte
4 bytes
4 cycles 2 bytes
9 bytes
7 cycles 3 bytes
11 bytes + library call
13 cycles
C51的指针,用不好,就是祸害。
Posted by ian at 07:53 Tagged with: pointer
- C51 pointers
- C51
- Pointers
- Pointers
- Pointers
- Pointers to Pointers
- PCLINT+C51
- C51中断
- 汇编语言C51
- C51笔记
- C51指针
- C51中断
- C51单片机
- C51语法
- ubuntu c51
- C51串口
- C51计数器
- C51:Keil c51指针变量
- 七夕感怀
- getevent/sendevent 使用说明
- 定位IAT表
- C51: CALCULATING STACK SIZE
- 中庸----做人的智慧
- C51 pointers
- 深度解析:印度软件产业为何如此发达
- C51指针转换
- 引用是特殊指针
- Java线程:新特征-线程池
- C51指针定义
- 计算机的颜色格式(8位色 16位色 24位色)
- C51 Parameters and Registers
- GetBuffer--ReleaseBuffer问题