Mouse code for the MacroRat
mbed-dev/targets/TARGET_NXP/TARGET_LPC2460/device/TOOLCHAIN_GCC_ARM/vector_functions.S@46:b156ef445742, 2017-06-03 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /* .include "vector_defns.h" */ |
sahilmgandhi | 18:6a4db94011d3 | 2 | |
sahilmgandhi | 18:6a4db94011d3 | 3 | |
sahilmgandhi | 18:6a4db94011d3 | 4 | |
sahilmgandhi | 18:6a4db94011d3 | 5 | .section .privileged_code, "ax" |
sahilmgandhi | 18:6a4db94011d3 | 6 | .arm |
sahilmgandhi | 18:6a4db94011d3 | 7 | |
sahilmgandhi | 18:6a4db94011d3 | 8 | |
sahilmgandhi | 18:6a4db94011d3 | 9 | .weak __mbed_fiq |
sahilmgandhi | 18:6a4db94011d3 | 10 | .weak __mbed_undef |
sahilmgandhi | 18:6a4db94011d3 | 11 | .weak __mbed_prefetch_abort |
sahilmgandhi | 18:6a4db94011d3 | 12 | .weak __mbed_data_abort |
sahilmgandhi | 18:6a4db94011d3 | 13 | .weak __mbed_irq |
sahilmgandhi | 18:6a4db94011d3 | 14 | .weak __mbed_swi |
sahilmgandhi | 18:6a4db94011d3 | 15 | .weak __mbed_dcc_irq |
sahilmgandhi | 18:6a4db94011d3 | 16 | .weak __mbed_reset |
sahilmgandhi | 18:6a4db94011d3 | 17 | .global __mbed_init_realmonitor |
sahilmgandhi | 18:6a4db94011d3 | 18 | .weak SVC_Handler |
sahilmgandhi | 18:6a4db94011d3 | 19 | .weak IRQ_Handler |
sahilmgandhi | 18:6a4db94011d3 | 20 | /* .global __mbed_init */ |
sahilmgandhi | 18:6a4db94011d3 | 21 | |
sahilmgandhi | 18:6a4db94011d3 | 22 | |
sahilmgandhi | 18:6a4db94011d3 | 23 | |
sahilmgandhi | 18:6a4db94011d3 | 24 | |
sahilmgandhi | 18:6a4db94011d3 | 25 | __mbed_fiq: |
sahilmgandhi | 18:6a4db94011d3 | 26 | B __mbed_fiq |
sahilmgandhi | 18:6a4db94011d3 | 27 | __mbed_undef: |
sahilmgandhi | 18:6a4db94011d3 | 28 | LDR PC, =0x7fffffa0 |
sahilmgandhi | 18:6a4db94011d3 | 29 | __mbed_prefetch_abort: |
sahilmgandhi | 18:6a4db94011d3 | 30 | LDR PC, =0x7fffffb0 |
sahilmgandhi | 18:6a4db94011d3 | 31 | __mbed_data_abort: |
sahilmgandhi | 18:6a4db94011d3 | 32 | LDR PC, =0x7fffffc0 |
sahilmgandhi | 18:6a4db94011d3 | 33 | __mbed_irq: |
sahilmgandhi | 18:6a4db94011d3 | 34 | /* |
sahilmgandhi | 18:6a4db94011d3 | 35 | If RTOS is enabled then goto RTOS IRQ handler |
sahilmgandhi | 18:6a4db94011d3 | 36 | */ |
sahilmgandhi | 18:6a4db94011d3 | 37 | PUSH {R0} |
sahilmgandhi | 18:6a4db94011d3 | 38 | LDR R0, =IRQ_Handler |
sahilmgandhi | 18:6a4db94011d3 | 39 | CMP R0, #0 |
sahilmgandhi | 18:6a4db94011d3 | 40 | POP {R0} |
sahilmgandhi | 18:6a4db94011d3 | 41 | BNE IRQ_Handler |
sahilmgandhi | 18:6a4db94011d3 | 42 | /* |
sahilmgandhi | 18:6a4db94011d3 | 43 | else use CMSIS IRQ handler |
sahilmgandhi | 18:6a4db94011d3 | 44 | */ |
sahilmgandhi | 18:6a4db94011d3 | 45 | MSR CPSR_c, #0x1F|0x80|0x40 |
sahilmgandhi | 18:6a4db94011d3 | 46 | |
sahilmgandhi | 18:6a4db94011d3 | 47 | STMDB sp!, {r0-r3,r12,lr} |
sahilmgandhi | 18:6a4db94011d3 | 48 | |
sahilmgandhi | 18:6a4db94011d3 | 49 | MOV r0, #0xFFFFFF00 |
sahilmgandhi | 18:6a4db94011d3 | 50 | LDR r0, [r0] |
sahilmgandhi | 18:6a4db94011d3 | 51 | |
sahilmgandhi | 18:6a4db94011d3 | 52 | MOV lr, pc |
sahilmgandhi | 18:6a4db94011d3 | 53 | BX r0 |
sahilmgandhi | 18:6a4db94011d3 | 54 | |
sahilmgandhi | 18:6a4db94011d3 | 55 | MOV r0, #0xFFFFFF00 |
sahilmgandhi | 18:6a4db94011d3 | 56 | STR r0, [r0] |
sahilmgandhi | 18:6a4db94011d3 | 57 | |
sahilmgandhi | 18:6a4db94011d3 | 58 | LDMFD sp!,{r0-r3,r12,lr} |
sahilmgandhi | 18:6a4db94011d3 | 59 | |
sahilmgandhi | 18:6a4db94011d3 | 60 | MSR CPSR_c, #0x12|0x80|0x40 |
sahilmgandhi | 18:6a4db94011d3 | 61 | |
sahilmgandhi | 18:6a4db94011d3 | 62 | SUBS pc, lr, #4 |
sahilmgandhi | 18:6a4db94011d3 | 63 | |
sahilmgandhi | 18:6a4db94011d3 | 64 | __mbed_swi: |
sahilmgandhi | 18:6a4db94011d3 | 65 | /* |
sahilmgandhi | 18:6a4db94011d3 | 66 | If RTOS is enabled then goto RTOS SVC handler |
sahilmgandhi | 18:6a4db94011d3 | 67 | */ |
sahilmgandhi | 18:6a4db94011d3 | 68 | PUSH {R0} |
sahilmgandhi | 18:6a4db94011d3 | 69 | LDR R0, =SVC_Handler |
sahilmgandhi | 18:6a4db94011d3 | 70 | CMP R0, #0 |
sahilmgandhi | 18:6a4db94011d3 | 71 | POP {R0} |
sahilmgandhi | 18:6a4db94011d3 | 72 | BNE SVC_Handler |
sahilmgandhi | 18:6a4db94011d3 | 73 | /* |
sahilmgandhi | 18:6a4db94011d3 | 74 | else use CMSIS SVC handler |
sahilmgandhi | 18:6a4db94011d3 | 75 | */ |
sahilmgandhi | 18:6a4db94011d3 | 76 | STMFD sp!, {a4, r4, ip, lr} |
sahilmgandhi | 18:6a4db94011d3 | 77 | |
sahilmgandhi | 18:6a4db94011d3 | 78 | LDR r4, =0x40000040 |
sahilmgandhi | 18:6a4db94011d3 | 79 | |
sahilmgandhi | 18:6a4db94011d3 | 80 | LDR a4, =0x00940000 |
sahilmgandhi | 18:6a4db94011d3 | 81 | LDR PC, =0x7ffff820 |
sahilmgandhi | 18:6a4db94011d3 | 82 | |
sahilmgandhi | 18:6a4db94011d3 | 83 | __mbed_dcc_irq: |
sahilmgandhi | 18:6a4db94011d3 | 84 | LDMFD sp!,{r0-r3,r12,lr} |
sahilmgandhi | 18:6a4db94011d3 | 85 | |
sahilmgandhi | 18:6a4db94011d3 | 86 | MSR CPSR_c, #0x12|0x80|0x40 |
sahilmgandhi | 18:6a4db94011d3 | 87 | |
sahilmgandhi | 18:6a4db94011d3 | 88 | SUB lr, lr, #4 |
sahilmgandhi | 18:6a4db94011d3 | 89 | STMFD sp!, {ip,lr} |
sahilmgandhi | 18:6a4db94011d3 | 90 | |
sahilmgandhi | 18:6a4db94011d3 | 91 | LDR LR, =0xfffff000 |
sahilmgandhi | 18:6a4db94011d3 | 92 | STR LR, [LR, #0xf00] |
sahilmgandhi | 18:6a4db94011d3 | 93 | |
sahilmgandhi | 18:6a4db94011d3 | 94 | LDR PC, =0x7fffffe0 |
sahilmgandhi | 18:6a4db94011d3 | 95 | /* |
sahilmgandhi | 18:6a4db94011d3 | 96 | __mbed_reset is called after reset |
sahilmgandhi | 18:6a4db94011d3 | 97 | we setup the stacks and realmonitor, then call Reset_Handler like on M3 |
sahilmgandhi | 18:6a4db94011d3 | 98 | */ |
sahilmgandhi | 18:6a4db94011d3 | 99 | |
sahilmgandhi | 18:6a4db94011d3 | 100 | .section .text, "ax" |
sahilmgandhi | 18:6a4db94011d3 | 101 | .arm |
sahilmgandhi | 18:6a4db94011d3 | 102 | .global Reset_handler |
sahilmgandhi | 18:6a4db94011d3 | 103 | Reset_Handler: |
sahilmgandhi | 18:6a4db94011d3 | 104 | .extern __libc_init_array |
sahilmgandhi | 18:6a4db94011d3 | 105 | .extern SystemInit |
sahilmgandhi | 18:6a4db94011d3 | 106 | .weak software_init_hook |
sahilmgandhi | 18:6a4db94011d3 | 107 | LDR R0, =SystemInit |
sahilmgandhi | 18:6a4db94011d3 | 108 | MOV LR, PC |
sahilmgandhi | 18:6a4db94011d3 | 109 | BX R0 |
sahilmgandhi | 18:6a4db94011d3 | 110 | |
sahilmgandhi | 18:6a4db94011d3 | 111 | /* if (software_init_hook) // give control to the RTOS |
sahilmgandhi | 18:6a4db94011d3 | 112 | software_init_hook(); // this will also call __libc_init_array |
sahilmgandhi | 18:6a4db94011d3 | 113 | */ |
sahilmgandhi | 18:6a4db94011d3 | 114 | LDR R0, =software_init_hook |
sahilmgandhi | 18:6a4db94011d3 | 115 | CMP R0, #0 |
sahilmgandhi | 18:6a4db94011d3 | 116 | BEQ nortos |
sahilmgandhi | 18:6a4db94011d3 | 117 | ORR R0,R0,#1 /* set thumb address */ |
sahilmgandhi | 18:6a4db94011d3 | 118 | BX R0 |
sahilmgandhi | 18:6a4db94011d3 | 119 | /* else */ |
sahilmgandhi | 18:6a4db94011d3 | 120 | nortos: |
sahilmgandhi | 18:6a4db94011d3 | 121 | LDR R0, =__libc_init_array |
sahilmgandhi | 18:6a4db94011d3 | 122 | MOV LR, PC |
sahilmgandhi | 18:6a4db94011d3 | 123 | BX R0 |
sahilmgandhi | 18:6a4db94011d3 | 124 | |
sahilmgandhi | 18:6a4db94011d3 | 125 | MSR CPSR_c, #0x1F /* enable irq */ |
sahilmgandhi | 18:6a4db94011d3 | 126 | |
sahilmgandhi | 18:6a4db94011d3 | 127 | LDR R0, =main |
sahilmgandhi | 18:6a4db94011d3 | 128 | BX R0 |
sahilmgandhi | 18:6a4db94011d3 | 129 | |
sahilmgandhi | 18:6a4db94011d3 | 130 | __mbed_reset: |
sahilmgandhi | 18:6a4db94011d3 | 131 | LDR R0, =( __SRAM_segment_end__ ) |
sahilmgandhi | 18:6a4db94011d3 | 132 | |
sahilmgandhi | 18:6a4db94011d3 | 133 | MSR CPSR_c, #0x1B|0x80|0x40 |
sahilmgandhi | 18:6a4db94011d3 | 134 | MOV SP, R0 |
sahilmgandhi | 18:6a4db94011d3 | 135 | SUB R0, R0, #0x00000040 |
sahilmgandhi | 18:6a4db94011d3 | 136 | |
sahilmgandhi | 18:6a4db94011d3 | 137 | MSR CPSR_c, #0x17|0x80|0x40 |
sahilmgandhi | 18:6a4db94011d3 | 138 | MOV SP, R0 |
sahilmgandhi | 18:6a4db94011d3 | 139 | SUB R0, R0, #0x00000040 |
sahilmgandhi | 18:6a4db94011d3 | 140 | |
sahilmgandhi | 18:6a4db94011d3 | 141 | MSR CPSR_c, #0x11|0x80|0x40 |
sahilmgandhi | 18:6a4db94011d3 | 142 | MOV SP, R0 |
sahilmgandhi | 18:6a4db94011d3 | 143 | SUB R0, R0, #0x00000040 |
sahilmgandhi | 18:6a4db94011d3 | 144 | |
sahilmgandhi | 18:6a4db94011d3 | 145 | MSR CPSR_c, #0x12|0x80|0x40 |
sahilmgandhi | 18:6a4db94011d3 | 146 | MOV SP, R0 |
sahilmgandhi | 18:6a4db94011d3 | 147 | SUB R0, R0, #0x00000040 |
sahilmgandhi | 18:6a4db94011d3 | 148 | |
sahilmgandhi | 18:6a4db94011d3 | 149 | MSR CPSR_c, #0x13|0x80|0x40 |
sahilmgandhi | 18:6a4db94011d3 | 150 | MOV SP, R0 |
sahilmgandhi | 18:6a4db94011d3 | 151 | SUB R0, R0, #0x00000040 |
sahilmgandhi | 18:6a4db94011d3 | 152 | |
sahilmgandhi | 18:6a4db94011d3 | 153 | /* |
sahilmgandhi | 18:6a4db94011d3 | 154 | MSR CPSR_c, #0x10|0x80|0x40 |
sahilmgandhi | 18:6a4db94011d3 | 155 | MOV SP, R0 |
sahilmgandhi | 18:6a4db94011d3 | 156 | */ |
sahilmgandhi | 18:6a4db94011d3 | 157 | MSR CPSR_c, #0x1F|0x80|0x40 |
sahilmgandhi | 18:6a4db94011d3 | 158 | MOV SP, R0 |
sahilmgandhi | 18:6a4db94011d3 | 159 | |
sahilmgandhi | 18:6a4db94011d3 | 160 | MSR CPSR_c, #0x13|0x80|0x40 /* execute in Supervisor mode */ |
sahilmgandhi | 18:6a4db94011d3 | 161 | |
sahilmgandhi | 18:6a4db94011d3 | 162 | /* Relocate .data section (Copy from ROM to RAM) */ |
sahilmgandhi | 18:6a4db94011d3 | 163 | LDR R1, =__text_end__ /* _etext */ |
sahilmgandhi | 18:6a4db94011d3 | 164 | LDR R2, =__data_start__ /* _data */ |
sahilmgandhi | 18:6a4db94011d3 | 165 | LDR R3, =__data_end__ /* _edata */ |
sahilmgandhi | 18:6a4db94011d3 | 166 | CMP R2, R3 |
sahilmgandhi | 18:6a4db94011d3 | 167 | BEQ DataIsEmpty |
sahilmgandhi | 18:6a4db94011d3 | 168 | LoopRel: CMP R2, R3 |
sahilmgandhi | 18:6a4db94011d3 | 169 | LDRLO R0, [R1], #4 |
sahilmgandhi | 18:6a4db94011d3 | 170 | STRLO R0, [R2], #4 |
sahilmgandhi | 18:6a4db94011d3 | 171 | BLO LoopRel |
sahilmgandhi | 18:6a4db94011d3 | 172 | DataIsEmpty: |
sahilmgandhi | 18:6a4db94011d3 | 173 | |
sahilmgandhi | 18:6a4db94011d3 | 174 | /* Clear .bss section (Zero init) */ |
sahilmgandhi | 18:6a4db94011d3 | 175 | MOV R0, #0 |
sahilmgandhi | 18:6a4db94011d3 | 176 | LDR R1, =__bss_start__ |
sahilmgandhi | 18:6a4db94011d3 | 177 | LDR R2, =__bss_end__ |
sahilmgandhi | 18:6a4db94011d3 | 178 | CMP R1,R2 |
sahilmgandhi | 18:6a4db94011d3 | 179 | BEQ BSSIsEmpty |
sahilmgandhi | 18:6a4db94011d3 | 180 | LoopZI: CMP R1, R2 |
sahilmgandhi | 18:6a4db94011d3 | 181 | STRLO R0, [R1], #4 |
sahilmgandhi | 18:6a4db94011d3 | 182 | BLO LoopZI |
sahilmgandhi | 18:6a4db94011d3 | 183 | BSSIsEmpty: |
sahilmgandhi | 18:6a4db94011d3 | 184 | |
sahilmgandhi | 18:6a4db94011d3 | 185 | |
sahilmgandhi | 18:6a4db94011d3 | 186 | /* Init realmonitor */ |
sahilmgandhi | 18:6a4db94011d3 | 187 | /* |
sahilmgandhi | 18:6a4db94011d3 | 188 | LDR R0, =__mbed_init_realmonitor |
sahilmgandhi | 18:6a4db94011d3 | 189 | MOV LR, PC |
sahilmgandhi | 18:6a4db94011d3 | 190 | BX R0 |
sahilmgandhi | 18:6a4db94011d3 | 191 | */ |
sahilmgandhi | 18:6a4db94011d3 | 192 | |
sahilmgandhi | 18:6a4db94011d3 | 193 | /* Go to Reset_Handler */ |
sahilmgandhi | 18:6a4db94011d3 | 194 | LDR R0, =Reset_Handler |
sahilmgandhi | 18:6a4db94011d3 | 195 | BX R0 |