Small knowledge of ARM development summary

Byte 8 bits

Halfword 16 bits

32 bits

Code, RO-data

RW-data, ZI-data

Code is part of the program code

RO-data represents the constant const temp defined by the program;

RW-data represents initialized global variables

ZI-data represents uninitialized global variables

Program Size: Code=“18248” RO-data=320 RW-data=260 ZI-data=3952

Code, RO-data, RW-data. .. .. .. .. .flash

RW-data, ZIdata. .. .. .. .. .. ..RAM

RW-data is copied from flash to RAM during initialization

The generated map file is located in the list folder (KEIL)

Total RO Size (Code + RO Data) 18568 ( 18.13kB)

Total RW Size (RW Data + ZI Data) 4212 ( 4.11kB)

Total ROM Size (Code + RO Data + RW Data) 18828 ( 18.39kB)

The length of the ARM instruction is exactly 1 word (allocated to occupy 4 bytes), and the length of the Thumb instruction is just halfword (occupying 2 bytes)

R0-R15 (R15-PC, R14-LR, R13-SP) 32-bit

Each exception mode also has a Program Status Save Register (SPSR) that holds the CPSR before the exception event occurs.

LDMIA R1! , {R2-R7, R12} ; read the data in R1 single 到 to R2-R7, R12, R1 automatically add 1

STMIA RO! , {R3-R6, R10} ; save the data in R3-R6, R10 to the address pointed to by RO, RO automatically adds 1

The offset is added to Rn before the data transfer, and the result is used as the storage address of the transfer data. If the suffix "!" is used, the result is written back to Rn, and the Rn value is not allowed to be R15. The command is as follows:

LDR Rd, [Rn, #Ox4]!

LDMFD SP! , {R0-R3, PC}^ ; interrupt return

The "^" symbol indicates that this is a special form of instruction. This instruction is loaded while loading the PC from the memory (the PC is finally restored) and the CPSR is also restored.

Big endian format (Big-endian)

Little endian format (Little-endian)

Data 0x12345678 storage format

Big endian format

Low address "----0x12|0x34|0x56|0x78----" high address

Little endian format

Low address "----0x78|0x56|0x34|0x12----" high address

The ARM microprocessor supports seven operating modes, namely: CPSR M[4:0]

User mode (usr): The normal program execution state of the ARM processor. 10000

Fast interrupt mode (fiq): For high speed data transfer or channel processing. 10001

External Interrupt Mode (irq): Used for general purpose interrupt handling. 10010

Management mode (svc): The protection mode used by the operating system. 10011

Data Access Termination Mode (abt): This mode is entered when data or instruction prefetch is terminated and can be used for virtual storage and storage protection. 10111

System mode (sys): Run a privileged operating system task. 11111

Define Instruction Abort Mode (und): Enter this mode when an undefined instruction is executed, which can be used to support software emulation of the hardware coprocessor. 11011

ARM works normally in user mode and system mode, and enters management mode when resetting.

For the ARM instruction set, the PC points to the address of the next two instructions of the current instruction.

Note that pc, when debugging, shows the current instruction address, and when using mov lr, pc, lr saves the address of the last two instructions of this instruction.

Hypothetical disassembly code: 0x000001 : mov lr pc

(At this time, the value of the PC register is 0x000001, but the actual PC value is 0x000003, and the lr contains 0x000003)

Fields specifies the area to transfer (psr CPSR or SPSR)

c Control domain mask byte (psr[7..0])

x extended domain mask byte (psr[15..8])

s state field mask byte (psr[23..16])

f flag field mask byte (psr[31..24])

For example: MSR cpsr_c, #0xD3 ; CPSR[7. .0] = 0xD3

CODE SIZE, RO DATA, RW DATA, ZI DATA, idata, pdata---project Map file interpretation (1)

When the opTImizaTIon project starts, it tends to focus on performance at a time, such as codec mips or MCPS. When the time performance meets the requirements, the size parameter is often added for comparison. In this case, various sizes must be considered. This performance parameter may be clearly stated in the project requirements book, and there are more prepared data records in the test performance result or in the release note.

As shown in the following table:

Program ROM Data RAMROM Table

Scratch StackStaTIc

XXXXXXXXXX

First we have to figure out the meaning of these sizes and the performance implications of the reactions.

1, CODE SIZE, RO DATA, RW DATA, ZI DATA

The above variables are the values ​​that will appear in the ARM development environment. You can add some parameters to the armlink and get the corresponding .map file, from which you can get these values ​​accurately. There is an article detailing these meanings:

The composition of the ARM program (referring to the program being executed in the ARM system, not the bin file saved in the ROM)

An ARM program consists of 3 parts: RO segment, RW segment and ZI segment

RO is the instruction and constant in the program

RW is an initialized variable in the program

ZI is an uninitialized variable in the program

The above three points can be understood as:

RO is readonly,

RW is read/write,

ZI is zero

The composition of the ARM image file

The so-called ARM image file refers to the bin file that is burned into the ROM and also becomes an image file. The following uses the Image file to call it.

The Image file contains RO and RW data.

The reason why the Image file does not contain ZI data is because the ZI data is 0, it is not necessary to include, as long as the program is running, the area where the ZI data is located is always cleared. Including it wastes storage space.

Q: Why must Image contain RO and RW?

A: Because the instructions and constants in the RO and the variables initialized in the RW are not "out of the box" like the ZI.

ARM program execution process

From the above two points, it can be known that the image file burned into the ROM is not exactly the same as the ARM program in the actual runtime. Therefore, it is necessary to understand how the ARM program reaches the actual running state from the image in the ROM.

In fact, the instructions in the RO should at least have such a function:

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

2. Clear the RAM area where ZI is located. Because the ZI area is not in the Image, the program needs to clear the corresponding RAM area according to the ZI address and size given by the compiler. ZI is also a variable, the same reason: variables can not exist in ROM

In the initial stage of the program run, the C program can complete the two tasks and the C program can access the variables normally. Otherwise you can only run code without variables.

Said the above may still be a bit confused, RO, RW and ZI in the end, I will give a few examples below, the most intuitive to explain RO, RW, ZI what is meant in C.

PA Column Speaker

The Multiple Power Selection Column Loudspeaker Series which produce good clear sound and acoustical clarity for background music and paging,are suitable for indoor and outdoor applications such as stations, gardens, swimming pools,stadiums, and tennis courts, etc.
Even in extreme weather conditions, the all metal extruded aluminum alloy enclosure with cast aluminium top and bottom plates are fully dust and weatherproofcolumn speaker

Column Speaker,Column Speakers,Sound Column, Column Loudspeaker, Aluminium Alloy Outdoor Column Speaker

Taixing Minsheng Electronic Co.,Ltd. , https://www.ms-speakers.com