Chinaunix首页 | 论坛 | 博客
  • 博客访问: 162024
  • 博文数量: 63
  • 博客积分: 2961
  • 博客等级: 少校
  • 技术积分: 445
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-21 10:44
文章分类

全部博文(63)

文章存档

2011年(17)

2010年(46)

我的朋友

分类: 嵌入式

2010-10-11 20:17:15

最近遇到了一个^号的问题,纠缠了很久,终于搞清楚了,相当的爽快,甚于赢了几盘三国杀。
 
1.LDM instructions with the PC in the register list and ^ specified cause both bits to be copied from the SPSR to the CPSR and execution to resume in the resulting state.
 
2.instruction that does not load the PC, this indicates that User mode registers are
to be loaded.
 
参考ARM architecture V5 p93, p118
 
也就是说,
a.当涉及到需要向pc赋值的指令时,^表示执行完该指令后,将spsr传递给cpsr,完成状态转换。如ldmfd sp!, {r4 - sl, fp, pc}^。
b.当不需要向pc赋值时,^表示load 用户模式下的寄存器。如ldmdb r8, {sp, lr}^,实际load的是sp_usr和lr_usr。
 
我猜想,对于第二点来说,因为usr模式下不能修改cpsr的值,故当在svc下需要设置usr的sp,lr时,不能通过修改cpsr的值进入usr模式,因为在usr模式下,禁止修改cpsr,故设置完后无法返回svc模式。另一方面是svc能看到所有模式的寄存器,故能直接访问usr的寄存器。
 
 
当然,^号的用法不仅涉及LDM指令,也同样适用于STM指令。
 
 
心得,在网上用goolge找了半天,不如直接看权威英文文档,英文文档里面都写得明明白白。
阅读(804) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~