Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /**************************************************
sahilmgandhi 18:6a4db94011d3 2 *
sahilmgandhi 18:6a4db94011d3 3 * Part two of the system initialization code, contains C-level
sahilmgandhi 18:6a4db94011d3 4 * initialization, thumb-2 only variant.
sahilmgandhi 18:6a4db94011d3 5 *
sahilmgandhi 18:6a4db94011d3 6 * Copyright 2006 IAR Systems. All rights reserved.
sahilmgandhi 18:6a4db94011d3 7 *
sahilmgandhi 18:6a4db94011d3 8 * $Revision: 59783 $
sahilmgandhi 18:6a4db94011d3 9 *
sahilmgandhi 18:6a4db94011d3 10 **************************************************/
sahilmgandhi 18:6a4db94011d3 11
sahilmgandhi 18:6a4db94011d3 12
sahilmgandhi 18:6a4db94011d3 13 ; --------------------------------------------------
sahilmgandhi 18:6a4db94011d3 14 ; Module ?cmain, C-level initialization.
sahilmgandhi 18:6a4db94011d3 15 ;
sahilmgandhi 18:6a4db94011d3 16
sahilmgandhi 18:6a4db94011d3 17
sahilmgandhi 18:6a4db94011d3 18 SECTION SHT$$PREINIT_ARRAY:CONST:NOROOT(2)
sahilmgandhi 18:6a4db94011d3 19 SECTION SHT$$INIT_ARRAY:CONST:NOROOT(2)
sahilmgandhi 18:6a4db94011d3 20
sahilmgandhi 18:6a4db94011d3 21 SECTION .text:CODE:NOROOT(2)
sahilmgandhi 18:6a4db94011d3 22
sahilmgandhi 18:6a4db94011d3 23 PUBLIC __cmain
sahilmgandhi 18:6a4db94011d3 24 ;; Keep ?main for legacy reasons, it is accessed in countless instances of cstartup.s around the world...
sahilmgandhi 18:6a4db94011d3 25 PUBLIC ?main
sahilmgandhi 18:6a4db94011d3 26 EXTWEAK __iar_data_init3
sahilmgandhi 18:6a4db94011d3 27 EXTWEAK __iar_argc_argv
sahilmgandhi 18:6a4db94011d3 28 EXTERN __low_level_init
sahilmgandhi 18:6a4db94011d3 29 EXTERN __call_ctors
sahilmgandhi 18:6a4db94011d3 30 EXTERN main
sahilmgandhi 18:6a4db94011d3 31 EXTERN exit
sahilmgandhi 18:6a4db94011d3 32 EXTERN __iar_dynamic_initialization
sahilmgandhi 18:6a4db94011d3 33 EXTERN mbed_sdk_init
sahilmgandhi 18:6a4db94011d3 34 EXTERN SystemInit
sahilmgandhi 18:6a4db94011d3 35
sahilmgandhi 18:6a4db94011d3 36 THUMB
sahilmgandhi 18:6a4db94011d3 37 __cmain:
sahilmgandhi 18:6a4db94011d3 38 ?main:
sahilmgandhi 18:6a4db94011d3 39
sahilmgandhi 18:6a4db94011d3 40 ; Initialize segments.
sahilmgandhi 18:6a4db94011d3 41 ; __segment_init and __low_level_init are assumed to use the same
sahilmgandhi 18:6a4db94011d3 42 ; instruction set and to be reachable by BL from the ICODE segment
sahilmgandhi 18:6a4db94011d3 43 ; (it is safest to link them in segment ICODE).
sahilmgandhi 18:6a4db94011d3 44
sahilmgandhi 18:6a4db94011d3 45 FUNCALL __cmain, __low_level_init
sahilmgandhi 18:6a4db94011d3 46 bl __low_level_init
sahilmgandhi 18:6a4db94011d3 47 cmp r0,#0
sahilmgandhi 18:6a4db94011d3 48 beq ?l1
sahilmgandhi 18:6a4db94011d3 49 FUNCALL __cmain, __iar_data_init3
sahilmgandhi 18:6a4db94011d3 50 bl __iar_data_init3
sahilmgandhi 18:6a4db94011d3 51 MOVS r0,#0 ; No parameters
sahilmgandhi 18:6a4db94011d3 52 FUNCALL __cmain, mbed_sdk_init
sahilmgandhi 18:6a4db94011d3 53 BL mbed_sdk_init
sahilmgandhi 18:6a4db94011d3 54 MOVS r0,#0 ; No parameters
sahilmgandhi 18:6a4db94011d3 55 FUNCALL __cmain, __iar_dynamic_initialization
sahilmgandhi 18:6a4db94011d3 56 BL __iar_dynamic_initialization ; C++ dynamic initialization
sahilmgandhi 18:6a4db94011d3 57
sahilmgandhi 18:6a4db94011d3 58 ?l1:
sahilmgandhi 18:6a4db94011d3 59 REQUIRE ?l3
sahilmgandhi 18:6a4db94011d3 60
sahilmgandhi 18:6a4db94011d3 61 SECTION .text:CODE:NOROOT(2)
sahilmgandhi 18:6a4db94011d3 62
sahilmgandhi 18:6a4db94011d3 63 PUBLIC _main
sahilmgandhi 18:6a4db94011d3 64 PUBLIC _call_main
sahilmgandhi 18:6a4db94011d3 65 THUMB
sahilmgandhi 18:6a4db94011d3 66
sahilmgandhi 18:6a4db94011d3 67 __iar_init$$done: ; Copy initialization is done
sahilmgandhi 18:6a4db94011d3 68
sahilmgandhi 18:6a4db94011d3 69 ?l3:
sahilmgandhi 18:6a4db94011d3 70 _call_main:
sahilmgandhi 18:6a4db94011d3 71 MOVS r0,#0 ; No parameters
sahilmgandhi 18:6a4db94011d3 72 FUNCALL __cmain, __iar_argc_argv
sahilmgandhi 18:6a4db94011d3 73 BL __iar_argc_argv ; Maybe setup command line
sahilmgandhi 18:6a4db94011d3 74
sahilmgandhi 18:6a4db94011d3 75 FUNCALL __cmain, main
sahilmgandhi 18:6a4db94011d3 76 BL main
sahilmgandhi 18:6a4db94011d3 77 _main:
sahilmgandhi 18:6a4db94011d3 78 FUNCALL __cmain, exit
sahilmgandhi 18:6a4db94011d3 79 BL exit
sahilmgandhi 18:6a4db94011d3 80
sahilmgandhi 18:6a4db94011d3 81 END