📄 init_a.s
字号:
; *********************************
; LPC22XX SYSTEM WITHOUT OS
; FILE: INIT_A.S
; MODIFIED: ZPCYP 2005-3-16 20:16
; *********************************
; This module initializes stack pointers for each mode,
; and branches to __main in the C library (which eventually calls main()).
;
; On reset, the ARM core starts up in Supervisor (SVC) mode, in ARM state,
; with IRQ and FIQ disabled.
; Note: Lines started with ";//" are configuration items in Keil UV3. :-)
;//*** <<< Use Configuration Wizard in Context Menu >>> ***
; Stack sizes configuration
;// <h> Stack Sizes (in Bytes)
;// <o0> Undefined Mode <0x0-0xFFFFFFFF>
;// <o1> Supervisor Mode <0x0-0xFFFFFFFF>
;// <o2> Abort Mode <0x0-0xFFFFFFFF>
;// <o3> Fast Interrupt Mode <0x0-0xFFFFFFFF>
;// <o4> Interrupt Mode <0x0-0xFFFFFFFF>
;// <o5> User/System Mode <0x0-0xFFFFFFFF>
;// </h>
UND_Stack_Size EQU 0x00000000
SVC_Stack_Size EQU 0x00000000
ABT_Stack_Size EQU 0x00000000
FIQ_Stack_Size EQU 0x00000000
IRQ_Stack_Size EQU 0x00000400
SYS_Stack_Size EQU 0x00000400 ; No need to conf in fact, retarget.c deals this
; Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs
Mode_USR EQU 0x20
Mode_FIQ EQU 0x11
Mode_IRQ EQU 0x12
Mode_SVC EQU 0x13
Mode_ABT EQU 0x17
Mode_UND EQU 0x1B
Mode_SYS EQU 0x1F
I_Bit EQU 0x80 ; when I bit is set, IRQ is disabled
F_Bit EQU 0x40 ; when F bit is set, FIQ is disabled
AREA Init, CODE, READONLY
; *******************
; Reset Handler
; *******************
ENTRY
IMPORT Top_Stack ; defined in stack.s and located by scatter file
IMPORT __main ; entry to C code
EXPORT Reset_Handler
Reset_Handler
; Setup Stack for each mode
LDR R0, =Top_Stack
; Enter Undefined Instruction Mode and set its Stack Pointer
MSR CPSR_c, #Mode_UND:OR:I_Bit:OR:F_Bit
MOV SP, R0
SUB R0, R0, #UND_Stack_Size
; Enter Abort Mode and set its Stack Pointer
MSR CPSR_c, #Mode_ABT:OR:I_Bit:OR:F_Bit
MOV SP, R0
SUB R0, R0, #ABT_Stack_Size
; Enter FIQ Mode and set its Stack Pointer
MSR CPSR_c, #Mode_FIQ:OR:I_Bit:OR:F_Bit
MOV SP, R0
SUB R0, R0, #FIQ_Stack_Size
; Enter IRQ Mode and set its Stack Pointer
MSR CPSR_c, #Mode_IRQ:OR:I_Bit:OR:F_Bit
MOV SP, R0
SUB R0, R0, #IRQ_Stack_Size
; Enter Supervisor Mode and set its Stack Pointer
MSR CPSR_c, #Mode_SVC:OR:I_Bit:OR:F_Bit
MOV SP, R0
SUB R0, R0, #SVC_Stack_Size
; Enter System Mode and set its Stack Pointer (of User Mode too)
MSR CPSR_c, #Mode_SYS
MOV SP, R0
; ****************************************************************
; Stay in System Mode finally (with IRQ and FIQ enabled).
; System Mode is the default Mode running tasks.
; ****************************************************************
; Enter the C code
B __main
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -