Welcome to the official website of Shenzhen Chongwen Technology Co., Ltd!
描述
描述
0755-29812996 

Details of ARM program execution process

time :2022-12-02 author : from: scanning : classify :公司新闻
The composition of ARM program (referring to the program being executed in ARM system, rather than the bin file saved in ROM). An ARM program consists of three parts: RO segment (read-only), RW segment (read-write) and ZI segment (read-write)

Composition of ARM program


The composition of ARM program (referring to the program being executed in ARM system, rather than the bin file saved in ROM). An ARM program consists of three parts: RO segment (read-only), RW segment (read-write) and ZI segment (read-write). RO is the instruction and constant in the program; RW is the initialized variable in the program; ZI is an uninitialized variable in the program.


Composition of ARM image file


The so-called ARM image file refers to the bin file burned into ROM, also known as image file. The Image file contains RO and RW data. The reason why the Image file does not contain ZI data is that ZI data is all 0, so it is unnecessary to include it, as long as the area where the ZI data is located is cleared to zero before the program runs. Inclusion wastes storage space instead.


Execution process of ARM program


From the above two points, we can know that the image file burned into ROM is not exactly the same as the actual ARM program. Therefore, it is necessary to understand how ARM programs arrive at the actual running state from the image in ROM.


In fact, the instructions in ROM should at least have the following functions:


1. Move RW from ROM to RAM. Since RW is a variable, the variable cannot exist in ROM.

2. Clear all the RAM regions where the ZI is located. Since the ZI region is not in Image, the program needs to clear the corresponding RAM regions according to the ZI address and size given by the compiler. ZI is also a variable. Similarly, variables cannot exist in ROM. At the initial stage of program operation, C program can access variables normally only after the instructions in RO have completed these two tasks. Otherwise, you can only run code without variables.


Explain RO, RW, ZI


It may be a bit confusing to say what RO, RW and ZI are. I will give some examples to illustrate what RO, RW and ZI mean in C.


1、RO


Look at the following two programs. There is a statement between them. This statement is to declare a character constant. Therefore, as we said before, they should only differ by one byte in RO data (the character constant is 1 byte).


Prog1:


#include《stdio.h》

voidmain(void)

{

;

}

Prog2:


#include《stdio.h》

const char a= 5;

voidmain(void)

{

;

}

The compiled information of Prog1 is as follows:

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

Code RO DataRW Data ZI Data Debug

948 60 0 960 Grand Totals

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

Total ROSize(Code + RO Data) 1008 ( 0.98kB)

Total RWSize(RW Data + ZI Data) 96 ( 0.09kB)

Total ROMSize(Code + RO Data + RW Data) 1008 ( 0.98kB)

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

The information compiled by Prog2 is as follows:

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

Code RO DataRW Data ZI Data Debug

948 61 0 960 Grand Totals

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

Total ROSize(Code + RO Data) 1009 ( 0.99kB)

Total RWSize(RW Data + ZI Data) 96 ( 0.09kB)