Stack problem

MSR     PSP, R0; 
BX LR

When an abnormal condition, two values ​​we need is a pc, one is LR, find the stack by LR, through the stack to find pc

1, 
if LR = 0xFFFFFFF9 instructions for use when an exception is MSP, we only need to read the current value of sp,

sp + = 0x1c; contents read out of the stack is the voltage value when an abnormality of the PC, this value with the inverse assembler codes contrast can be obtained on exceptions generated which sentence.

2, 
the use of time if LR = 0xFFFFFFFD out an exception is the PSP, we need to read the value of the PSP, do not directly read the value of sp, in keil integrated development environment, debugging registers the window there is a Banked option will the value of the current PSP, of course, can also be added in the exception handling two words:

MRS R0,PSP

We can get in the current MSP, the value of our PSP's, and after the operation the same as above, psp + = 0x1c;
the contents read out is generating value onto the stack of abnormal PC, this value with the disassembled code comparison, on specific abnormality can be obtained in which sentence generation.

Released six original articles · won praise 0 · Views 514

Guess you like

Origin blog.csdn.net/qq_34492122/article/details/100162555