如果是使用stm32cubeide编译的话是会用到gcc/linker文件下的startup_stm32mp15xx.s,当然了如果是用mdk的话是纯纯的汇编它是在arm/linker文件夹下的startup_stm32mp15xx.s这两个文件功能是一样的只是编写风格十分不同,如果是想看mdk的说明可以移步本站的其他文章。
其代码如下,十分的简洁,而且熟悉arm汇编的话,很容易就能理解
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
当然了今天的主角是下面的采用stm32cubeide的编写风格的汇编
.section .startup_copro_fw.Reset_Handler,"ax"
.weak Reset_Handler
.type Reset_Handler, %function
Reset_Handler:
ldr sp, =_estack /* set stack pointer */
/* Loop to copy data from read only memory to RAM. The ranges
* of copy from/to are specified by following symbols evaluated in
* linker script.
* _sidata: End of code section, i.e., begin of data sections to copy from.
* _sdata/_edata: RAM address range that data should be
* copied to. Both must be aligned to 4 bytes boundary. */
movs r1, #0
b LoopCopyDataInit
CopyDataInit:
ldr r3, =_sidata
ldr r3, [r3, r1]
str r3, [r0, r1]
adds r1, r1, #4
LoopCopyDataInit:
ldr r0, =_sdata
ldr r3, =_edata
adds r2, r0, r1
cmp r2, r3
bcc CopyDataInit
ldr r2, =_sbss
b LoopFillZerobss
/* Zero fill the bss segment. */
FillZerobss:
movs r3, #0
str r3, [r2], #4
LoopFillZerobss:
ldr r3, = _ebss
cmp r2, r3
bcc FillZerobss
/* Call the clock system intitialization function.*/
bl SystemInit
// ldr r0, =SystemInit
// blx r0
/* Call static constructors */
bl __libc_init_array
// ldr r0, =__libc_init_array
// blx r0
/* Call the application's entry point.*/
bl main
//ldr r0, =main
//blx r0
LoopForever:
b LoopForever
.size Reset_Handler, .-Reset_Handler
可以在最后的代码段看到如下的代码,它和arm下的汇编的意思是一样的,都是先跳转到systeminit(?bl? SystemInit),再跳转到main(bl main)函数
/* Call the clock system intitialization function.*/
bl SystemInit
// ldr r0, =SystemInit
// blx r0
/* Call static constructors */
bl __libc_init_array
// ldr r0, =__libc_init_array
// blx r0
/* Call the application's entry point.*/
bl main
//ldr r0, =main
//blx r0
LoopForever:
b LoopForever
从注释中可以看到:
1、/* Call the clock system intitialization function.*/
该处是调用时钟系统初始化函数。
2、/* Call the application's entry point.*/
该处是调用应用程序的入口指针(点位)。
|