Memory Type Specifiers
The mikroPascal PRO for 8051 supports usage of all memory areas.
Each variable may be explicitly assigned to a specific memory space by including a memory type specifier in the declaration, or implicitly assigned (based on a memory model).
The following memory type specifiers can be used:
code
Description |
Program memory (64 KBytes); accessed by opcode MOVC @A+DPTR. The |
---|---|
Example |
// puts txt in program memory const txt : string[11] = 'Enter text:'; code; |
data
Description |
Directly addressable internal data memory; fastest access to variables (128 bytes). This memory is directly accessed using 8-bit addresses and is the on-chip RAM of the 8051. It has the shortest (fastest) access time but the amount of data is limited in size (to 128 bytes or less). |
---|---|
Example |
// puts x in data ram var x : byte; data; |
idata
Description |
Indirectly addressable internal data memory; accessed across the full internal address space (256 bytes). This memory is indirectly accessed using 8-bit addresses and is the on-chip RAM of the 8051. The amount of idata is limited in size (to 128 bytes or less) it is upper 128 addresses of RAM |
---|---|
Example |
// puts x in idata ram var x : byte; idata; |
bdata
Description |
Bit-addressable internal data memory; supports mixed bit and byte access (16 bytes). This memory is directly accessed using 8-bit addresses and is the on-chip bit-addressable RAM of the 8051. Variables declared with the bdata type are bit-addressable and may be read and written using bit instructions. For more information about thebdata type refer to the Migration Issues.
|
---|---|
Example |
// puts x in bdata var x : byte; bdata; |
xdata
Description |
External RAM (XRAM) or Internal expanded RAM (ERAM); accessed by opcode MOVX @DPTR. See Xdata Specifics This memory is indirectly accessed using 16-bit addresses and is the external data RAM of the 8051. The amount of xdata is limited in size (to 64K or less). |
---|---|
Example |
// puts x in xdata var x : byte; xdata; |
pdata
Description |
Paged (256 bytes) external data memory; accessed by opcode MOVX @Rn. This memory is indirectly accessed using 8-bit addresses and is one 256-byte page of external data RAM of the 8051. The amount of |
---|---|
Example |
// puts x in pdata var x : byte; pdata; |
rx
Description |
This memory specifier allows variable to be stored in the Rx space, R0-R7 (Register file).
Note :
|
---|---|
Example |
// puts R0 in Rx space R0 : byte; absolute 0x00; rx; |
sfr
Description |
This memory specifier allows user to access special function registers. It also instructs compiler to maintain same identifier name in source and assembly.
Note :
Variables can only be allocated in sfr space by the means of absolute directive or at directive to a variable already allocated in sfr space.
|
---|---|
Example |
// Extern y in sfr space var y : char; sfr; external; // Puts y in sfr space by absolute (sfr addresses are MCU specific) var y : char; absolute 0x0F81; sfr; // // Puts y in sfr space by at var y: char at PORTB; |
- If none of the memory specifiers are used when declaring a variable,
data
specifier will be set as default by the compiler.
What do you think about this topic ? Send us feedback!