switching between RV64 and RV32 in the same application to access RV32 instruction meanings

210 views
Skip to first unread message

Luke Kenneth Casson Leighton

unread,
Oct 19, 2018, 10:11:07 AM10/19/18
to RISC-V ISA Dev
a few months back it was discussed that the RV instruction encoding
did not appear to be "clean" i.e. that there was no way to ascertain
if, from a particular opcode, if thats specific opcode was an RV32 one
or an RV64 one. i.e. additional state was required, namely XLEN.

the solution was suggested, "set XLEN, that sets the context,
therefore RV32 applications will run".

however, that does not imply automatically that 32-bit (RV32)
instructions may be *MIXED* with 64-bit (RV64) instructions. examples
of where this may be desirable include calling of RV32 libraries from
an RV64 system.

i am specifically interested in actually calling, at the assembly
level, from within the same function, an instruction where the
specific *RV32* meaning is required, *not* the RV64 meaning. in this
way actually mixing RV32 and RV64 within the *same function*.

reading the privspec (V1.11-draft) it appears that something called
UXL (mstatus, sstatus) is used to over-ride XLEN.

question: is it possible to override UXL from *user* mode?

l.

Tommy Murphy

unread,
Oct 19, 2018, 12:37:50 PM10/19/18
to Luke Kenneth Casson Leighton, RISC-V ISA Dev
Any use...?


"The canonical way to solve this problem is to implement MXL and switch to RV32 mode."

Tommy Murphy

unread,
Oct 19, 2018, 12:42:12 PM10/19/18
to Tommy Murphy, Luke Kenneth Casson Leighton, RISC-V ISA Dev

Luke Kenneth Casson Leighton

unread,
Oct 19, 2018, 1:12:56 PM10/19/18
to Tommy Murphy, RISC-V ISA Dev
On Fri, Oct 19, 2018 at 5:42 PM Tommy Murphy <tommy_...@hotmail.com> wrote:

> Also this thread?
>
> https://groups.google.com/a/groups.riscv.org/forum/m/#!topic/sw-dev/mUUaoxjQy6Q

that was the one, thanks tommy, good find. yes, it looks like
setting MXL/SXL/UXL (depending on M/U/S mode) is the way to do it.

ah darn - spike doesn't implement ustatus. it has sstatus and mstatus.

l.
Reply all
Reply to author
Forward
0 new messages