Generic pointers and Memory specific pointers in PSoC3 KEIL compiler

Question: What is generic pointer and memory specific pointer in PSoC3 KEIL Compiler?

 

Answer:

Generic pointers are declared like standard C pointers. For example:

                     int *ptr;       /* Pointer to Integer     */

Generic pointers are always stored using three bytes. The first byte contains a value that indicates the memory area or memory type, the second is the high-order byte of the offset, and the third is the low-order byte of the offset. By using these generic pointers, a function can access data regardless of the memory in which it is stored. Memory type has following values based on target memory location.

 

  

 

                                                                                 
   

     Compiler

  
   

     Memory Type

  
   

     idata

  
   

     data

  
   

     bdata

  
   

     xdata

  
   

     pdata

  
   

     code

  
   

     C51 Compiler
     (8051 Devices)

  
   

     0x00

  
   

     0x00

  
   

     0x00

  
   

     0x01

  
   

     0xFE

  
   

     0xFF

  


The following list summarizes the memory type supported by KEIL compiler.

  •   code    Program memory
  •   data    Directly addressable internal data memory; fastest access to variables (128 bytes)
  •   idata    Indirectly addressable internal data memory; accessed across the full internal address space (256 bytes)
  •   bdata    Bit-addressable internal data memory; supports mixed bit and byte access (16 bytes)
  •   xdata    External data memory (64 KBytes); accessed by opcode MOVX @DPTR
  •   pdata    Paged (256 bytes) external data memory; accessed by opcode MOVX @Rn
     

Memory-specific pointers always include a memory type specification in the pointer declaration, and always refer to a specific memory area. For example:

                            int xdata *ptr;     /* Pointer to integer stored in xdata space     */

Because the memory type is specified at compile-time, the memory type byte required by generic pointers is not needed by memory-specific pointers. Memory-specific pointers can be stored using only one byte (idata, data, bdata, and pdata pointers) or two bytes (code and xdata pointers).

Refer to KEIL compiler documentation for more details.