初级会员

- 积分
- 78
- 金钱
- 78
- 注册时间
- 2015-6-3
- 在线时间
- 8 小时
|
5金钱
最近在看《ARM Cortex-M3权威指南》这本书,看到第3章3.14节链接结存器的时候有些迷惑,特来请教。原文如下:
Despite the fact that bit 0 of the program counter is always 0 (because instructions are word
aligned or half word aligned), the LR bit 0 is readable and writable. This is because in the
Thumb instruction set, bit 0 is often used to indicate ARM/Thumb states. To allow the
Thumb-2 program for the Cortex-M3 to work with other ARM processors that support
the Thumb-2 instruction set, this LSB is writable and readable.(原著)
尽管 PC 的 LSB 总是 0(因为代码至少是字对齐的), LR 的 LSB 却是可读可写的。这是历
史遗留的产物。在以前,由位 0 来指示 ARM/Thumb 状态。因为其它有些 ARM 处理器支持
ARM 和 Thumb 状态并存,为了方便汇编程序移植, CM3 需要允许 LSB 可读可写。(译文)
我的问题是:在以前,Thumb指令集中,由位 0 来指示 ARM/Thumb 状态,这点没问题。为了方便移植,Thumb2指令集中指令的第0位设置为可读可写,但是链接寄存器LR保存的是指令的地址,并不是指令本身,为什么要让一个指令地址的第0位可读可写呢?
|
|