How do I write rotation Operation for the Risc-V(Assembly Language) Do we have any command for it like we have have in 8086?

后端 未结 2 802
轮回少年
轮回少年 2020-12-22 04:04

I have worked with assembly language of 8086 previously, rotation operation in 8086 was just a command. But I can\'t find a specific keyword for rotation operation in Risc-V

2条回答
  •  悲&欢浪女
    2020-12-22 04:50

    It looks like extension "B" should define such an instruction eventually.

    Until then you have to compose it using left and right shifts.

    Here's an equivalent of the MIPS32R2 rotrv instruction (rotate right by variable count):

    rotrv:
        subu    neg_count, zero, count
        srlv    tmp1, src, count
        sllv    tmp2, src, neg_count
        or      dst, tmp1, tmp2
    

    You can do the same on riscv.

提交回复
热议问题