Files
        @ 3e00cf5fc57d
    
        
              Branch filter: 
        
    Location: therm/libraries/CMSIS/Device/ST/STM32L1xx/Source/Templates/TASKING/cstart_thumb2.asm
        
            
            3e00cf5fc57d
            3.6 KiB
            text/x-nasm
        
        
    
    Trying to make clocks work
    | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | 
;;  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
        .extern exit
        .weak   exit
        .global __get_argcv
        .weak   __get_argcv
        .extern __argcvbuf
        .weak   __argcvbuf
        ;;.extern __init_hardware
        .extern  SystemInit
        
    .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
        ldr     r1,=_lc_ub_stack        ; TODO: make this part of the vector table
        mov     sp,r1
        ;; call a user function which initializes function.
        bl  SystemInit
        ;; 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:   
      .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
        ;; retrieve argc and argv (default argv[0]==NULL & argc==0)
        bl      __get_argcv
        ldr     r1,=__argcvbuf
        ;; call main
        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
        
__get_argcv:                    ; weak definition
        movs     r0,#0
        bx      lr
        .ltorg
        .endsec
        .calls  '_START', '  '
        .calls  '_START','__init_vector_table'
    .if @defined('__PROF_ENABLE__')
        .calls  '_START','__prof_init'
    .endif
    .if @defined('__POSIX__')
        .calls  '_START','posix_main'
    .else
        .calls  '_START','__get_argcv'
        .calls  '_START','main'
    .endif
        .calls  '_START','exit'
        .calls  '_START','',0
        .end
 |