Memory Type Specifiers
The mikroC PRO for PIC 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.
The following memory type specifiers can be used:
code
Description |
The |
---|---|
Example |
// puts txt in program memory const code char txt[] = "ENTER PARAMETER:"; |
data
Description |
This memory specifier is used when storing variable to the Data RAM. |
---|---|
Example |
// puts x in data ram data unsigned char x; |
rx
Description |
This memory specifier allows variable to be stored in the working registers space (WREG0-WREG15). ![]() However, since compiler uses Rx space for storing temporary variables, it might happen that user variables will be stored in the internal data SRAM, when writing complex programs. |
---|---|
Example |
// puts y in working register space char rx y; |
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. ![]() |
---|---|
Example |
// Extern y in sfr space extern char y; sfr; // Puts y in sfr space by absolute (sfr addresses are MCU specific) char y absolute 0x0F81; sfr; // Puts y in sfr space by at char y at PORTB; |
ldm
Description |
The To treat a certain variable whose size exceeds 80 bytes as a linear, |
---|---|
Example |
// puts y in Linear Data Memory space ldm char y; |

- The ldm memory specifier is supported only by PIC16 Enhanced family devices.
- 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!