Keil Logo

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:

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 Pointer xdata 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
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.