OpenCores
no use no use 1/1 no use no use
Understanding l.mtspr instruction
by binod on May 28, 2019
binod
Posts: 1
Joined: Apr 5, 2016
Last seen: Aug 23, 2024
I was using or1200 processor for my work and I want to know about the l.mtspr instruction (l.mtspr rA,rB,K). In this instruction, how to write in SPR group other than Group 0. As I was trying to write in the other group so I just gave the address of that register. But I can see that without specifying the group we cannot write into that register.

For example, if I have to write in UPR register (address = 1) of Group 0
l.mtspr r0, rx, 1
but if I want to write in IMMUPR register(address = 1) of Group 2
How should I write the assembly instruction?
RE: Understanding l.mtspr instruction
by DavidsonDFGL on May 31, 2019
DavidsonDFGL
Posts: 2
Joined: May 17, 2018
Last seen: Oct 16, 2019
Hello binod,

You can have up to 32 groups and each group can have up to 2^11 registers. So, to compute a register index, you first left-shift the group index and them add the register index.

In your example, to access the IMMUPR register (Group 2, Reg 1) you do: (2 << 11) + 1,
or to be more precise: l.mtspr r0, rx, (2 << 11) + 1.

You can find a nice table here: https://github.com/torvalds/linux/blob/master/arch/openrisc/include/asm/spr_defs.h

Cheers,
Davidson Francis
no use no use 1/1 no use no use
© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.