在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > STM32 arm匯編(thumb-2指令集)啟動代碼分析

            STM32 arm匯編(thumb-2指令集)啟動代碼分析

            作者: 時間:2016-12-02 來源:網(wǎng)絡(luò) 收藏
            ;// Stack Configuration
            ;// Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
            ;//

            Stack_Size EQU 0x00000200 ;//定義堆棧大小
            AREA STACK, NOINIT, READWRITE, ALIGN=3 ;//定義一個數(shù)據(jù)段 按8字節(jié)對齊 ;AREA 偽指令用于定義一個代碼段或數(shù)據(jù)段 NOINIT:指定此數(shù)據(jù)段僅僅保留了內(nèi)存單元,而沒有將各初始值寫入內(nèi)存單元,或者將各個內(nèi)存單元值初始化為0
            Stack_Mem SPACE Stack_Size ;//保留Stack_Size大小的堆??臻g 分 配連續(xù) Stack_Size 字節(jié)的存儲單元并初始化為 0
            __initial_sp ;//標(biāo)號,代表堆棧頂部地址,后面有用
            ;// Heap Configuration
            ;// Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
            ;//

            Heap_Size EQU 0x00000020 ;//定義堆空間大小
            AREA HEAP, NOINIT, READWRITE, ALIGN=3 ;//定義一個數(shù)據(jù)段,8字節(jié)對齊
            __heap_base
            Heap_Mem SPACE Heap_Size ;//保留Heap_Size的堆空間
            __heap_limit ;//標(biāo)號,代表堆末尾地址,后面有用
            PRESERVE8 ;//指示編譯器8字節(jié)對齊
            THUMB ;//指示編譯器為THUMB指令
            ; Vector Table Mapped to Address 0 at Reset
            AREA RESET, DATA, READONLY ;//定義只讀數(shù)據(jù)段,其實放在CODE區(qū),位于0地址

            EXTERN NMIException
            EXTERN HardFaultException
            EXTERN MemManageException
            EXTERN BusFaultException
            EXTERN UsageFaultException
            EXTERN SVCHandler
            EXTERN DebugMonitor
            EXTERN PendSVC
            EXTERN SysTickHandler ;//聲明這些符號在外部定義,同C
            ;//在××it.c中實現(xiàn)這些函數(shù) ,中斷就能自動調(diào)用了
            EXPORT __Vectors
            EXPORT __initial_sp ;EXPORT:在程序中聲明一個全局的標(biāo)號__Vectors,該標(biāo)號可在其他的文件中引用;IMPORT:偽指令用于通知編譯器要使用的標(biāo)號在其他的源文件中定義, ;但要在當(dāng)前源文件中引用,而且無論當(dāng)前源文件是否引用該標(biāo)號,該標(biāo)號均會被加入到當(dāng)前源文件的符號表中
            __Vectors DCD __initial_sp ; Top of Stack //Cotex-M 要求此處為堆棧頂部地址
            DCD Reset_Handler ; Reset Handler
            DCD NMIException ; NMI Handler
            DCD HardFaultException ; Hard Fault Handler
            DCD MemManageException ; MPU Fault Handler
            DCD BusFaultException ; Bus Fault Handler
            DCD UsageFaultException ; Usage Fault Handler
            DCD 0 ; Reserved
            DCD 0 ; Reserved
            DCD 0 ; Reserved
            DCD 0 ; Reserved
            DCD SVCHandler ; SVCall Handler
            DCD DebugMonitor ; Debug Monitor Handler
            DCD 0 ; Reserved
            DCD PendSVC ; PendSV Handler
            DCD SysTickHandler ; SysTick Handler //一大堆的異常處理函數(shù)地址
            ; External Interrupts
            EXTERN WWDG_IRQHandler
            EXTERN PVD_IRQHandler
            EXTERN TAMPER_IRQHandler
            EXTERN RTC_IRQHandler
            EXTERN FLASH_IRQHandler
            EXTERN RCC_IRQHandler
            EXTERN EXTI0_IRQHandler
            EXTERN EXTI1_IRQHandler
            EXTERN EXTI2_IRQHandler
            EXTERN EXTI3_IRQHandler
            EXTERN EXTI4_IRQHandler
            EXTERN DMAChannel1_IRQHandler
            EXTERN DMAChannel2_IRQHandler
            EXTERN DMAChannel3_IRQHandler
            EXTERN DMAChannel4_IRQHandler
            EXTERN DMAChannel5_IRQHandler
            EXTERN DMAChannel6_IRQHandler
            EXTERN DMAChannel7_IRQHandler
            EXTERN ADC_IRQHandler
            EXTERN USB_HP_CAN_TX_IRQHandler
            EXTERN USB_LP_CAN_RX0_IRQHandler
            EXTERN CAN_RX1_IRQHandler
            EXTERN CAN_SCE_IRQHandler
            EXTERN EXTI9_5_IRQHandler
            EXTERN TIM1_BRK_IRQHandler
            EXTERN TIM1_UP_IRQHandler
            EXTERN TIM1_TRG_COM_IRQHandler
            EXTERN TIM1_CC_IRQHandler
            EXTERN TIM2_IRQHandler
            EXTERN TIM3_IRQHandler
            EXTERN TIM4_IRQHandler
            EXTERN I2C1_EV_IRQHandler
            EXTERN I2C1_ER_IRQHandler
            EXTERN I2C2_EV_IRQHandler
            EXTERN I2C2_ER_IRQHandler
            EXTERN SPI1_IRQHandler
            EXTERN SPI2_IRQHandler
            EXTERN USART1_IRQHandler
            EXTERN USART2_IRQHandler
            EXTERN USART3_IRQHandler
            EXTERN EXTI15_10_IRQHandler
            EXTERN RTCAlarm_IRQHandler
            EXTERN USBWakeUp_IRQHandler ;//同上,

            DCD WWDG_IRQHandler ; Window Watchdog
            DCD PVD_IRQHandler ; PVD through EXTI Line detect
            DCD TAMPER_IRQHandler ; Tamper
            DCD RTC_IRQHandler ; RTC
            DCD FLASH_IRQHandler ; Flash
            DCD RCC_IRQHandler ; RCC
            DCD EXTI0_IRQHandler ; EXTI Line 0
            DCD EXTI1_IRQHandler ; EXTI Line 1
            DCD EXTI2_IRQHandler ; EXTI Line 2
            DCD EXTI3_IRQHandler ; EXTI Line 3
            DCD EXTI4_IRQHandler ; EXTI Line 4
            DCD DMAChannel1_IRQHandler ; DMA Channel 1
            DCD DMAChannel2_IRQHandler ; DMA Channel 2
            DCD DMAChannel3_IRQHandler ; DMA Channel 3
            DCD DMAChannel4_IRQHandler ; DMA Channel 4
            DCD DMAChannel5_IRQHandler ; DMA Channel 5
            DCD DMAChannel6_IRQHandler ; DMA Channel 6
            DCD DMAChannel7_IRQHandler ; DMA Channel 7
            DCD ADC_IRQHandler ; ADC
            DCD USB_HP_CAN_TX_IRQHandler ; USB High Priority or CAN TX
            DCD USB_LP_CAN_RX0_IRQHandler ; USB Low Priority or CAN RX0
            DCD CAN_RX1_IRQHandler ; CAN RX1
            DCD CAN_SCE_IRQHandler ; CAN SCE
            DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
            DCD TIM1_BRK_IRQHandler ; TIM1 Break
            DCD TIM1_UP_IRQHandler ; TIM1 Update
            DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
            DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
            DCD TIM2_IRQHandler ; TIM2
            DCD TIM3_IRQHandler ; TIM3
            DCD TIM4_IRQHandler ; TIM4
            DCD I2C1_EV_IRQHandler ; I2C1 Event
            DCD I2C1_ER_IRQHandler ; I2C1 Error
            DCD I2C2_EV_IRQHandler ; I2C2 Event
            DCD I2C2_ER_IRQHandler ; I2C2 Error
            DCD SPI1_IRQHandler ; SPI1
            DCD SPI2_IRQHandler ; SPI2
            DCD USART1_IRQHandler ; USART1
            DCD USART2_IRQHandler ; USART2
            DCD USART3_IRQHandler ; USART3
            DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
            DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line
            DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend ;//同上
            AREA |.text|, CODE, READONLY ;//定義代碼段
            ; Reset Handler
            Reset_Handler PROC ;過程的開始

            ;//Rset_Handler的實現(xiàn) 利用PROC、ENDP這一對偽指令把程序段分為若干個過程,使程序的結(jié)構(gòu)加清晰
            EXPORT Reset_Handler [WEAK] ;//在外部沒有定義該符號時導(dǎo)出該符號,見HELP中[WEAK]
            IMPORT __main ;//導(dǎo)入符號,__main為 運(yùn)行時庫提供的函數(shù);完成堆棧,堆的初始話
            LDR R0, =__main ;//等工作,會調(diào)用下面定義的__user_initial_stackheap;
            BX R0 ;//跳到__main,進(jìn)入C的世界
            ENDP ;過程的結(jié)束
            ALIGN
            ; User Initial Stack & Heap
            IF :DEF:__MICROLIB ;//如果使用micro lib,micro lib 描述見armlib.chm

            EXPORT __heap_base
            EXPORT __heap_limit ;//只導(dǎo)出幾個定義

            ELSE ;//如果使用默認(rèn)C運(yùn)行時庫

            IMPORT __use_two_region_memory
            EXPORT __user_initial_stackheap
            __user_initial_stackheap ;//則進(jìn)行堆棧和堆的賦值,在__main函數(shù)執(zhí)行過程中調(diào)用。
            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 ;//OK ,完了

            本文引用地址:http://www.biyoush.com/article/201612/325049.htm

            http://blog.csdn.net/chehlcy/archive/2010/01/09/5164472.aspx

            http://files.ourdev.cn/bbs_upload134190/files_11/ourdev_495775.txt

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

            Reset_Handler PROC
            EXPORT Reset_Handler [WEAK]
            IMPORT __main
            LDR R0, =__main
            BX R0
            ENDP
            這段代碼什么意思。
            有2個地方不理解
            一:PROC ENDP
            二: [WEAK] 什么意思

            -------------------------------------------------------------------------------

            一:PROC為子程序開始,ENDP為子程序結(jié)束
            二:[weak]的意思就是弱。
            怎么弱呢?如果你在其他地方寫一個同名函數(shù),比如Reset_handler, 你寫的這個函數(shù)就可以取代它這個函數(shù)了。


            語法格式:
            EXPORT 標(biāo)號 {[WEAK]}
            EXPORT 偽指令用于在程序中聲明一個全局的標(biāo)號,該標(biāo)號可在其他的文件中引用。 EXPORT可用 GLOBAL 代替。標(biāo)號在程序中區(qū)分大小寫, [WEAK] 選項聲明其他的同名標(biāo)號優(yōu)先于該標(biāo)號被引用。
            使用示例:
            AREA Init , CODE , READONLY
            EXPORT Stest ;聲明一個可全局引用的標(biāo)號Stest……
            END



            關(guān)鍵詞: STM32arm匯編啟動代

            評論


            技術(shù)專區(qū)

            關(guān)閉