Topic : MSR and MRS instruction

Forum : ARM

Original Post
Post Information Post
November 25, 2010 - 2:25pm

I have been trying to use MSR and MRS. But somehow when I read any special register the value loaded in the register is 0.
For eg: in the code below
I have CONTROL register = 0 (thus I am executing the thread in privileged mode).
But still the value loaded in r0 is always 0. This is even true for apsr which doesn't need a privileged mode to be read.

int main (void)
asm("mrs r0,psp");
asm("mrs r0,msp");
asm("mrs r0,apsr");
asm("mrs r0,psr");
asm("mrs r0,ipsr");

Thanks in advance

Post Information Post
November 25, 2010 - 2:30pm

I am using stm32f107vct6 (cortex m3) and ride 7. And Default start up script to reach main.

November 30, 2010 - 11:10am
Raisonance Support Team


We would like to help you as quickly as possible on this issue, but we need to have more information about the problem before we can help further.

In order to understand the issue you are facing, we need the following information about your configuration:
- Version of Ride7 and RKit that you are using. You can get these from the Ride7 "Help | About" dialog box.

Please check from the Raisonance downloads page at that you are using the latest version of the tools.

Concerning your particular problem:
- The hardware on which you are executing (REva evaluation board?).
- Provide the steps you followed to raise the error.
- The precise error message you received, and which tool produced it. If possible, a screenshot of the message (using the PrtScr keyboard key) is helpful.

Can you send us a project that exhibits the problem?


The Raisonance support team.

December 1, 2010 - 7:30am

Sir please find my mail to you .

Given below is a description of the issues I am facing.

Ride 7 Patch
Ride 7

REva evaluation board 3.3

I am using stm32f107vct6 (cortex m3) and ride 7. And Default start up script to reach main.
main.c has the source code.

Problem 1:
In simulator when I run the code the MRS instruction puts 0x0 in R0.
The MSR instruction doesnot write to the status register.

2.On REva evaluation board
The MRS insruction WORKS.(GREAT !)
But the MSR instruction writes to the status register but that is not displayed on the register veiw.
Example asm("msr control,r0");
Changes the SP correctly to PSP but in the control register the value is still 0x0 .
When I read the control register in r0 using asm("mrs r0,control");
r0 correctly shows correctly r0=0x3.

So is there a way to find out the correct value of control register,PSP using the register veiw as
the displayed value of PSP and control is always 0 ?


December 2, 2010 - 5:27pm
Raisonance Support Team


Thanks for your detailed report. We have been able to reproduce both issues:

- Concerning the simulator, it is actually not a bug. Our simulator is a Core simulatore i.e., it only simulates the execution of instructions and the basic registers. Peripherals and advanced registers are not simulated, hence the simulation of your code does not produce anything in the simulator.

- The second problem you reported is a limitation of our debugger. It is currently not able to see the registers PSP, PRIMASK, BASEPRI, BASEPRI_MASK, FAULTMASK and CONTROL.
This limitation will be corrected in a future release of RKit-ARM (although we will not have enough time to integrate it in the next release, dues in few weeks).

Thanks again for your great help on this,
Best Regards,