文件开头是关于文件的描述,先粘过来后面解释:
/**
- @file startup_stm32f407xx.s
- @author MCD Application Team
- @brief STM32F407xx Devices vector table for GCC based toolchains.
- This module performs:
-
- Set the initial SP
-
- Set the initial PC == Reset_Handler,
-
- Set the vector table entries with the exceptions ISR address
-
- Branches to main in the C library (which eventually
- calls main()).
- After Reset the Cortex-M4 processor is in Thread mode,
- priority is Privileged, and the Stack is set to Main.
- @attention
*
© COPYRIGHT 2017 STMicroelectronics
*
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- Neither the name of STMicroelectronics nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
*
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
复制
开头部分描述了文件的用途及版权声明:基于GCC编译链的STM32F407xx设备中断向量表,主要描述了
初始SP,PC寄存器的初始值。
PC的初始值即Reset_Handler
设置中断向量表入口地址,并用异常地址初始化向量表。 向量表里面保存的是异常响应的时候服务例程的入口地址。STM32把向量表放在0地址开始的code区。
转到C库的__main(最后调用mian())
复位CortexM4之后,处理器处于线程模式,特权优先级。
定义
继续往下看
.syntax unified
.cpu cortex-m4
.fpu softvfp
.thumb
.global g_pfnVectors
.global Default_Handler
复制
.syntax unified 是一个指示,默认值divided(分裂的) 旧样式,下面的指令使用ARM和THUMB各自独立的语法。unified (统一的)新样式,下面的指令使用ARM和THUMB通用格式。
.cpu表示后面用到的CPU平台为cortex-M4
.fpu表示后面使用的是软浮点,软浮点即Soft-float,浮点单元即VFP,(vector floating-point),相关资料可据此查询
.thumb使用thumb模式等价于.code 16;gcc -mthumb
.global定义了全局符号(symbol),.global使该符号对.ld(连接文件)可见。g_pfnVectors即中断向量表,Default_Handler我们这里先不解释,后面再看