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
|
/*
* The STARTUP.S code is executed after CPU Reset. This file may be
* translated with the following SET symbols. In uVision these SET
* symbols are entered under Options - ASM - Set.
*
* REMAP: when set the startup code initializes the register MEMMAP
* which overwrites the settings of the CPU configuration pins. The
* startup and interrupt vectors are remapped from:
* 0x00000000 default setting (not remapped)
* 0x80000000 when EXTMEM_MODE is used
* 0x40000000 when RAM_MODE is used
*
* EXTMEM_MODE: when set the device is configured for code execution
* from external memory starting at address 0x80000000. The startup
* vectors are located to 0x80000000.
*
* RAM_MODE: when set the device is configured for code execution
* from on-chip RAM starting at address 0x40000000. The startup
* vectors are located to 0x40000000.
*/
Reset_Handler:
/* Memory Mapping */
/* Setup Stack for each mode */
ldr r0, =Top_Stack
/* Enter Undefined Instruction Mode and set its Stack Pointer */
msr CPSR_c, #UND_MODE | PSR_I_BIT | PSR_F_BIT
mov SP, r0
sub r0, r0, #UND_Stack_Size
/* Enter Abort Mode and set its Stack Pointer */
msr CPSR_c, #ABT_MODE | PSR_I_BIT | PSR_F_BIT
mov SP, r0
sub r0, r0, #ABT_Stack_Size
/* Enter FIQ Mode and set its Stack Pointer */
msr CPSR_c, #FIQ_MODE | PSR_I_BIT | PSR_F_BIT
mov SP, r0
sub r0, r0, #FIQ_Stack_Size
/* Enter IRQ Mode and set its Stack Pointer */
msr CPSR_c, #IRQ_MODE | PSR_I_BIT | PSR_F_BIT
mov SP, r0
sub r0, r0, #IRQ_Stack_Size
/* Enter Supervisor Mode and set its Stack Pointer */
msr CPSR_c, #SVC_MODE | PSR_I_BIT | PSR_F_BIT
mov SP, r0
sub r0, r0, #SVC_Stack_Size
/* Enter User Mode and set its Stack Pointer */
msr CPSR_c, #USR_MODE
mov SP, r0
/* Enter the C code */
ldr r0,=?C?INIT
tst r0,#1 ; Bit-0 set: INIT is Thumb
ldreq LR,=exit?A ; ARM Mode
ldrne LR,=exit?T ; Thumb Mode
bx r0
ENDP
PUBLIC exit?A
exit?A PROC CODE32
B exit?A
ENDP
PUBLIC exit?T
exit?T PROC CODE16
exit: B exit?T
ENDP
END
|