Keil after compiling code,ro-data,rw-data,zi-data meaning and MCU flash actual storage data

Source: Internet
Author: User

Keil will have a line after compiling: program size:code=xxx ro-data=xxx rw-data=xxx zi-data=xxx

Code represents the execution of the codes, and all functions in the program are located here.

Ro-data represents read-only data, and the global constant data and strings defined in the program are located here.

The rw-data represents the initialized read-write data, and the global and static variables defined and initialized in the program are located here.

Zi-data represents uninitialized read-write data, and global variables and static variables defined in the program but not initialized are located here. Zi English is zero initial, which is the variable that is used in the program and is initialized by the system to 0 of the number of bytes of the variable, Keil compiler by default, you do not initialize the variables are assigned a value of 0, these variables are stored in RAM when the program is run.

2. If you view the. map file, the following example:

==============================================================================

Total RO Size (Code + ro Data) 2980 (2.91kB)
Total RW Size (rw data + ZI data) 104 (0.10kB)
Total ROM Size (Code + RO data + RW data) 2988 (2.92kB)

============================================================================== Total ROM Size (Code + RO data + RW data) This writes the total number of ROM bytes used by the program, which means the size of the program downloaded to ROM flash. Why ROM also to save RW, because all the data in RAM after the power loss, each time the data in the power RAM is re-assigned, each time these fixed values are stored in ROM, why does not contain Zi paragraph, because the Zi data is 0, no need to include, As long as the program runs before the Zi data in the region of the 0 can be included in the instead of wasting storage space.

In fact, the instructions in the ROM should have at least one of these features:
       1. Move RW from ROM to ram because RW is a variable and the variable cannot exist in ROM.
       2. Zi the area of RAM, because the Zi area is not in the image, so the program needs to clear the corresponding RAM area based on the Zi address and size given by the compiler. Zi is also a variable, in the same vein: A variable cannot exist in ROM.
        in the initial stage of the program's operation, the instructions in the RO complete these two tasks before the C program can access the variables normally. Otherwise, you can only run code that does not contain variables.

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.