AR# 17026

|

MicroBlaze - How do I read the registers in the MicroBlaze Core?

描述

How do I read the registers in the MicroBlaze Core?

解决方案

MSR Register Example 

 

1. To read the MSR, use the MFS (Move From Special) assembly instruction. 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 specify it directly. 

 

2. When moving the contents to the variable, you should be aware that the compiler may move the instruction around since it is not dependent on any inputs. To avoid this, you may want to supply a dependency in the ASM instruction as follows: 

 

int k; 

a = b*c; 

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

AR# 17026
日期 05/15/2014
状态 Archive
Type 综合文章
People Also Viewed