Sree Ranjani
Sree Ranjani

Reputation: 65

What is the expansion of the MSR and MRS instructions in ARM

I am learning ARM and I am not able to understand the full form of Program Status Register Instructions, MSR and MRS.

Example:

MRS R0,CPSR         ; Take a copy of the CPSR.
BIC R0,R0,#0x1F     ; Clear the mode bits.
ORR R0,R0,#new_mode ; Select new mode
MSR CPSR,R0         ; Write back the modified CPSR.

Upvotes: 3

Views: 21534

Answers (1)

Sean Houlihane
Sean Houlihane

Reputation: 1789

The first port of call for ARM instruction set questions is the relevant ARM Architecture Manual. For example, Cortex-M3 uses ARMv7-M.

There you can find:

B5.2.2 MRS Move to Register from Special Register

moves the value from the selected special-purpose register into a general-purpose register.

There are lists of the particular special purpose registers in various places, such as this article, and more definitavely in the architecture manual and the Technical Reference Manual (TRM) for the specific core used in your SoC.

Special Purpose Registers are architecturally defined internal state of the processor, such as the ALU flags, the exception model state, security controls, etc. These are distinct from the r0-r14 'general purpose' registers which are available to the main part of the instruction set. The processor security model will generally restrict access to much of this state (so user code can't escalate it's own priviledge).

Specific instructions are used to access the special purpose registers (and closely linked the co-processor registers) partly so that the relevant permission checks can be provided, and partly to increase the addressable space (at the cost of only providing two types of operation).

Upvotes: 8

Related Questions