新闻  |   论坛  |   博客  |   在线研讨会
CPSR(当前程序状态寄存器)&SPSR(备份程序状态寄存器)(续)
xiajiashan | 2012-08-29 10:32:44    阅读:2092   发布文章

2.4:ARM进入异常的行为

When handling an exception, the ARM720T processor behaves as follows:

当处理一个异常时,arm720T(arm9,10,11同)有下列行为:

  1. It preserves the address of the next instruction in the appropriate LR.

保存下一条指令地址到LR(链接寄存器)。

  1. It copies the CPSR into the appropriate SPSR.

复制CPSR到SPSR寄存器

  1. It forces the CPSR mode bits to a value that depends on the exception.

根据当前异常模式强制CPSR 模式位设置到一个对应值

翻译整理:下家山(索漫科技培训教材 转载请注明) http://www.xiajiashan.com

4. It forces the PC to fetch the next instruction from the relevant exception vector.

迫使PC获取该异常向量的下一条要执行的指令

It can also set the interrupt disable flags to prevent otherwise unmanageable nestings of

exceptions.

它也能设置中断使能标志来预防其他未知的异常

2.4:ARM退出异常的行为

On completion, the exception handler:

在完成异常处理后:arm将做如下处理

1. Moves the LR, minus an offset where appropriate, to the PC. The offset varies

depending on the type of exception.

移动LR里面保存的地址到PC,以使代码能正常返回到发生异常的地方继续执行。

2. Copies the SPSR back to the CPSR.

拷贝SPSR到CPSR。

  1. Clears the interrupt disable flags, if they were set on entry.

清楚中断标志位

=======================================================================================

By 下家山 Q群 75303301 上海松江文汇路928号258室 松江大学城

上海索漫科技 http://www.xiajiashan.com 专注嵌入式(ARM7,Cortex-M0,Cortex-M3,ARM9,linux)培训

 

三:实例讲解

 

3.1程序最初的模式和状态
1.jpg
3.2设置管理模式后的状态变化

;Build the SVC stack

;设置管理模式堆栈

MSR CPSR_c, #0xd3

LDR SP, StackSvc

2.jpg

 

2.3 设置IRQ中断模式后的状态变化

;Build the IRQ stack

;设置中断模式堆栈

MSR CPSR_c, #0xd2

LDR SP, StackIrq

3.jpg
3.4 设置快速中断模式后的状态变化

;Build the FIQ stack

;设置快速中断模式堆栈

MSR CPSR_c, #0xd1

LDR SP, StackFiq

4.jpg
3.5 设置中止模式后的状态变化

;Build the DATAABORT stack

;设置中止模式堆栈

MSR CPSR_c, #0xd7

LDR SP, StackAbt

5.jpg
3.6 设置未定义模式后的状态变化

;Build the UDF stack

;设置未定义模式堆栈

 

MSR CPSR_c, #0xdb

LDR SP, StackUnd

6.jpg
3.7 设置系统模式后的状态变化

;Build the SYS stack

;设置系统模式堆栈

MSR CPSR_c, #0xdf

LDR SP, =StackSys

7.jpg
3.8 思考问题

在上述过程中,为什么SPSR的值一值是nzcvqift_User?????

3.9 思考问题

当设置系统模式的时候,为什么SPSR显示Unavailable?????

3.a 思考问题

上述过程中,为什么没有设置用户模式????

翻译整理:下家山(上海索漫科技培训教材 转载请注明)http://www.xiajiashan.com

 

2012-6-19

写于上海松江

 

 

*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
02年接触ARM和ucos,开发过有线和无线图像报警器,IPCamera,人脸识别系统,OCR识别系统,指纹识别系统,05年开始从事Linux及Rtems下WiFi,camera,Ethernet等驱动开发工作,专做嵌入式linux培训,致力于把我十年来的研发经验传授给每一个学员,招人的可以找我,ximenpiaoxue4016@sina.com
推荐文章
最近访客