Mechatronics geek blog

Tuesday, April 2, 2019

Memory Sections

Memory Sections (Common Sections)
-----------------------------------------------

RAM:
1- .Stack section
2- .Heap section
3- .BSS section (Block Started by Symbol)
4- .Data

ROM:
1- .ISR Vector or .Vectors or .intVVector or .IVT
2- .rodata (Read Only data)
3- .romdata or .data
4- .text
==============================================
Example:
------------
uint32 x ; /*Uninitialized Global Variable stored in .bss section in RAM  and initialized with ZERO "According C Standard"*/

uint32 y=7; /*Initialized Global Variable stored in .data section in ROM (which means it has a specific location in .data section in ROM with value 7 but there's no label for it ) then it will be moved to .data section in RAM during run time with its label y and its value 7 */

const uint32 Z=100; /*Constant initialized global variable stored in .rodata section in ROM*/

void main(void)
{
uint32 A=10; /*Local variable stored in .stack section in RAM during runtime*/

/********Note: Static local variables will be treated as Global Variables********/

static uint32 B=20; /*Static local variable initialized with 20 and stored in .data section in ROM (which means it has a specific location in .data section in ROM with value 20 but there's no label for it ) then it will be moved to .data section in RAM during run time with its label B and its value 20 */

static uint32 F; /*Uninitialized static local Variable stored in .bss section in RAM  and initialized with ZERO "According C Standard"*/


const uint32 N=20;/*constant local variable stored in .stack section in RAM you can not change its value directly but you can define a pointer to it and change its value by dereferencing that pointer*/


static const uint32 M=200; /*static constant local variable .rodata section in ROM*/

}



















0 comments:

Post a Comment