[Country EMBED strategy] [044] [Initialize BSS segment]

Source: Internet
Author: User

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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.