博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于启动文件分析的(MDK-ARM) 【转】
阅读量:4953 次
发布时间:2019-06-12

本文共 18544 字,大约阅读时间需要 61 分钟。

;******************** (C) COPYRIGHT 2010 STMicroelectronics ********************;* File Name          : startup_stm32f10x_hd.s;* Author             : MCD Application Team;* Version            : V3.4.0;* Date               : 10/15/2010;* Description        : STM32F10x High Density Devices vector table for MDK-ARM;*                      toolchain.;*                      This module performs:;*                      - Set the initial SP;*                      - Set the initial PC == Reset_Handler;*                      - Set the vector table entries with the exceptions ISR address;*                      - Configure the clock system and also configure the external;*                        SRAM mounted on STM3210E-EVAL board to be used as data;*                        memory (optional, to be enabled by user);*                      - Branches to __main in the C library (which eventually;*                        calls main()).;*                      After Reset the CortexM3 processor is in Thread mode,;*                      priority is Privileged, and the Stack is set to Main.;* <<< Use Configuration Wizard in Context Menu >>>;                        INITIALIZE EXCEPTION VECTORS; 首先对栈和堆的大小进行定义,并在代码区的起始处建立中断向量表,其第一个表项是栈; 顶地址,第二个表项是复位中断服务入口地址。然后在复位中断服务程序中跳转C/C++标; 准实时库的__main函数。假设STM32被设置为从内部FLASH启动中断向量表起始地位为0x8000000,; 则栈顶地址存放于0x8000000处,而复位中断服务入口地址存放于0x8000004处。当STM32遇; 到复位信号后,则从0x80000004处取出复位中断服务入口地址继而执行复位中断服务程序,; 然后跳转__main函数,最后来到C的世界。 ; DCD指令:作用是开辟一段空间,其意义等价于C语言中的地址符“&”。开始建立的中断向量; 表则类似于使用C语.其每一个成员都是一个函数指针,分别指向各个中断服务函数 ;伪指令AREA,表示开辟一段大小为Stack_Size的内存空间作为栈,段名是STACK,可读可写。;NOINIT:指定此数据段仅仅保留了内存单元,而没有将各初始值写入内存单元,或者将各个内存单元值初始化为0; Amount of memory (in bytes) allocated for Stack; Tailor this value to your application needs; 
Stack Configuration;
Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>;
Stack_Size EQU 0x0000200 AREA STACK, NOINIT, READWRITE, ALIGN=3 ;解释在上面有说明 Stack_Mem SPACE Stack_Size ;分配连续 Stack_Size 字节的存储单元并初始化为 0。__initial_sp ;标号__initial_sp,表示栈空间顶地址。 ;
Heap Configuration;
Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>;
Heap_Size EQU 0x0000200 AREA HEAP, NOINIT, READWRITE, ALIGN=3 ;ALIGN用来指定对齐方式, 8字节对齐__heap_base ;表示堆空间起始地址Heap_Mem SPACE Heap_Size__heap_limit ;表示堆空间结束地址 PRESERVE8 ;PRESERVE8 指令指定当前文件保持堆栈八字节对齐 THUMB ;THUMB指令 ; Vector Table Mapped to Address 0 at Reset ;实际上是在CODE区(假设STM32从FLASH启动,则此中断向量表起始地址即为0x8000000) AREA RESET, DATA, READONLY ;定义一块数据段,只可读,段名字是RESET EXPORT __Vectors ;EXPORT:在程序中声明一个全局的标号__Vectors,该标号可在其他的文件中引用 EXPORT __Vectors_End ;在程序中声明一个全局的标号__Vectors_End EXPORT __Vectors_Size ;在程序中声明一个全局的标号__Vectors_Size__Vectors ;建立中断向量表DCD __initial_sp ; 0,Top of StackDCD Reset_Handler ; 1,Reset HandlerDCD NMI_Handler ; 2,NMI HandlerDCD HardFault_Handler ; 3,Hard Fault HandlerDCD MemManage_Handler ; 4,MPU Fault HandlerDCD BusFault_Handler ; 5,Bus Fault HandlerDCD UsageFault_Handler ; 6,Usage Fault HandlerDCD 0 ; 7,ReservedDCD 0 ; 8,ReservedDCD 0 ; 9,ReservedDCD 0 ; 10,ReservedDCD SVC_Handler ; 11,SVCall HandlerDCD DebugMon_Handler ; 12,Debug Monitor HandlerDCD 0 ; 13,ReservedDCD PendSV_Handler ;14,PendSV HandlerDCD SysTick_Handler ;15,uC/OS-II Tick ISR Handler; External InterruptsDCD WWDG_IRQHandler ; 16, INTISR[ 0] Window Watchdog.DCD PVD_IRQHandler ; 17, INTISR[ 1] PVD through EXTI Line Detection.DCD TAMPER_IRQHandler ; 18, INTISR[ 2] Tamper Interrupt.DCD RTC_IRQHandler ; 19, INTISR[ 3] RTC Global Interrupt.DCD FLASH_IRQHandler ; 20, INTISR[ 4] FLASH Global Interrupt.DCD RCC_IRQHandler ; 21, INTISR[ 5] RCC Global Interrupt.DCD EXTI0_IRQHandler ; 22, INTISR[ 6] EXTI Line0 Interrupt.DCD EXTI1_IRQHandler ; 23, INTISR[ 7] EXTI Line1 Interrupt.DCD EXTI2_IRQHandler ; 24, INTISR[ 8] EXTI Line2 Interrupt.DCD EXTI3_IRQHandler ; 25, INTISR[ 9] EXTI Line3 Interrupt.DCD EXTI4_IRQHandler ; 26, INTISR[ 10] EXTI Line4 Interrupt.DCD DMA1_Channel1_IRQHandler ; 27, INTISR[ 11] DMA Channel1 Global Interrupt.DCD DMA1_Channel2_IRQHandler ; 28, INTISR[ 12] DMA Channel2 Global Interrupt.DCD DMA1_Channel3_IRQHandler ; 29, INTISR[ 13] DMA Channel3 Global Interrupt.DCD DMA1_Channel4_IRQHandler ; 30, INTISR[ 14] DMA Channel4 Global Interrupt.DCD DMA1_Channel5_IRQHandler ; 31, INTISR[ 15] DMA Channel5 Global Interrupt.DCD DMA1_Channel6_IRQHandler ; 32, INTISR[ 16] DMA Channel6 Global Interrupt.DCD DMA1_Channel7_IRQHandler ; 33, INTISR[ 17] DMA Channel7 Global Interrupt.DCD ADC1_2_IRQHandler ; 34, INTISR[ 18] ADC1 & ADC2 Global Interrupt.DCD USB_HP_CAN1_TX_IRQHandler ; 35, INTISR[ 19] USB High Prio / CAN TX Interrupts.DCD USB_LP_CAN1_RX0_IRQHandler ; 36, INTISR[ 20] USB Low Prio / CAN RX0 Interrupts.DCD CAN1_RX1_IRQHandler ; 37, INTISR[ 21] CAN RX1 Interrupt.DCD CAN1_SCE_IRQHandler ; 38, INTISR[ 22] CAN SCE Interrupt.DCD EXTI9_5_IRQHandler ; 39, INTISR[ 23] EXTI Line[9:5] Interrupt.DCD TIM1_BRK_IRQHandler ; 40, INTISR[ 24] TIM1 Break Interrupt.DCD TIM1_UP_IRQHandler ; 41, INTISR[ 25] TIM1 Update Interrupt.DCD TIM1_TRG_COM_IRQHandler ; 42, INTISR[ 26] TIM1 Trig & Commutation Interrupts.DCD TIM1_CC_IRQHandler ; 43, INTISR[ 27] TIM1 Capture Compare Interrupt.DCD TIM2_IRQHandler ; 44, INTISR[ 28] TIM2 Global Interrupt.DCD TIM3_IRQHandler ; 45, INTISR[ 29] TIM3 Global Interrupt.DCD TIM4_IRQHandler ; 46, INTISR[ 30] TIM4 Global Interrupt.DCD I2C1_EV_IRQHandler ; 47, INTISR[ 31] I2C1 Event Interrupt. DCD I2C1_ER_IRQHandler ; 48, INTISR[ 32] I2C1 Error Interrupt.DCD I2C2_EV_IRQHandler ; 49, INTISR[ 33] I2C2 Event Interrupt.DCD I2C2_ER_IRQHandler ; 50, INTISR[ 34] I2C2 Error Interrupt.DCD SPI1_IRQHandler ; 51, INTISR[ 35] SPI1 Global Interrupt.DCD SPI2_IRQHandler ; 52, INTISR[ 36] SPI2 Global Interrupt.DCD USART1_IRQHandler ; 53, INTISR[ 37] USART1 Global Interrupt.DCD USART2_IRQHandler ; 54, INTISR[ 38] USART2 Global Interrupt.DCD USART3_IRQHandler ; 55, INTISR[ 39] USART3 Global Interrupt.DCD EXTI15_10_IRQHandler ; 56, INTISR[ 40] EXTI Line [15:10] Interrupts.DCD RTCAlarm_IRQHandler ; 57, INTISR[ 41] RTC Alarm EXT Line Interrupt.DCD USBWakeUp_IRQHandler ; 58, INTISR[ 42] USB Wakeup from Suspend EXTI Int.DCD TIM8_BRK_IRQHandler ; 59, INTISR[ 43] TIM8 Break Interrupt.DCD TIM8_UP_IRQHandler ; 60, INTISR[ 44] TIM8 Update Interrupt.DCD TIM8_TRG_COM_IRQHandler ; 61, INTISR[ 45] TIM8 Trigg/Commutation Interrupts.DCD TIM8_CC_IRQHandler ; 62, INTISR[ 46] TIM8 Capture Compare Interrupt.DCD ADC3_IRQHandler ; 63, INTISR[ 47] ADC3 Global Interrupt. DCD FSMC_IRQHandler ; 64, INTISR[ 48] FSMC Global Interrupt.DCD SDIO_IRQHandler ; 65, INTISR[ 49] SDIO Global Interrupt.DCD TIM5_IRQHandler ; 66, INTISR[ 50] TIM5 Global Interrupt.DCD SPI3_IRQHandler ; 67, INTISR[ 51] SPI3 Global Interrupt.DCD UART4_IRQHandler ; 68, INTISR[ 52] UART4 Global Interrupt.DCD UART5_IRQHandler ; 69, INTISR[ 53] UART5 Global Interrupt.DCD TIM6_IRQHandler ; 70, INTISR[ 54] TIM6 Global Interrupt.DCD TIM7_IRQHandler ; 71, INTISR[ 55] TIM7 Global Interrupt.DCD DMA2_Channel1_IRQHandler ; 72, INTISR[ 56] DMA2 Channel1 Global Interrupt.DCD DMA2_Channel2_IRQHandler ; 73, INTISR[ 57] DMA2 Channel2 Global Interrupt.DCD DMA2_Channel3_IRQHandler ; 74, INTISR[ 58] DMA2 Channel3 Global Interrupt.DCD DMA2_Channel4_5_IRQHandler ; 75, INTISR[ 59] DMA2 Channel4/5 Global Interrups.__Vectors_End__Vectors_Size EQU __Vectors_End - __Vectors ;得到向量表的大小,304个字节也就是0x130个字节 AREA |.text|, CODE, READONLY ;定义一个代码段,可读,段名字是.text ; Reset handlerReset_Handler PROC ;利用PROC、ENDP这一对伪指令把程序段分为若干个过程,使程序的结构加清晰 EXPORT Reset_Handler [WEAK] ;在外部没有定义该符号时导出该符号Reset_Handler IMPORT __main ;IMPORT:伪指令用于通知编译器要使用的标号在其他的源文件中定义 IMPORT SystemInit ;但要在当前源文件中引用,而且无论当前源文件是否引用该标号,该标号均会被加入到当前源文件的符号表中 LDR R0, =SystemInit BLX R0 LDR R0, =__main ;__main为 运行时库提供的函数;完成堆栈,堆的初始话等工作,会调用下面定义的__user_initial_stackheap BX R0 ;跳到__main,进入C的世界 ENDP; Dummy Exception Handlers (infinite loops which can be modified)NMI_Handler PROC EXPORT NMI_Handler [WEAK] ;WEAK声明其他的同名标号优先于该标号被引用,就是说如果外面声明了的话, B . ;会调用外面的 ENDPHardFault_Handler\ PROC EXPORT HardFault_Handler [WEAK] B . ENDPMemManage_Handler\ PROC EXPORT MemManage_Handler [WEAK] B . ENDPBusFault_Handler\ PROC EXPORT BusFault_Handler [WEAK] B . ENDPUsageFault_Handler\ PROC EXPORT UsageFault_Handler [WEAK] B . ENDPSVC_Handler PROC EXPORT SVC_Handler [WEAK] B . ENDPDebugMon_Handler\ PROC EXPORT DebugMon_Handler [WEAK] B . ENDPPendSV_Handler PROC EXPORT PendSV_Handler [WEAK] B . ENDPSysTick_Handler PROC EXPORT SysTick_Handler [WEAK] B . ENDPDefault_Handler PROC EXPORT WWDG_IRQHandler [WEAK] EXPORT PVD_IRQHandler [WEAK] EXPORT TAMPER_IRQHandler [WEAK] EXPORT RTC_IRQHandler [WEAK] EXPORT FLASH_IRQHandler [WEAK] EXPORT RCC_IRQHandler [WEAK] EXPORT EXTI0_IRQHandler [WEAK] EXPORT EXTI1_IRQHandler [WEAK] EXPORT EXTI2_IRQHandler [WEAK] EXPORT EXTI3_IRQHandler [WEAK] EXPORT EXTI4_IRQHandler [WEAK] EXPORT DMA1_Channel1_IRQHandler [WEAK] EXPORT DMA1_Channel2_IRQHandler [WEAK] EXPORT DMA1_Channel3_IRQHandler [WEAK] EXPORT DMA1_Channel4_IRQHandler [WEAK] EXPORT DMA1_Channel5_IRQHandler [WEAK] EXPORT DMA1_Channel6_IRQHandler [WEAK] EXPORT DMA1_Channel7_IRQHandler [WEAK] EXPORT ADC1_2_IRQHandler [WEAK] EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK] EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK] EXPORT CAN1_RX1_IRQHandler [WEAK] EXPORT CAN1_SCE_IRQHandler [WEAK] EXPORT EXTI9_5_IRQHandler [WEAK] EXPORT TIM1_BRK_IRQHandler [WEAK] EXPORT TIM1_UP_IRQHandler [WEAK] EXPORT TIM1_TRG_COM_IRQHandler [WEAK] EXPORT TIM1_CC_IRQHandler [WEAK] EXPORT TIM2_IRQHandler [WEAK] EXPORT TIM3_IRQHandler [WEAK] EXPORT TIM4_IRQHandler [WEAK] EXPORT I2C1_EV_IRQHandler [WEAK] EXPORT I2C1_ER_IRQHandler [WEAK] EXPORT I2C2_EV_IRQHandler [WEAK] EXPORT I2C2_ER_IRQHandler [WEAK] EXPORT SPI1_IRQHandler [WEAK] EXPORT SPI2_IRQHandler [WEAK] EXPORT USART1_IRQHandler [WEAK] EXPORT USART2_IRQHandler [WEAK] EXPORT USART3_IRQHandler [WEAK] EXPORT EXTI15_10_IRQHandler [WEAK] EXPORT RTCAlarm_IRQHandler [WEAK] EXPORT USBWakeUp_IRQHandler [WEAK] EXPORT TIM8_BRK_IRQHandler [WEAK] EXPORT TIM8_UP_IRQHandler [WEAK] EXPORT TIM8_TRG_COM_IRQHandler [WEAK] EXPORT TIM8_CC_IRQHandler [WEAK] EXPORT ADC3_IRQHandler [WEAK] EXPORT FSMC_IRQHandler [WEAK] EXPORT SDIO_IRQHandler [WEAK] EXPORT TIM5_IRQHandler [WEAK] EXPORT SPI3_IRQHandler [WEAK] EXPORT UART4_IRQHandler [WEAK] EXPORT UART5_IRQHandler [WEAK] EXPORT TIM6_IRQHandler [WEAK] EXPORT TIM7_IRQHandler [WEAK] EXPORT DMA2_Channel1_IRQHandler [WEAK] EXPORT DMA2_Channel2_IRQHandler [WEAK] EXPORT DMA2_Channel3_IRQHandler [WEAK] EXPORT DMA2_Channel4_5_IRQHandler [WEAK] WWDG_IRQHandlerPVD_IRQHandlerTAMPER_IRQHandlerRTC_IRQHandlerFLASH_IRQHandlerRCC_IRQHandlerEXTI0_IRQHandlerEXTI1_IRQHandlerEXTI2_IRQHandlerEXTI3_IRQHandlerEXTI4_IRQHandlerDMA1_Channel1_IRQHandlerDMA1_Channel2_IRQHandlerDMA1_Channel3_IRQHandlerDMA1_Channel4_IRQHandlerDMA1_Channel5_IRQHandlerDMA1_Channel6_IRQHandlerDMA1_Channel7_IRQHandlerADC1_2_IRQHandlerUSB_HP_CAN1_TX_IRQHandlerUSB_LP_CAN1_RX0_IRQHandlerCAN1_RX1_IRQHandlerCAN1_SCE_IRQHandlerEXTI9_5_IRQHandlerTIM1_BRK_IRQHandlerTIM1_UP_IRQHandlerTIM1_TRG_COM_IRQHandlerTIM1_CC_IRQHandlerTIM2_IRQHandlerTIM3_IRQHandlerTIM4_IRQHandlerI2C1_EV_IRQHandlerI2C1_ER_IRQHandlerI2C2_EV_IRQHandlerI2C2_ER_IRQHandlerSPI1_IRQHandlerSPI2_IRQHandlerUSART1_IRQHandlerUSART2_IRQHandlerUSART3_IRQHandlerEXTI15_10_IRQHandlerRTCAlarm_IRQHandlerUSBWakeUp_IRQHandlerTIM8_BRK_IRQHandlerTIM8_UP_IRQHandlerTIM8_TRG_COM_IRQHandlerTIM8_CC_IRQHandlerADC3_IRQHandlerFSMC_IRQHandlerSDIO_IRQHandlerTIM5_IRQHandlerSPI3_IRQHandlerUART4_IRQHandlerUART5_IRQHandlerTIM6_IRQHandlerTIM7_IRQHandlerDMA2_Channel1_IRQHandlerDMA2_Channel2_IRQHandlerDMA2_Channel3_IRQHandlerDMA2_Channel4_5_IRQHandler B . ENDP ALIGN ;*******************************************************************************; User Stack and Heap initialization;******************************************************************************* IF :DEF:__MICROLIB ;判断是否使用DEF:__MICROLIB(micro lib) EXPORT __initial_sp ;使用的话则将栈顶地址,堆始末地址赋予全局属 EXPORT __heap_base ;性,使外部程序可以使用 EXPORT __heap_limit ELSE ;如果使用默认C库运行时 IMPORT __use_two_region_memory ;定义全局标号__use_two_region_memory EXPORT __user_initial_stackheap ;声明全局标号__user_initial_stackheap,这样外程序也可调用此标号 ;则进行堆栈和堆的赋值,在__main函数执行过程中调用__user_initial_stackheap ;标号__user_initial_stackheap,表示用户堆栈初始化程序入口 LDR R0, = Heap_Mem ;保存堆始地址 LDR R1, =(Stack_Mem + Stack_Size) ;保存栈的大小 LDR R2, = (Heap_Mem + Heap_Size) ;保存堆的大小 LDR R3, = Stack_Mem ;保存栈顶指针 BX LR ALIGN ENDIF END;******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE*****

 

转载于:https://www.cnblogs.com/Just--Do--It/p/6986153.html

你可能感兴趣的文章
51nod 1247可能的路径
查看>>
js05-DOM对象二
查看>>
mariadb BINLOG_FORMAT = STATEMENT 异常
查看>>
C3P0 WARN: Establishing SSL connection without server's identity verification is not recommended
查看>>
iPhone在日本最牛,在中国输得最慘
查看>>
动态方法决议 和 消息转发
查看>>
WPF自定义搜索框代码分享
查看>>
js 基础拓展
查看>>
SpringBoot访问html访问不了的问题
查看>>
{width=200px;height=300px;overflow:hidden}
查看>>
C#生成随机数
查看>>
CSS基础学习 20.CSS媒体查询
查看>>
2019春季第十一周作业
查看>>
洛谷P4591 [TJOI2018]碱基序列 【KMP + dp】
查看>>
iOS CoreData介绍和使用(以及一些注意事项)
查看>>
OS笔记047代理传值和block传值
查看>>
Android应用程序与SurfaceFlinger服务的连接过程分析
查看>>
coco2dx服务器简单例子
查看>>
Java回顾之多线程
查看>>
sqlite
查看>>