AR# 17216

|

3.2 EDK MicroBlaze - How do I read the Machie Status Register (MSR) in MicroBlaze?

説明

General Description: 

How do I read the Machie Status Register (MSR) in MicroBlaze?

ソリューション

To read the MSR, use the mfs (move from special) assembly instruction, and insert the assembly instruction in your C code as follows: 

 

int k; 

asm ("mfs %0, rmsr" : "=d" (k)); 

 

The above instruction transfers the contents of the MSR into the "k" variable. Alternatively, if you know which register you want to read the MSR into, you can directly specify it. 

 

When moving the contents to the variable, beware that the compiler may move the instruction around since it is not dependent on any inputs. To avoid this issue, you can supply a dependency in the asm instruction as follows: 

int k; 

a = b*c; 

asm ("mfs %0, rmsr" : "=d" (k) : "d" (a));

AR# 17216
日付 05/15/2014
ステータス アーカイブ
種類 一般
People Also Viewed