1 __asm void prvStartFirstTask( void ) 2 { 3 /* *INDENT-OFF* */ 4 PRESERVE8 5 6 /* Use the NVIC offset register to locate the stack. */ 7 ldr r0, =0xE000ED08 // 将 0xE000ED08 加载到 R0 8 ldr r0, [ r0 ] // 将 0xE000ED08 地址中的值,也就是向量表的实际地址加载到 R0 9 ldr r0, [ r0 ] // 根据向量表实际存储地址,取出向量表中的第一项,向量表第一项存储主堆栈指针 MSP 的初始值 10 /* Set the msp back to the start of the stack. */ 11 msr msp, r0 // 将 MSP 的初始值写入 MSP 中 12 13 /* Clear the bit that indicates the FPU is in use in case the FPU was used 14 * before the scheduler was started - which would otherwise result in the 15 * unnecessary leaving of space in the SVC stack for lazy saving of FPU 16 * registers. */ 17 mov r0, #0 18 msr control, r0 19 /* Globally enable interrupts. */ 20 cpsie i 21 cpsie f 22 dsb 23 isb 24 /* Call SVC to start the first task. */ 25 svc 0 26 nop 27 nop 28 /* *INDENT-ON* */ 29 }