Explicitly Declared Memory Types

By including a memory type specifier in the variable declaration, you may specify where variables are stored . The following table summarizes the available memory type specifiers.

Memory Type

Description

code

program memory (64 KBytes); accessed by opcode MOVC @A+DPTR

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; allows 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

As with the signed and unsigned attributes, you may include memory type specifiers in the variable declaration. For example:
char data var1;

char code text[] = "ENTER PARAMETER:";

unsigned long xdata array[100];

float idata x,y,z;

unsigned int pdata dimension;

unsigned char xdata vector[10][4][4];

char bdata flags;

NOTE
C51 allows you to specify the memory type even before the type declarator. For this reason, the declaration data char x;  is equivalent to the declaration char data x.