The role of BSS segments
1. Space for variable storage
Initialized Global variables: Data segments
Uninitialized global variable: BSS segment
Local Variables: Stacks
Dynamic Allocation variables: heap
2. Why do you want to initialize the BSS segment?
Uninitialized global variables are assigned when they are used, and are not used to forget assignments, resulting in the use of random values. The BBS is zeroed by the system engineer when the system is started.
Initializing BSS segments
Locate the BSS segment start address and end address to fill in 0, the BSS segment address is recorded in the linker script
/** Name: init_bss* function: Initialize BSS segment */INIT_BSS:LDR R1, =bss_startldr R2, =bss_endmov R3, #0loop_bss: CMP R1, R2 // If the start address of the BSS segment equals the end address, then the end loop beq end_bssstr R3, [R1], #4 //Clear 0 BSS corresponding to the value of the address, then let the address add 4 byte b loop_bssend_bss:mov pc, LR
[Country EMBED strategy] [044] [Initialize BSS segment]