Search code examples
assemblymicroblaze

Trying to see what is in the MSR register on Microblaze


Using OVPSim I am hoping to peek at the contents of the (simulated) MSR register eg

  register int x asm("r19");
  asm("mfs r19, msr");
  printf("R19 contains %i\n", x);

This gives the errors:

Compiling application.c
/tmp/ccbSgUEu.s: Assembler messages:
/tmp/ccbSgUEu.s:59: Error: register expected, but saw 'msr'
/tmp/ccbSgUEu.s:59: Fatal error: invalid value for special purpose register
make: *** [application.o] Error 1

While using this code:

register int x asm("r19");
asm("mfs r19, 1 ");
printf("R19 contains %i\n", x);

Gives me:

/tmp/ccWZKjxi.s: Assembler messages:
/tmp/ccWZKjxi.s:59: Error: register expected, but saw '1'
/tmp/ccWZKjxi.s:59: Fatal error: invalid value for special purpose register
make: *** [application.o] Error 1

And the example actually given in the Xilinx documentation (to read PC) of:

mfs r2 0

Also fails - so what's the correct way to do this?

NB: I am using the CROSS tools eg make -C HelloWorld/ CROSS=MICROBLAZE


Solution

  • The code compiles if the name of the register is given as rmsr, i.e,:

     asm("mfs r19, rmsr")