rev8
Byte-reverse register (RV64 encoding)
- Extension
- Zbb, Zbkb, Zk, Zkn, Zks
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
rev8 xd, xs1- Length
- 32-bit
Encoding
RV64 form
| 3120 | 1915 | 1412 | 117 | 60 | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 011010111000 | rs1 | 101 | rd | 0010011 | |||||||||||||||||||||||||||
Match 0x6b805013, mask 0xfff0707f. Source: rev8 rd rs1 31..20=0x6B8 14..12=5 6..0=0x13 in riscv-opcodes/extensions/rv64_zbb.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| rs1 | 19:15 | rs1 |
| rd | 11:7 | rd |
RV32 form; listed in riscv-opcodes as a pseudo-op of rev8.rv32
| 3120 | 1915 | 1412 | 117 | 60 | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 011010011000 | rs1 | 101 | rd | 0010011 | |||||||||||||||||||||||||||
Match 0x69805013, mask 0xfff0707f. Source: $pseudo_op rv32_zbkb::rev8.rv32 rev8.rv32 rd rs1 31..20=0x698 14..12=5 6..0=0x13 in riscv-opcodes/extensions/rv32_zbb.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| rs1 | 19:15 | rs1 |
| rd | 11:7 | rd |
Description
Reverses the order of the bytes in xs1.
Note: The rev8 mnemonic corresponds to different instruction encodings in RV32 and RV64.
Note: The byte-reverse operation is only available for the full register width. To emulate word-sized
and halfword-sized byte-reversal, perform a rev8 xd,xs1 followed by a srai xd,xd,K, where K
is XLEN-32 and XLEN-16, respectively.
Description from riscv-unified-db, reformatted.
Operation
XReg input = X[xs1];
XReg output = 0;
XReg j = xlen() - 1;
for (U32 i=0; i < xlen(); i = i+8) {
output[(i+7):i] = input[j:(j-7)];
j = j - 8;
}
X[xd] = output;Pseudocode in riscv-unified-db’s IDL, quoted unchanged.
Specification and related pages
- The RISC-V Instruction Set Manual: src/unpriv/zbb.adoc (Zbb)
- The RISC-V Instruction Set Manual: src/unpriv/zbkb.adoc (Zbkb)
- The RISC-V Instruction Set Manual: src/unpriv/zk.adoc (Zk)
- The RISC-V Instruction Set Manual: src/unpriv/zk.adoc (Zkn)
- The RISC-V Instruction Set Manual: src/unpriv/zk.adoc (Zks)
- riscv-unified-db: spec/std/isa/inst/B/rev8.yaml
- Zbb instruction listing
- Zbkb instruction listing
- Zk instruction listing
- Zkn instruction listing
- Zks instruction listing