Cortex-M3 内部寄存器

本文摘录于:http://blog.****.net/sagitta_zl/article/details/51318507
Cortex-M3 内部寄存器

The IPSR contains the current executing interrupt service routine (ISR) number. Each exception on the Cortex-M0 processor has a unique associated ISR number (exception type). This is useful for identifying the current interrupt type during debugging and allows an exception handler that is shared by several exceptions to know what exception it is serving.

注意:ISR Number从0开始排列,system_tick为16,NVIC外部中断从17开始

 

 

Cortex-M3 内部寄存器

关于LR寄存器这里做更多的解释:

Cortex-M3 内部寄存器

也就是说在Thumb指令集下LR寄存器中的地址比返回地址多了一个1,比如:LR为0x10008E59,那么表示返回的地方就是0x10008E58

另外对于编译而言有这些规则:

r0-r3    用作传入函数参数,传出函数返回值。在子程序调用之间,可以将 r0-r3 用于任何用途。

            被调用函数在返回之前不必恢复 r0-r3。如果调用函数需要再次使用 r0-r3 的内容,则它必须保留这些内容。

r4-r11 被用来存放函数的局部变量。如果被调用函数使用了这些寄存器,它在返回之前必须恢复这些寄存器的值。

r12        是内部调用暂时寄存器 ip。它在过程链接胶合代码(例如,交互操作胶合代码)中用于此角色。
             

在过程调用之间,可以将它用于任何用途。被调用函数在返回之前不必恢复 r12。

13        是栈指针 sp。它不能用于任何其它用途。sp 中存放的值在退出被调用函数时必须与进入时的值相同。

r14        是链接寄存器 lr。如果您保存了返回地址,则可以在调用之间将 r14 用于其它用途,程序返回时要恢复

r15        是程序计数器 PC。它不能用于任何其它用途。
     

注意:在中断程序中,所有的寄存器都必须保护,编译器会自动保护R4~R11