Professional Documents
Culture Documents
C 1 M 3 V 5-Special Keywords
C 1 M 3 V 5-Special Keywords
• RAM
• Code Memory Data Segment
.text
• Read-Only Data Start
Address .data
• External Non-volatile Memory .const
• Non-Volatile Data .bss
.cinit
.heap .pinit
Non-Volatile Data
Start Segment (unused)
Address (unused)
End
.eeprom .stack End
End Address
Address Address
C Keywords
• Special C-Keywords can affect data allocation
• Variable Types
• Type Qualifiers
• Type Modifiers
• Storage Classes*
Address .intvecs
• Data will be constant & put in read-only
memory like flash
.text
.data
• Automatically allocated and deallocated
data on the stack .bss
• Has a lifetime of a function or block
.heap
void foo(){
auto int vara;
int varb; (unused)
/* Other Code */
.stack
return; End Address
}
Static Keyword Data Segment
Start Address
.heap
• Static data can get stored in both
.data or .bss
static int VARA = 1; (unused)
.stack
static char VARB;
static int VARC = 0; End Address
Extern Keyword
Data Segment
• Declares a global reference defined in Start Address
another file to be visible by current file .data
• Can be bss or data
.bss
• Initial definition must be a global variable
.heap
extern int VARA; int VARA = 1;
extern char VARB; char VARB;
extern int VARC; int VARC = 0; (unused)
File1.c File2.c
.stack
End Address
Register Keyword
• Allocates Data directly in the CPU Microcontroller
• Used for repeated variable use with CPU Flash
high speed
• Not a guaranteed Registers
Peripherals GPIO
Registers Registers
register int VAR = 1;
int A_BSS;
Data Segment int B_BSS = 0;
int C_DATA = 1;
const int D_RODATA = 1;
• Stack: Temporary Data Storage like
local variables void foo(int D_STACK_REG){
int F_STACK_REG;
int G_STACK_REG = 1;
static int H_BSS;
• Heap: Dynamic data storage static int I_BSS = 0;
static int J_DATA = 1;
char * ptr_STACK_REG;
• Data: Non-Zero Initialized global and ptr_STACK_REG = (char *)malloc(8);
static data
/* More Code Here */
free((void *)ptr_STACK_REG);
• BSS: Zero initialized and Uninitialized
global and static data return;
}