⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cstart_thumb2.asm

📁 用 Hitex 工具软件开发 stm32 的例子
💻 ASM
字号:
 ;;********************************************************************
 ;;* Project:     Systick example demo for STM32
 ;;* File:    	cstart_thumb2.asm
 ;;*
 ;;* System:   	Cortex-M3 32 Bit
 ;;* Compiler:  	Tasking
 ;;*
 ;;* Date:      	2007-09-27
 ;;* Author:   
 ;;*
 ;;* Rights:    	Hitex Development Tools GmbH
 ;;*            	Greschbachstr. 12
 ;;*            	D-76229 Karlsruhe
 ;;********************************************************************
 ;;* Description:
 ;;*  - boot code
 ;;********************************************************************
 ;;* History:
 ;;*
 ;;*  Revision 1.0    2007/09/27      We
 ;;*     Initial revision 
 ;;********************************************************************
 ;;* This is a preliminary version.
 ;;*
 ;;* WARRANTY:  HITEX warrants that the media on which the SOFTWARE is 
 ;;* furnished is free from defects in materials and workmanship under 
 ;;* normal use and service for a period of ninety (90) days. HITEX entire
 ;;* liability and your exclusive remedy shall be the replacement of the 
 ;;* SOFTWARE if the media is defective. This Warranty is void if failure
 ;;* of the media resulted from unauthorized modification, accident, abuse,
 ;;* or misapplication.
 ;;*
 ;;* DISCLAIMER:  OTHER THAN THE ABOVE WARRANTY, THE SOFTWARE IS FURNISHED
 ;;* "AS IS" WITHOUT WARRANTY OF ANY KIND. HITEX DISCLAIMS ALL OTHER WARRANTIES,
 ;;* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES
 ;;* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 ;;*
 ;;* NEITHER HITEX NOR ITS AFFILIATES SHALL BE LIABLE FOR ANY DAMAGES ARISING
 ;;* OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, INCLUDING DAMAGES FOR
 ;;* LOSS OF PROFITS, BUSINESS INTERRUPTION, OR ANY SPECIAL, INCIDENTAL, INDIRECT
 ;;* OR CONSEQUENTIAL DAMAGES EVEN IF HITEX HAS BEEN ADVISED OF THE POSSIBILITY 
 ;;* OF SUCH DAMAGES.
 ;;********************************************************************/

;;  NOTE: To allow the use of this file for both ARMv6M and ARMv7M,
;;        we will only use 16-bit Thumb intructions.

   .extern _lc_ub_stack            ; usr/sys mode stack pointer
   .extern _lc_ue_stack            ; symbol required by debugger
   .extern _lc_ub_table            ; ROM to RAM copy table
   .extern main
   .extern _Exit
;   .global __RESET
   .extern exit
   .weak   exit
   .extern _init_hardware

   .if @defined('__PROF_ENABLE__')
      .extern __prof_init
   .endif
   .if @defined('__POSIX__')
      .extern posix_main
      .extern _posix_boot_stack_top
   .endif

   .global _START

   .section .text.cstart
   .thumb

_START:
      ;; anticipate possible ROM/RAM remapping
      ;; by loading the 'real' program address
      ldr     r1,=_Next
      bx      r1
_Next:
      ;; initialize the stack pointer
      ; this is also part of the vector table
      ldr     r1,=_lc_ub_stack
      mov     sp,r1

      ;; call a user function which initializes hardware
      ;; such as ROM/RAM re-mapping or MMU configuration
      bl      _init_hardware

      ;; copy initialized sections from ROM to RAM
      ;; and clear uninitialized data sections in RAM

      ldr     r3,=_lc_ub_table
      movs    r0,#0
cploop:
      ldr     r4,[r3,#0]      ; load type
      ldr     r5,[r3,#4]      ; dst address
      ldr     r6,[r3,#8]      ; src address
      ldr     r7,[r3,#12]     ; size

      cmp     r4,#1
      beq     copy
      cmp     r4,#2
      beq     clear
      b       done

copy:
      subs    r7,r7,#1
      ldrb    r1,[r6,r7]
      strb    r1,[r5,r7]
      bne     copy

      adds    r3,r3,#16
      b       cploop

clear:
      subs    r7,r7,#1
      strb    r0,[r5,r7]
      bne     clear

      adds    r3,r3,#16
      b       cploop

done:
      ;; initialize or copy the vector table

      .if @defined('__POSIX__')

         ;; posix stack buffer for system upbringing
         ldr     r0,=_posix_boot_stack_top
         ldr     r0, [r0]
         mov     sp,r0

      .else

         ;; load r10 with end of USR/SYS stack, which is
         ;; needed in case stack overflow checking is on
         ;; NOTE: use 16-bit instructions only, for ARMv6M
         ldr     r0,=_lc_ue_stack
         mov     r10,r0

      .endif

      .if @defined('__PROF_ENABLE__')
         bl      __prof_init
      .endif

      .if @defined('__POSIX__')
         ;; call posix_main with no arguments
         bl      posix_main
      .else
         ;; call main with argv[0]==NULL & argc==0
         movs     r0,#0
         movs     r1,#0
         bl       main
      .endif

         ;; call exit using the return value from main()
         ;; Note. Calling exit will also run all functions
         ;; that were supplied through atexit().
         bl      exit

      .ltorg
      .endsec

      .calls  '_START','_init_hardware'
      .calls  '_START','_init_vector_table'
      .if @defined('__PROF_ENABLE__')
         .calls  '_START','__prof_init'
      .endif
      .if @defined('__POSIX__')
         .calls  '_START','posix_main'
      .else
         .calls  '_START','main'
      .endif
         .calls  '_START','exit'
         .calls  '_START','',0

      .end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -