REV8

Byte Reverse

REV8 rd, rs1

Reverses the order of bytes in a register (Endian swap).

Encoding

Binary Layout
011010111000
31:20
rs1
19:15
101
14:12
rd
11:7
0010011
6:0
 
Format I-Type
Opcode 0x6B805013
Extension Zbb

Operands

  • rd
    Destination register (integer)
  • rs1
    Source

Example

REV8 x10, x11

// Converts Big-Endian to Little-Endian.

Related

Across architectures

Byte Swap (Endianness Reversal) : how x86, ARM, RISC-V, and PowerISA each do this.

More in Zbb

Description

REV8 reverses the order of the bytes in rs1 (byte swap, endianness conversion) and writes the result to rd. The stored encoding is the RV64 one (imm12 = 0x6B8, shifting by 56); on RV32 the encoding is 0x698.

Operation

R[rd] = Byteswap(R[rs1]);