85: Vectors LDR PC, Reset_Addr ;加载Reset_Addr到寄存器PC中 0x00000000 E59FF018 LDR PC,[PC,#0x0018] ;这里是将PC+0x0018地址处的数据读出保存到PC,一开始PC=0,那么PC+0x0018后就是0x0018,就是说完成这语句后,程序要跳到0x0018该地址了,但是从LDR PC, Reset_Addr 来看,是要跳到Reset_Addr该地址处(0x00000020 00000058 DD 0x00000058).那这样不是错了吗? 86: LDR PC, Undef_Addr 0x00000004 E59FF018 LDR PC,[PC,#0x0018] 87: LDR PC, SWI_Addr 0x00000008 E59FF018 LDR PC,[PC,#0x0018] 88: LDR PC, PAbt_Addr 0x0000000C E59FF018 LDR PC,[PC,#0x0018] 89: LDR PC, DAbt_Addr 0x00000010 E59FF018 LDR PC,[PC,#0x0018] 90: NOP ; Reserved Vector 91: ; LDR PC, IRQ_Addr 0x00000014 E1A00000 NOP 92: LDR PC, [PC, #-0x0120] ; Vector from VicVectAddr 0x00000018 E51FF120 LDR PC,[PC,#-0x0120] 93: LDR PC, FIQ_Addr 94: 95: Reset_Addr DCD Reset_Handler ;将Reset_Handler加载到当前地址Reset_Addr上 96: Undef_Addr DCD Undef_Handler 97: SWI_Addr DCD SWI_Handler 98: PAbt_Addr DCD PAbt_Handler 99: DAbt_Addr DCD DAbt_Handler 100: DCD 0xB9206E28 ; Reserved Address 101: IRQ_Addr DCD IRQ_Handler 102: FIQ_Addr DCD FIQ_Handler 103: 0x0000001C E59FF018 LDR PC,[PC,#0x0018] 0x00000020 00000058 DD 0x00000058 0x00000024 00000040 DD 0x00000040 0x00000028 00000044 DD 0x00000044 0x0000002C 00000048 DD 0x00000048 0x00000030 0000004C DD 0x0000004C 0x00000034 B9206E28 DD 0xB9206E28 0x00000038 00000050 DD 0x00000050 0x0000003C 00000054 DD 0x00000054 104: Undef_Handler B Undef_Handler 0x00000040 EAFFFFFE B 0x00000040 105: SWI_Handler B SWI_Handler 0x00000044 EAFFFFFE B 0x00000044 106: PAbt_Handler B PAbt_Handler 0x00000048 EAFFFFFE B 0x00000048 107: DAbt_Handler B DAbt_Handler 0x0000004C EAFFFFFE B 0x0000004C 108: IRQ_Handler B IRQ_Handler 0x00000050 EAFFFFFE B 0x00000050 109: FIQ_Handler B FIQ_Handler 110: 111: ; Reset Handler 112: 113: EXPORT Reset_Handler 114: Reset_Handler 115: 116: ; Setup Stack for each mode 0x00000054 EAFFFFFE B 0x00000054 117: LDR R0, =Stack_Top 118: 119: ; Enter Undefined Instruction Mode and set its Stack Pointer 0x00000058 E59F0050 LDR R0,[PC,#0x0050] 120: MSR CPSR_c, #Mode_UND:OR:I_Bit:OR:F_Bit ; :OR: Mode_UND,I_Bit,F_Bit之间按位作逻辑或操作,设置未定义模式,禁止FIQ,IRQ 0x0000005C E321F0DB MSR CPSR_c,#0x000000DB 121: MOV SP, R0 ;堆指针指向栈顶 0x00000060 E1A0D000 MOV R13,R0 122: SUB R0, R0, #UND_Stack_Size ;把减去"未定义模式的栈"大小后的地址存放在R0(那么从开始的栈顶到该地址之间的大小为未定义模式分配的栈的大小),R0只是一个存放东西的容器,它会随着存放内容同而更新自己的值 123: 124: ; Enter Abort Mode and set its Stack Pointer 0x00000064 E2400000 SUB R0,R0,#0x00000000 125: MSR CPSR_c, #Mode_ABT:OR:I_Bit:OR:F_Bit 0x00000068 E321F0D7 MSR CPSR_c,#0x000000D7 126: MOV SP, R0 ;ABT模式的栈指针指向R0中存放的地址 0x0000006C E1A0D000 MOV R13,R0 127: SUB R0, R0, #ABT_Stack_Size ;分配ABT模式的栈大小, 128: 129: ; Enter FIQ Mode and set its Stack Pointer 0x00000070 E2400000 SUB R0,R0,#0x00000000 130: MSR CPSR_c, #Mode_FIQ:OR:I_Bit:OR:F_Bit 0x00000074 E321F0D1 MSR CPSR_c,#0x000000D1 131: MOV SP, R0 0x00000078 E1A0D000 MOV R13,R0 132: SUB R0, R0, #FIQ_Stack_Size 133: 134: ; Enter IRQ Mode and set its Stack Pointer 0x0000007C E2400000 SUB R0,R0,#0x00000000 135: MSR CPSR_c, #Mode_IRQ:OR:I_Bit:OR:F_Bit 0x00000080 E321F0D2 MSR CPSR_c,#0x000000D2 136: MOV SP, R0 0x00000084 E1A0D000 MOV R13,R0 137: SUB R0, R0, #IRQ_Stack_Size 138: 139: ; Enter Supervisor Mode and set its Stack Pointer 0x00000088 E2400C01 SUB R0,R0,#0x00000100 140: MSR CPSR_c, #Mode_SVC:OR:I_Bit:OR:F_Bit 0x0000008C E321F0D3 MSR CPSR_c,#0x000000D3 141: MOV SP, R0 0x00000090 E1A0D000 MOV R13,R0 142: SUB R0, R0, #SVC_Stack_Size ;分配管理模式堆栈的大小,R0现在存储着该堆栈的最底下地址(栈底) 143: 144: ; Enter User Mode and set its Stack Pointer 0x00000094 E2400C01 SUB R0,R0,#0x00000100 145: MSR CPSR_c, #Mode_USR 0x00000098 E321F010 MSR CPSR_c,#0x00000010 146: MOV SP, R0 0x0000009C E1A0D000 MOV R13,R0 147: SUB SL, SP, #USR_Stack_Size ;到这里,所有模式的堆栈已经分配好,SL存储着用户模式堆栈的最底下地址(栈底) |