ARM Program Status Register 和 相关指令之笔记

【原本发表在网易博客,可博客中的图片经常过段时间后就挂掉了,逼我换地方的节奏】

The ARM instruction set provides two instructions to directly control a program status register (psr). The MRS instruction transfers the contents of either the cpsr or spsr into a register; in the reverse direction, the MSR instruction transfers the contents of a register into the cpsr or spsr. Together these instructions are used to read and write the cpsr and spsr.

 

In the syntax you can see a label called fields. This can be any combination of control (c), extension (x), status (s), and flags (f). These fields relate to particular byte regions in a psr, as shown in Figure 3.9.

Syntax: MRS{} Rd,

MSR{} _,Rm

MSR{} _,#immediate


ARM Program Status Register 和 相关指令之笔记_第1张图片


ARM Program Status Register 和 相关指令之笔记_第2张图片


If you use the S suffix on a data processing instruction, then it updates the flags in the cpsr. Move and logical operations update the carry flag C, negative flag N, and zero flag Z. The carry flag is set from the result of the barrel shift as the last bit shifted out. The N flag is set to bit 31 of the result. The Z flag is set if the result is zero.

 

关于下面示例中的话

ARM Program Status Register 和 相关指令之笔记_第3张图片

终于找到了答案: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0344i/Beigeaha.html

2.15.2. Leaving an exception

When an exception has completed, the exception handler must move the LR, minus an offset to the PC. The offset varies according to the type of exception, as Table 2.12 shows.

Typically the return instruction is an arithmetic or logical operation with the S bit set to 1 and rd = r15, so the core copies the SPSR back to the CPSR.


你可能感兴趣的:(ARM Program Status Register 和 相关指令之笔记)