RISC-V Instruction Set Reference

A compact reference for the RISC-V instructions you meet when reversing RV64 binaries, firmware or shellcode: base integer, the G extensions (M, A, F, D, Zicsr, Zifencei), C, the B bit-manipulation extensions (Zba, Zbb, Zbs) and the privileged instructions. Every encoding below is checked against the LLVM assembler. The vector extension (V) is not covered.

Registers

RegisterABI nameRoleSaved by
x0zeroHard-wired zero. Writes are ignored.—
x1raReturn addressCaller
x2spStack pointer (16-byte aligned)Callee
x3gpGlobal pointer (linker relaxation)—
x4tpThread pointer (TLS)—
x5–x7t0–t2Temporaries (t0 is the alternate link register)Caller
x8s0 / fpSaved register / frame pointerCallee
x9s1Saved registerCallee
x10–x11a0–a1Arguments / return valuesCaller
x12–x17a2–a7Arguments (a7 = syscall number on Linux)Caller
x18–x27s2–s11Saved registersCallee
x28–x31t3–t6TemporariesCaller
f0–f7ft0–ft7FP temporariesCaller
f8–f9fs0–fs1FP saved registersCallee
f10–f11fa0–fa1FP arguments / return valuesCaller
f12–f17fa2–fa7FP argumentsCaller
f18–f27fs2–fs11FP saved registersCallee
f28–f31ft8–ft11FP temporariesCaller
There are no condition flags: comparisons write a register (slt) or branch directly (blt). pc is not a general purpose register. XLEN is 32 on RV32 and 64 on RV64. On RV64, 32-bit results (*w instructions, lw) are always sign-extended to 64 bits, even for unsigned int. Compressed instructions with a ' register field (rd', rs1', rs2') can only use x8–x15 (s0, s1, a0–a5).

Instruction formats

Instructions are 32 bits, little endian, 4-byte aligned (2-byte aligned with C). If the two low bits are not 11, the instruction is a 16-bit compressed one. rd, rs1 and rs2 always sit at the same position, and the immediate sign bit is always bit 31, so decoding is cheap.

R
31–25funct7
24–20rs2
19–15rs1
14–12funct3
11–7rd
6–0opcode
I
31–20imm[11:0]
19–15rs1
14–12funct3
11–7rd
6–0opcode
S
31–25imm[11:5]
24–20rs2
19–15rs1
14–12funct3
11–7imm[4:0]
6–0opcode
B
31–25imm[12|10:5]
24–20rs2
19–15rs1
14–12funct3
11–7imm[4:1|11]
6–0opcode
U
31–12imm[31:12]
11–7rd
6–0opcode
J
31–12imm[20|10:1|11|19:12]
11–7rd
6–0opcode
R4
31–27rs3
26–25fmt
24–20rs2
19–15rs1
14–12funct3
11–7rd
6–0opcode

Opcode map (inst[6:0], low bits always 11)

inst[4:2] →
inst[6:5] ↓
000001010011100101110111
00LOADLOAD-FPcustom-0MISC-MEMOP-IMMAUIPCOP-IMM-3248-bit
01STORESTORE-FPcustom-1AMOOPLUIOP-3264-bit
10MADDMSUBNMSUBNMADDOP-FPOP-Vcustom-248-bit
11BRANCHJALRreservedJALSYSTEMOP-VEcustom-3≥80-bit

Pseudo-instructions (what disassemblers show vs. what is encoded)

Pseudo-instructionReal instruction(s)
nopaddi x0, x0, 0
li rd, immlui/addi(w)/slli sequence chosen by the assembler
la rd, symauipc rd, %pcrel_hi(sym) ; addi rd, rd, %pcrel_lo
mv rd, rsaddi rd, rs, 0
not rd, rsxori rd, rs, -1
neg rd, rssub rd, x0, rs
negw rd, rssubw rd, x0, rs
sext.w rd, rsaddiw rd, rs, 0
zext.b rd, rsandi rd, rs, 255
seqz rd, rssltiu rd, rs, 1
snez rd, rssltu rd, x0, rs
sltz rd, rsslt rd, rs, x0
sgtz rd, rsslt rd, x0, rs
beqz / bnez rs, offbeq / bne rs, x0, off
blez rs, offbge x0, rs, off
bgez / bltz rs, offbge / blt rs, x0, off
bgtz rs, offblt x0, rs, off
bgt / ble / bgtu / bleu a, b, offblt / bge / bltu / bgeu b, a, off
j offjal x0, off
jal offjal ra, off
jr rsjalr x0, 0(rs)
jalr rsjalr ra, 0(rs)
retjalr x0, 0(ra)
call symauipc ra, %pcrel_hi(sym) ; jalr ra, %pcrel_lo(ra)
tail symauipc t1, %pcrel_hi(sym) ; jalr x0, %pcrel_lo(t1)
csrr rd, csrcsrrs rd, csr, x0
csrw / csrs / csrc csr, rscsrrw / csrrs / csrrc x0, csr, rs
rdcycle / rdtime / rdinstret rdcsrrs rd, cycle / time / instret, x0
fmv.s / fabs.s / fneg.s rd, rsfsgnj.s / fsgnjx.s / fsgnjn.s rd, rs, rs

Common CSRs

NumberNamePurpose
0x001fflagsFP accrued exceptions
0x002frmFP dynamic rounding mode
0x003fcsrfrm + fflags
0xC00cycleCycle counter (user read-only)
0xC01timeReal-time counter
0xC02instretInstructions retired
0x100sstatusSupervisor status (SIE, SPIE, SPP, SUM, MXR...)
0x104sieSupervisor interrupt enable
0x105stvecSupervisor trap vector base
0x140sscratchSupervisor scratch
0x141sepcSupervisor exception PC
0x142scauseSupervisor trap cause
0x143stvalSupervisor bad address / instruction
0x144sipSupervisor interrupt pending
0x180satpAddress translation: MODE (Sv39/48/57), ASID, root PPN
0x300mstatusMachine status (MIE, MPIE, MPP, MPRV...)
0x301misaISA and extensions
0x302medelegException delegation to S-mode
0x303midelegInterrupt delegation to S-mode
0x304mieMachine interrupt enable
0x305mtvecMachine trap vector base
0x340mscratchMachine scratch
0x341mepcMachine exception PC
0x342mcauseMachine trap cause
0x343mtvalMachine bad address / instruction
0x344mipMachine interrupt pending
0xF14mhartidHart ID
The two top bits of the CSR number say whether it is read-only (11), and bits 9:8 give the lowest privilege allowed to access it (00 = U, 01 = S, 11 = M).

Instructions (239 entries)

Group
Extension
Click a row to show its encoding, the bits of the example, and its bytes in memory.
MnemonicSyntaxDescriptionExt.
Integer computation
lui rd, imm20 Load upper immediate: rd = sext(imm20 << 12). Low 12 bits are zero. I
31–12imm[31:12]00010010001101000101
11–7rd01010
6–00 1 1 0 1 1 1

Pair with addi to build any 32-bit constant. If bit 11 of the low part is set, the assembler rounds the upper part up by one because addi sign-extends.

Examplelui a0, 0x123451234553737 55 34 12
auipc rd, imm20 Add upper immediate to PC: rd = pc + sext(imm20 << 12). I
31–12imm[31:12]00000000000000000001
11–7rd00101
6–00 0 1 0 1 1 1

Base of all PC-relative addressing (la, call, GOT accesses). Useful in shellcode to find where you are without a call.

Exampleauipc t0, 0x10000129797 12 00 00
addi rd, rs1, imm12 rd = rs1 + sext(imm12). Overflow is ignored. I
31–20imm[11:0]111111010110
19–15rs101011
14–120 0 0
11–7rd01010
6–00 0 1 0 0 1 1

addi x0, x0, 0 is the canonical nop (0x00000013). mv rd, rs is addi rd, rs, 0.

Exampleaddi a0, a1, -42fd65851313 85 65 fd
slti rd, rs1, imm12 Set rd to 1 if rs1 < sext(imm12) (signed), else 0. I
31–20imm[11:0]000000001010
19–15rs101011
14–120 1 0
11–7rd01010
6–00 0 1 0 0 1 1
Exampleslti a0, a1, 1000a5a51313 a5 a5 00
sltiu rd, rs1, imm12 Set rd to 1 if rs1 < sext(imm12) (unsigned), else 0. I
31–20imm[11:0]000000000001
19–15rs101011
14–120 1 1
11–7rd01010
6–00 0 1 0 0 1 1

seqz rd, rs is sltiu rd, rs, 1.

Examplesltiu a0, a1, 10015b51313 b5 15 00
xori rd, rs1, imm12 rd = rs1 ^ sext(imm12). I
31–20imm[11:0]111111111111
19–15rs101011
14–121 0 0
11–7rd01010
6–00 0 1 0 0 1 1

not rd, rs is xori rd, rs, -1.

Examplexori a0, a1, -1fff5c51313 c5 f5 ff
ori rd, rs1, imm12 rd = rs1 | sext(imm12). I
31–20imm[11:0]000011111111
19–15rs101011
14–121 1 0
11–7rd01010
6–00 0 1 0 0 1 1
Exampleori a0, a1, 0xff0ff5e51313 e5 f5 0f
andi rd, rs1, imm12 rd = rs1 & sext(imm12). I
31–20imm[11:0]000011111111
19–15rs101011
14–121 1 1
11–7rd01010
6–00 0 1 0 0 1 1
Exampleandi a0, a1, 0xff0ff5f51313 f5 f5 0f
slli rd, rs1, shamt Logical shift left by an immediate (0–63 on RV64, 0–31 on RV32). I
31–260 0 0 0 0 0
25–20shamt000011
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 0 0 1 1
Exampleslli a0, a1, 30035951313 95 35 00
srli rd, rs1, shamt Logical shift right by an immediate (zeros shifted in). I
31–260 0 0 0 0 0
25–20shamt000011
19–15rs101011
14–121 0 1
11–7rd01010
6–00 0 1 0 0 1 1
Examplesrli a0, a1, 30035d51313 d5 35 00
srai rd, rs1, shamt Arithmetic shift right by an immediate (sign bit shifted in). I
31–260 1 0 0 0 0
25–20shamt000011
19–15rs101011
14–121 0 1
11–7rd01010
6–00 0 1 0 0 1 1
Examplesrai a0, a1, 34035d51313 d5 35 40
add rd, rs1, rs2 rd = rs1 + rs2. I
31–250 0 0 0 0 0 0
24–20rs201100
19–15rs101011
14–120 0 0
11–7rd01010
6–00 1 1 0 0 1 1
Exampleadd a0, a1, a200c5853333 85 c5 00
sub rd, rs1, rs2 rd = rs1 - rs2. I
31–250 1 0 0 0 0 0
24–20rs201100
19–15rs101011
14–120 0 0
11–7rd01010
6–00 1 1 0 0 1 1

neg rd, rs is sub rd, x0, rs.

Examplesub a0, a1, a240c5853333 85 c5 40
sll rd, rs1, rs2 Logical shift left by the low 6 (RV64) or 5 (RV32) bits of rs2. I
31–250 0 0 0 0 0 0
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–00 1 1 0 0 1 1
Examplesll a0, a1, a200c5953333 95 c5 00
slt rd, rs1, rs2 Set rd to 1 if rs1 < rs2 (signed), else 0. I
31–250 0 0 0 0 0 0
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 1 0 0 1 1
Exampleslt a0, a1, a200c5a53333 a5 c5 00
sltu rd, rs1, rs2 Set rd to 1 if rs1 < rs2 (unsigned), else 0. I
31–250 0 0 0 0 0 0
24–20rs201100
19–15rs101011
14–120 1 1
11–7rd01010
6–00 1 1 0 0 1 1

snez rd, rs is sltu rd, x0, rs.

Examplesltu a0, a1, a200c5b53333 b5 c5 00
xor rd, rs1, rs2 rd = rs1 ^ rs2. I
31–250 0 0 0 0 0 0
24–20rs201100
19–15rs101011
14–121 0 0
11–7rd01010
6–00 1 1 0 0 1 1
Examplexor a0, a1, a200c5c53333 c5 c5 00
srl rd, rs1, rs2 Logical shift right by the low bits of rs2. I
31–250 0 0 0 0 0 0
24–20rs201100
19–15rs101011
14–121 0 1
11–7rd01010
6–00 1 1 0 0 1 1
Examplesrl a0, a1, a200c5d53333 d5 c5 00
sra rd, rs1, rs2 Arithmetic shift right by the low bits of rs2. I
31–250 1 0 0 0 0 0
24–20rs201100
19–15rs101011
14–121 0 1
11–7rd01010
6–00 1 1 0 0 1 1
Examplesra a0, a1, a240c5d53333 d5 c5 40
or rd, rs1, rs2 rd = rs1 | rs2. I
31–250 0 0 0 0 0 0
24–20rs201100
19–15rs101011
14–121 1 0
11–7rd01010
6–00 1 1 0 0 1 1
Exampleor a0, a1, a200c5e53333 e5 c5 00
and rd, rs1, rs2 rd = rs1 & rs2. I
31–250 0 0 0 0 0 0
24–20rs201100
19–15rs101011
14–121 1 1
11–7rd01010
6–00 1 1 0 0 1 1
Exampleand a0, a1, a200c5f53333 f5 c5 00
RV64 word operations
addiw rd, rs1, imm12 32-bit add immediate, result sign-extended to 64 bits. RV64I
31–20imm[11:0]000000000001
19–15rs101011
14–120 0 0
11–7rd01010
6–00 0 1 1 0 1 1

sext.w rd, rs is addiw rd, rs, 0. Very common in compiled code that handles int.

Exampleaddiw a0, a1, 10015851b1b 85 15 00
slliw rd, rs1, shamt 32-bit shift left by immediate, result sign-extended. RV64I
31–250 0 0 0 0 0 0
24–20shamt00011
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 1 0 1 1
Exampleslliw a0, a1, 30035951b1b 95 35 00
srliw rd, rs1, shamt 32-bit logical shift right by immediate, result sign-extended. RV64I
31–250 0 0 0 0 0 0
24–20shamt00011
19–15rs101011
14–121 0 1
11–7rd01010
6–00 0 1 1 0 1 1
Examplesrliw a0, a1, 30035d51b1b d5 35 00
sraiw rd, rs1, shamt 32-bit arithmetic shift right by immediate, result sign-extended. RV64I
31–250 1 0 0 0 0 0
24–20shamt00011
19–15rs101011
14–121 0 1
11–7rd01010
6–00 0 1 1 0 1 1
Examplesraiw a0, a1, 34035d51b1b d5 35 40
addw rd, rs1, rs2 32-bit add, result sign-extended. RV64I
31–250 0 0 0 0 0 0
24–20rs201100
19–15rs101011
14–120 0 0
11–7rd01010
6–00 1 1 1 0 1 1
Exampleaddw a0, a1, a200c5853b3b 85 c5 00
subw rd, rs1, rs2 32-bit subtract, result sign-extended. RV64I
31–250 1 0 0 0 0 0
24–20rs201100
19–15rs101011
14–120 0 0
11–7rd01010
6–00 1 1 1 0 1 1
Examplesubw a0, a1, a240c5853b3b 85 c5 40
sllw rd, rs1, rs2 32-bit shift left by the low 5 bits of rs2, result sign-extended. RV64I
31–250 0 0 0 0 0 0
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–00 1 1 1 0 1 1
Examplesllw a0, a1, a200c5953b3b 95 c5 00
srlw rd, rs1, rs2 32-bit logical shift right, result sign-extended. RV64I
31–250 0 0 0 0 0 0
24–20rs201100
19–15rs101011
14–121 0 1
11–7rd01010
6–00 1 1 1 0 1 1
Examplesrlw a0, a1, a200c5d53b3b d5 c5 00
sraw rd, rs1, rs2 32-bit arithmetic shift right, result sign-extended. RV64I
31–250 1 0 0 0 0 0
24–20rs201100
19–15rs101011
14–121 0 1
11–7rd01010
6–00 1 1 1 0 1 1
Examplesraw a0, a1, a240c5d53b3b d5 c5 40
Loads and stores
lb rd, imm12(rs1) Load a byte, sign-extended. I
31–20imm[11:0]000000000100
19–15rs100010
14–120 0 0
11–7rd01010
6–00 0 0 0 0 1 1
Examplelb a0, 4(sp)0041050303 05 41 00
lh rd, imm12(rs1) Load a halfword, sign-extended. I
31–20imm[11:0]000000000100
19–15rs100010
14–120 0 1
11–7rd01010
6–00 0 0 0 0 1 1
Examplelh a0, 4(sp)0041150303 15 41 00
lw rd, imm12(rs1) Load a word, sign-extended (on RV64). I
31–20imm[11:0]000000000100
19–15rs100010
14–120 1 0
11–7rd01010
6–00 0 0 0 0 1 1
Examplelw a0, 4(sp)0041250303 25 41 00
ld rd, imm12(rs1) Load a doubleword. RV64I
31–20imm[11:0]000000001000
19–15rs100010
14–120 1 1
11–7rd01010
6–00 0 0 0 0 1 1
Exampleld a0, 8(sp)0081350303 35 81 00
lbu rd, imm12(rs1) Load a byte, zero-extended. I
31–20imm[11:0]000000000100
19–15rs100010
14–121 0 0
11–7rd01010
6–00 0 0 0 0 1 1
Examplelbu a0, 4(sp)0041450303 45 41 00
lhu rd, imm12(rs1) Load a halfword, zero-extended. I
31–20imm[11:0]000000000100
19–15rs100010
14–121 0 1
11–7rd01010
6–00 0 0 0 0 1 1
Examplelhu a0, 4(sp)0041550303 55 41 00
lwu rd, imm12(rs1) Load a word, zero-extended. RV64I
31–20imm[11:0]000000000100
19–15rs100010
14–121 1 0
11–7rd01010
6–00 0 0 0 0 1 1
Examplelwu a0, 4(sp)0041650303 65 41 00
sb rs2, imm12(rs1) Store the low byte of rs2. I
31–25imm[11:5]0000000
24–20rs201010
19–15rs100010
14–120 0 0
11–7imm[4:0]00100
6–00 1 0 0 0 1 1
Examplesb a0, 4(sp)00a1022323 02 a1 00
sh rs2, imm12(rs1) Store the low halfword of rs2. I
31–25imm[11:5]0000000
24–20rs201010
19–15rs100010
14–120 0 1
11–7imm[4:0]00100
6–00 1 0 0 0 1 1
Examplesh a0, 4(sp)00a1122323 12 a1 00
sw rs2, imm12(rs1) Store the low word of rs2. I
31–25imm[11:5]0000000
24–20rs201010
19–15rs100010
14–120 1 0
11–7imm[4:0]00100
6–00 1 0 0 0 1 1
Examplesw a0, 4(sp)00a1222323 22 a1 00
sd rs2, imm12(rs1) Store a doubleword. RV64I
31–25imm[11:5]0000000
24–20rs200001
19–15rs100010
14–120 1 1
11–7imm[4:0]01000
6–00 1 0 0 0 1 1
Examplesd ra, 8(sp)0011342323 34 11 00
Control transfer
jal rd, offset Jump to pc + offset (±1 MiB) and write the return address pc + 4 to rd. I
31–12imm[20|10:1|11|19:12]00000000000100000000
11–7rd00001
6–01 1 0 1 1 1 1

j off is jal x0, off. jal off uses ra. The immediate bits are scrambled so that the sign bit is always inst[31].

Examplejal ra, 2048001000efef 00 10 00
jalr rd, imm12(rs1) Jump to (rs1 + sext(imm12)) & ~1 and write pc + 4 to rd. I
31–20imm[11:0]000000000000
19–15rs100101
14–120 0 0
11–7rd00001
6–01 1 0 0 1 1 1

ret is jalr x0, 0(ra) (0x00008067). jr rs is jalr x0, 0(rs). With auipc it reaches ±2 GiB (call, tail).

Examplejalr ra, 0(t0)000280e7e7 80 02 00
beq rs1, rs2, offset Branch if rs1 == rs2 (±4 KiB). I
31–25imm[12|10:5]0000000
24–20rs201011
19–15rs101010
14–120 0 0
11–7imm[4:1|11]10000
6–01 1 0 0 0 1 1

beqz rs, off is beq rs, x0, off.

Examplebeq a0, a1, 1600b5086363 08 b5 00
bne rs1, rs2, offset Branch if rs1 != rs2. I
31–25imm[12|10:5]0000000
24–20rs201011
19–15rs101010
14–120 0 1
11–7imm[4:1|11]10000
6–01 1 0 0 0 1 1

bnez rs, off is bne rs, x0, off.

Examplebne a0, a1, 1600b5186363 18 b5 00
blt rs1, rs2, offset Branch if rs1 < rs2 (signed). I
31–25imm[12|10:5]0000000
24–20rs201011
19–15rs101010
14–121 0 0
11–7imm[4:1|11]10000
6–01 1 0 0 0 1 1

bgt a, b is blt b, a.

Exampleblt a0, a1, 1600b5486363 48 b5 00
bge rs1, rs2, offset Branch if rs1 ≥ rs2 (signed). I
31–25imm[12|10:5]0000000
24–20rs201011
19–15rs101010
14–121 0 1
11–7imm[4:1|11]10000
6–01 1 0 0 0 1 1

ble a, b is bge b, a.

Examplebge a0, a1, 1600b5586363 58 b5 00
bltu rs1, rs2, offset Branch if rs1 < rs2 (unsigned). I
31–25imm[12|10:5]0000000
24–20rs201011
19–15rs101010
14–121 1 0
11–7imm[4:1|11]10000
6–01 1 0 0 0 1 1
Examplebltu a0, a1, 1600b5686363 68 b5 00
bgeu rs1, rs2, offset Branch if rs1 ≥ rs2 (unsigned). I
31–25imm[12|10:5]0000000
24–20rs201011
19–15rs101010
14–121 1 1
11–7imm[4:1|11]10000
6–01 1 0 0 0 1 1
Examplebgeu a0, a1, 1600b5786363 78 b5 00
Synchronization and environment
fence pred, succ Memory ordering: no access in the succ set (any of I, O, R, W) is observed before an access in the pred set. I
31–28fm0000
27–24pred0011
23–20succ0011
19–15rs100000
14–120 0 0
11–7rd00000
6–00 0 0 1 1 1 1
Examplefence rw, rw0330000f0f 00 30 03
fence.tso Total-store-ordering fence: orders RW→RW except W→R. I
31–281 0 0 0
27–240 0 1 1
23–200 0 1 1
19–150 0 0 0 0
14–120 0 0
11–70 0 0 0 0
6–00 0 0 1 1 1 1
Examplefence.tso8330000f0f 00 30 83
pause Spin-loop hint, encoded as a fence with pred=W and succ=0. Zihintpause
31–280 0 0 0
27–240 0 0 1
23–200 0 0 0
19–150 0 0 0 0
14–120 0 0
11–70 0 0 0 0
6–00 0 0 1 1 1 1
Examplepause0100000f0f 00 00 01
fence.i Synchronize the instruction stream with prior stores of the same hart. Zifencei
31–20imm[11:0]000000000000
19–15rs100000
14–120 0 1
11–7rd00000
6–00 0 0 1 1 1 1

Needed by self-modifying code and JITs after writing instructions. Other harts need a remote fence (on Linux, riscv_flush_icache syscall).

Examplefence.i0000100f0f 10 00 00
ecall Environment call: trap to the next privilege level (system call). I
31–200 0 0 0 0 0 0 0 0 0 0 0
19–150 0 0 0 0
14–120 0 0
11–70 0 0 0 0
6–01 1 1 0 0 1 1

Linux: syscall number in a7, arguments in a0–a5, result in a0. Encoding 0x00000073.

Exampleecall0000007373 00 00 00
ebreak Breakpoint trap, used by debuggers. I
31–200 0 0 0 0 0 0 0 0 0 0 1
19–150 0 0 0 0
14–120 0 0
11–70 0 0 0 0
6–01 1 1 0 0 1 1
Exampleebreak0010007373 00 10 00
Control and status registers
csrrw rd, csr, rs1 Atomically swap: rd = csr, csr = rs1. The CSR is not read if rd is x0. Zicsr
31–20csr001101000000
19–15rs101011
14–120 0 1
11–7rd01010
6–01 1 1 0 0 1 1

csrw csr, rs is csrrw x0, csr, rs.

Examplecsrrw a0, mscratch, a13405957373 95 05 34
csrrs rd, csr, rs1 Read and set bits: rd = csr, csr |= rs1. No write if rs1 is x0. Zicsr
31–20csr001100000000
19–15rs101011
14–120 1 0
11–7rd01010
6–01 1 1 0 0 1 1

csrr rd, csr is csrrs rd, csr, x0. rdcycle, rdtime and rdinstret also use it.

Examplecsrrs a0, mstatus, a13005a57373 a5 05 30
csrrc rd, csr, rs1 Read and clear bits: rd = csr, csr &= ~rs1. Zicsr
31–20csr001100000100
19–15rs101011
14–120 1 1
11–7rd01010
6–01 1 1 0 0 1 1
Examplecsrrc a0, mie, a13045b57373 b5 45 30
csrrwi rd, csr, uimm5 Like csrrw with a 5-bit zero-extended immediate. Zicsr
31–20csr000000000011
19–15uimm00001
14–121 0 1
11–7rd01010
6–01 1 1 0 0 1 1
Examplecsrrwi a0, fcsr, 10030d57373 d5 30 00
csrrsi rd, csr, uimm5 Like csrrs with a 5-bit immediate. Zicsr
31–20csr001100000000
19–15uimm01000
14–121 1 0
11–7rd01010
6–01 1 1 0 0 1 1

csrsi mstatus, 8 sets MIE (enables machine interrupts).

Examplecsrrsi a0, mstatus, 83004657373 65 04 30
csrrci rd, csr, uimm5 Like csrrc with a 5-bit immediate. Zicsr
31–20csr001100000000
19–15uimm01000
14–121 1 1
11–7rd01010
6–01 1 1 0 0 1 1
Examplecsrrci a0, mstatus, 83004757373 75 04 30
Multiply and divide
mul rd, rs1, rs2 Low XLEN bits of rs1 × rs2. M
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–120 0 0
11–7rd01010
6–00 1 1 0 0 1 1
Examplemul a0, a1, a202c5853333 85 c5 02
mulh rd, rs1, rs2 High XLEN bits of signed × signed. M
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–00 1 1 0 0 1 1
Examplemulh a0, a1, a202c5953333 95 c5 02
mulhsu rd, rs1, rs2 High XLEN bits of signed rs1 × unsigned rs2. M
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 1 0 0 1 1
Examplemulhsu a0, a1, a202c5a53333 a5 c5 02
mulhu rd, rs1, rs2 High XLEN bits of unsigned × unsigned. M
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–120 1 1
11–7rd01010
6–00 1 1 0 0 1 1
Examplemulhu a0, a1, a202c5b53333 b5 c5 02
div rd, rs1, rs2 Signed division, rounds toward zero. x/0 = -1; MIN/-1 = MIN (no trap). M
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–121 0 0
11–7rd01010
6–00 1 1 0 0 1 1

Division never traps: compilers emit an explicit check before calling it when the language requires one.

Examplediv a0, a1, a202c5c53333 c5 c5 02
divu rd, rs1, rs2 Unsigned division. x/0 = 2XLEN-1. M
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–121 0 1
11–7rd01010
6–00 1 1 0 0 1 1
Exampledivu a0, a1, a202c5d53333 d5 c5 02
rem rd, rs1, rs2 Signed remainder (sign of the dividend). x%0 = x. M
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–121 1 0
11–7rd01010
6–00 1 1 0 0 1 1
Examplerem a0, a1, a202c5e53333 e5 c5 02
remu rd, rs1, rs2 Unsigned remainder. x%0 = x. M
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–121 1 1
11–7rd01010
6–00 1 1 0 0 1 1
Exampleremu a0, a1, a202c5f53333 f5 c5 02
mulw rd, rs1, rs2 32-bit multiply, low 32 bits sign-extended. RV64M
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–120 0 0
11–7rd01010
6–00 1 1 1 0 1 1
Examplemulw a0, a1, a202c5853b3b 85 c5 02
divw rd, rs1, rs2 32-bit signed division, result sign-extended. RV64M
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–121 0 0
11–7rd01010
6–00 1 1 1 0 1 1
Exampledivw a0, a1, a202c5c53b3b c5 c5 02
divuw rd, rs1, rs2 32-bit unsigned division, result sign-extended. RV64M
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–121 0 1
11–7rd01010
6–00 1 1 1 0 1 1
Exampledivuw a0, a1, a202c5d53b3b d5 c5 02
remw rd, rs1, rs2 32-bit signed remainder, result sign-extended. RV64M
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–121 1 0
11–7rd01010
6–00 1 1 1 0 1 1
Exampleremw a0, a1, a202c5e53b3b e5 c5 02
remuw rd, rs1, rs2 32-bit unsigned remainder, result sign-extended. RV64M
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–121 1 1
11–7rd01010
6–00 1 1 1 0 1 1
Exampleremuw a0, a1, a202c5f53b3b f5 c5 02
Atomics
lr.w rd, (rs1) Load-reserved: load and register a reservation on the address. A
31–270 0 0 1 0
26aq1
25rl0
24–200 0 0 0 0
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 0 1 1 1 1

The .aq / .rl / .aqrl suffixes set the acquire and release bits.

Examplelr.w.aq a0, (a1)1405a52f2f a5 05 14
sc.w rd, rs2, (rs1) Store-conditional: store if the reservation is still valid; rd = 0 on success, non-zero on failure. A
31–270 0 0 1 1
26aq0
25rl1
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 0 1 1 1 1

A typical CAS loop is lr, compare, sc, bnez back.

Examplesc.w.rl a0, a2, (a1)1ac5a52f2f a5 c5 1a
amoswap.w rd, rs2, (rs1) Atomically swap rs2 with memory; rd gets the old value. A
31–270 0 0 0 1
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamoswap.w.aqrl a0, a2, (a1)0ec5a52f2f a5 c5 0e
amoadd.w rd, rs2, (rs1) Atomic 32-bit add; rd gets the old value. A
31–270 0 0 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamoadd.w.aqrl a0, a2, (a1)06c5a52f2f a5 c5 06
amoxor.w rd, rs2, (rs1) Atomic 32-bit XOR; rd gets the old value. A
31–270 0 1 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamoxor.w.aqrl a0, a2, (a1)26c5a52f2f a5 c5 26
amoand.w rd, rs2, (rs1) Atomic 32-bit AND; rd gets the old value. A
31–270 1 1 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamoand.w.aqrl a0, a2, (a1)66c5a52f2f a5 c5 66
amoor.w rd, rs2, (rs1) Atomic 32-bit OR; rd gets the old value. A
31–270 1 0 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamoor.w.aqrl a0, a2, (a1)46c5a52f2f a5 c5 46
amomin.w rd, rs2, (rs1) Atomic 32-bit signed minimum; rd gets the old value. A
31–271 0 0 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamomin.w.aqrl a0, a2, (a1)86c5a52f2f a5 c5 86
amomax.w rd, rs2, (rs1) Atomic 32-bit signed maximum; rd gets the old value. A
31–271 0 1 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamomax.w.aqrl a0, a2, (a1)a6c5a52f2f a5 c5 a6
amominu.w rd, rs2, (rs1) Atomic 32-bit unsigned minimum; rd gets the old value. A
31–271 1 0 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamominu.w.aqrl a0, a2, (a1)c6c5a52f2f a5 c5 c6
amomaxu.w rd, rs2, (rs1) Atomic 32-bit unsigned maximum; rd gets the old value. A
31–271 1 1 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamomaxu.w.aqrl a0, a2, (a1)e6c5a52f2f a5 c5 e6
lr.d rd, (rs1) Load-reserved: load and register a reservation on the address. RV64A
31–270 0 0 1 0
26aq1
25rl0
24–200 0 0 0 0
19–15rs101011
14–120 1 1
11–7rd01010
6–00 1 0 1 1 1 1
Examplelr.d.aq a0, (a1)1405b52f2f b5 05 14
sc.d rd, rs2, (rs1) Store-conditional: store if the reservation is still valid; rd = 0 on success, non-zero on failure. RV64A
31–270 0 0 1 1
26aq0
25rl1
24–20rs201100
19–15rs101011
14–120 1 1
11–7rd01010
6–00 1 0 1 1 1 1
Examplesc.d.rl a0, a2, (a1)1ac5b52f2f b5 c5 1a
amoswap.d rd, rs2, (rs1) Atomically swap rs2 with memory; rd gets the old value. RV64A
31–270 0 0 0 1
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 1
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamoswap.d.aqrl a0, a2, (a1)0ec5b52f2f b5 c5 0e
amoadd.d rd, rs2, (rs1) Atomic 64-bit add; rd gets the old value. RV64A
31–270 0 0 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 1
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamoadd.d.aqrl a0, a2, (a1)06c5b52f2f b5 c5 06
amoxor.d rd, rs2, (rs1) Atomic 64-bit XOR; rd gets the old value. RV64A
31–270 0 1 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 1
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamoxor.d.aqrl a0, a2, (a1)26c5b52f2f b5 c5 26
amoand.d rd, rs2, (rs1) Atomic 64-bit AND; rd gets the old value. RV64A
31–270 1 1 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 1
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamoand.d.aqrl a0, a2, (a1)66c5b52f2f b5 c5 66
amoor.d rd, rs2, (rs1) Atomic 64-bit OR; rd gets the old value. RV64A
31–270 1 0 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 1
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamoor.d.aqrl a0, a2, (a1)46c5b52f2f b5 c5 46
amomin.d rd, rs2, (rs1) Atomic 64-bit signed minimum; rd gets the old value. RV64A
31–271 0 0 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 1
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamomin.d.aqrl a0, a2, (a1)86c5b52f2f b5 c5 86
amomax.d rd, rs2, (rs1) Atomic 64-bit signed maximum; rd gets the old value. RV64A
31–271 0 1 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 1
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamomax.d.aqrl a0, a2, (a1)a6c5b52f2f b5 c5 a6
amominu.d rd, rs2, (rs1) Atomic 64-bit unsigned minimum; rd gets the old value. RV64A
31–271 1 0 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 1
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamominu.d.aqrl a0, a2, (a1)c6c5b52f2f b5 c5 c6
amomaxu.d rd, rs2, (rs1) Atomic 64-bit unsigned maximum; rd gets the old value. RV64A
31–271 1 1 0 0
26aq1
25rl1
24–20rs201100
19–15rs101011
14–120 1 1
11–7rd01010
6–00 1 0 1 1 1 1
Exampleamomaxu.d.aqrl a0, a2, (a1)e6c5b52f2f b5 c5 e6
Floating point
flw rd, imm12(rs1) Load a single-precision value into an FP register. F
31–20imm[11:0]000000001000
19–15rs100010
14–120 1 0
11–7rd01010
6–00 0 0 0 1 1 1
Exampleflw fa0, 8(sp)0081250707 25 81 00
fsw rs2, imm12(rs1) Store a single-precision FP register. F
31–25imm[11:5]0000000
24–20rs201010
19–15rs100010
14–120 1 0
11–7imm[4:0]01000
6–00 1 0 0 1 1 1
Examplefsw fa0, 8(sp)00a1242727 24 a1 00
fmadd.s rd, rs1, rs2, rs3 Fused multiply-add, single rounding: rd = (rs1 × rs2) + rs3. F
31–27rs301101
26–250 0
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 0 0 0 1 1
Examplefmadd.s fa0, fa1, fa2, fa368c5f54343 f5 c5 68
fmsub.s rd, rs1, rs2, rs3 Fused multiply-add, single rounding: rd = (rs1 × rs2) - rs3. F
31–27rs301101
26–250 0
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 0 0 1 1 1
Examplefmsub.s fa0, fa1, fa2, fa368c5f54747 f5 c5 68
fnmsub.s rd, rs1, rs2, rs3 Fused multiply-add, single rounding: rd = -(rs1 × rs2) + rs3. F
31–27rs301101
26–250 0
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 0 1 0 1 1
Examplefnmsub.s fa0, fa1, fa2, fa368c5f54b4b f5 c5 68
fnmadd.s rd, rs1, rs2, rs3 Fused multiply-add, single rounding: rd = -(rs1 × rs2) - rs3. F
31–27rs301101
26–250 0
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 0 1 1 1 1
Examplefnmadd.s fa0, fa1, fa2, fa368c5f54f4f f5 c5 68
fadd.s rd, rs1, rs2 Rd = rs1 + rs2 (single precision). F
31–250 0 0 0 0 0 0
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1

The rm field selects the rounding mode; 111 (dyn) uses frm in fcsr.

Examplefadd.s fa0, fa1, fa200c5f55353 f5 c5 00
fsub.s rd, rs1, rs2 Rd = rs1 - rs2 (single precision). F
31–250 0 0 0 1 0 0
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefsub.s fa0, fa1, fa208c5f55353 f5 c5 08
fmul.s rd, rs1, rs2 Rd = rs1 × rs2 (single precision). F
31–250 0 0 1 0 0 0
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefmul.s fa0, fa1, fa210c5f55353 f5 c5 10
fdiv.s rd, rs1, rs2 Rd = rs1 / rs2 (single precision). F
31–250 0 0 1 1 0 0
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefdiv.s fa0, fa1, fa218c5f55353 f5 c5 18
fsqrt.s rd, rs1 Square root. F
31–250 1 0 1 1 0 0
24–200 0 0 0 0
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefsqrt.s fa0, fa15805f55353 f5 05 58
fsgnj.s rd, rs1, rs2 Magnitude of rs1 with the sign of rs2. F
31–250 0 1 0 0 0 0
24–20rs201100
19–15rs101011
14–120 0 0
11–7rd01010
6–01 0 1 0 0 1 1

fmv.s rd, rs is fsgnj.s rd, rs, rs.

Examplefsgnj.s fa0, fa1, fa220c5855353 85 c5 20
fsgnjn.s rd, rs1, rs2 Magnitude of rs1 with the inverted sign of rs2. F
31–250 0 1 0 0 0 0
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–01 0 1 0 0 1 1

fneg.s rd, rs is fsgnjn.s rd, rs, rs.

Examplefsgnjn.s fa0, fa1, fa220c5955353 95 c5 20
fsgnjx.s rd, rs1, rs2 Magnitude of rs1, sign = sign(rs1) XOR sign(rs2). F
31–250 0 1 0 0 0 0
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–01 0 1 0 0 1 1

fabs.s rd, rs is fsgnjx.s rd, rs, rs.

Examplefsgnjx.s fa0, fa1, fa220c5a55353 a5 c5 20
fmin.s rd, rs1, rs2 Minimum (a NaN operand is ignored if the other is a number). F
31–250 0 1 0 1 0 0
24–20rs201100
19–15rs101011
14–120 0 0
11–7rd01010
6–01 0 1 0 0 1 1
Examplefmin.s fa0, fa1, fa228c5855353 85 c5 28
fmax.s rd, rs1, rs2 Maximum. F
31–250 0 1 0 1 0 0
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–01 0 1 0 0 1 1
Examplefmax.s fa0, fa1, fa228c5955353 95 c5 28
feq.s rd, rs1, rs2 Integer rd = 1 if rs1 == rs2 (quiet comparison). F
31–251 0 1 0 0 0 0
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–01 0 1 0 0 1 1
Examplefeq.s a0, fa1, fa2a0c5a55353 a5 c5 a0
flt.s rd, rs1, rs2 Integer rd = 1 if rs1 < rs2. F
31–251 0 1 0 0 0 0
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–01 0 1 0 0 1 1
Exampleflt.s a0, fa1, fa2a0c5955353 95 c5 a0
fle.s rd, rs1, rs2 Integer rd = 1 if rs1 ≤ rs2. F
31–251 0 1 0 0 0 0
24–20rs201100
19–15rs101011
14–120 0 0
11–7rd01010
6–01 0 1 0 0 1 1
Examplefle.s a0, fa1, fa2a0c5855353 85 c5 a0
fclass.s rd, rs1 Write a 10-bit one-hot mask classifying rs1 (±inf, normal, subnormal, zero, NaN). F
31–251 1 1 0 0 0 0
24–200 0 0 0 0
19–15rs101011
14–120 0 1
11–7rd01010
6–01 0 1 0 0 1 1
Examplefclass.s a0, fa1e005955353 95 05 e0
fcvt.w.s rd, rs1 Convert single-precision to signed 32-bit integer. F
31–251 1 0 0 0 0 0
24–200 0 0 0 0
19–15rs101011
14–12rm001
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.w.s a0, fa1, rtzc005955353 95 05 c0
fcvt.s.w rd, rs1 Convert a signed 32-bit integer to single precision. F
31–251 1 0 1 0 0 0
24–200 0 0 0 0
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.s.w fa0, a1d005f55353 f5 05 d0
fcvt.wu.s rd, rs1 Convert single-precision to unsigned 32-bit integer. F
31–251 1 0 0 0 0 0
24–200 0 0 0 1
19–15rs101011
14–12rm001
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.wu.s a0, fa1, rtzc015955353 95 15 c0
fcvt.s.wu rd, rs1 Convert a unsigned 32-bit integer to single precision. F
31–251 1 0 1 0 0 0
24–200 0 0 0 1
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.s.wu fa0, a1d015f55353 f5 15 d0
fcvt.l.s rd, rs1 Convert single-precision to signed 64-bit integer. RV64F
31–251 1 0 0 0 0 0
24–200 0 0 1 0
19–15rs101011
14–12rm001
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.l.s a0, fa1, rtzc025955353 95 25 c0
fcvt.s.l rd, rs1 Convert a signed 64-bit integer to single precision. RV64F
31–251 1 0 1 0 0 0
24–200 0 0 1 0
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.s.l fa0, a1d025f55353 f5 25 d0
fcvt.lu.s rd, rs1 Convert single-precision to unsigned 64-bit integer. RV64F
31–251 1 0 0 0 0 0
24–200 0 0 1 1
19–15rs101011
14–12rm001
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.lu.s a0, fa1, rtzc035955353 95 35 c0
fcvt.s.lu rd, rs1 Convert a unsigned 64-bit integer to single precision. RV64F
31–251 1 0 1 0 0 0
24–200 0 0 1 1
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.s.lu fa0, a1d035f55353 f5 35 d0
fld rd, imm12(rs1) Load a double-precision value into an FP register. D
31–20imm[11:0]000000001000
19–15rs100010
14–120 1 1
11–7rd01010
6–00 0 0 0 1 1 1
Examplefld fa0, 8(sp)0081350707 35 81 00
fsd rs2, imm12(rs1) Store a double-precision FP register. D
31–25imm[11:5]0000000
24–20rs201010
19–15rs100010
14–120 1 1
11–7imm[4:0]01000
6–00 1 0 0 1 1 1
Examplefsd fa0, 8(sp)00a1342727 34 a1 00
fmadd.d rd, rs1, rs2, rs3 Fused multiply-add, single rounding: rd = (rs1 × rs2) + rs3. D
31–27rs301101
26–250 1
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 0 0 0 1 1
Examplefmadd.d fa0, fa1, fa2, fa36ac5f54343 f5 c5 6a
fmsub.d rd, rs1, rs2, rs3 Fused multiply-add, single rounding: rd = (rs1 × rs2) - rs3. D
31–27rs301101
26–250 1
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 0 0 1 1 1
Examplefmsub.d fa0, fa1, fa2, fa36ac5f54747 f5 c5 6a
fnmsub.d rd, rs1, rs2, rs3 Fused multiply-add, single rounding: rd = -(rs1 × rs2) + rs3. D
31–27rs301101
26–250 1
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 0 1 0 1 1
Examplefnmsub.d fa0, fa1, fa2, fa36ac5f54b4b f5 c5 6a
fnmadd.d rd, rs1, rs2, rs3 Fused multiply-add, single rounding: rd = -(rs1 × rs2) - rs3. D
31–27rs301101
26–250 1
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 0 1 1 1 1
Examplefnmadd.d fa0, fa1, fa2, fa36ac5f54f4f f5 c5 6a
fadd.d rd, rs1, rs2 Rd = rs1 + rs2 (double precision). D
31–250 0 0 0 0 0 1
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefadd.d fa0, fa1, fa202c5f55353 f5 c5 02
fsub.d rd, rs1, rs2 Rd = rs1 - rs2 (double precision). D
31–250 0 0 0 1 0 1
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefsub.d fa0, fa1, fa20ac5f55353 f5 c5 0a
fmul.d rd, rs1, rs2 Rd = rs1 × rs2 (double precision). D
31–250 0 0 1 0 0 1
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefmul.d fa0, fa1, fa212c5f55353 f5 c5 12
fdiv.d rd, rs1, rs2 Rd = rs1 / rs2 (double precision). D
31–250 0 0 1 1 0 1
24–20rs201100
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefdiv.d fa0, fa1, fa21ac5f55353 f5 c5 1a
fsqrt.d rd, rs1 Square root. D
31–250 1 0 1 1 0 1
24–200 0 0 0 0
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefsqrt.d fa0, fa15a05f55353 f5 05 5a
fsgnj.d rd, rs1, rs2 Magnitude of rs1 with the sign of rs2. D
31–250 0 1 0 0 0 1
24–20rs201100
19–15rs101011
14–120 0 0
11–7rd01010
6–01 0 1 0 0 1 1

fmv.d rd, rs is fsgnj.d rd, rs, rs.

Examplefsgnj.d fa0, fa1, fa222c5855353 85 c5 22
fsgnjn.d rd, rs1, rs2 Magnitude of rs1 with the inverted sign of rs2. D
31–250 0 1 0 0 0 1
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–01 0 1 0 0 1 1

fneg.d rd, rs is fsgnjn.d rd, rs, rs.

Examplefsgnjn.d fa0, fa1, fa222c5955353 95 c5 22
fsgnjx.d rd, rs1, rs2 Magnitude of rs1, sign = sign(rs1) XOR sign(rs2). D
31–250 0 1 0 0 0 1
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–01 0 1 0 0 1 1

fabs.d rd, rs is fsgnjx.d rd, rs, rs.

Examplefsgnjx.d fa0, fa1, fa222c5a55353 a5 c5 22
fmin.d rd, rs1, rs2 Minimum (a NaN operand is ignored if the other is a number). D
31–250 0 1 0 1 0 1
24–20rs201100
19–15rs101011
14–120 0 0
11–7rd01010
6–01 0 1 0 0 1 1
Examplefmin.d fa0, fa1, fa22ac5855353 85 c5 2a
fmax.d rd, rs1, rs2 Maximum. D
31–250 0 1 0 1 0 1
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–01 0 1 0 0 1 1
Examplefmax.d fa0, fa1, fa22ac5955353 95 c5 2a
feq.d rd, rs1, rs2 Integer rd = 1 if rs1 == rs2 (quiet comparison). D
31–251 0 1 0 0 0 1
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–01 0 1 0 0 1 1
Examplefeq.d a0, fa1, fa2a2c5a55353 a5 c5 a2
flt.d rd, rs1, rs2 Integer rd = 1 if rs1 < rs2. D
31–251 0 1 0 0 0 1
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–01 0 1 0 0 1 1
Exampleflt.d a0, fa1, fa2a2c5955353 95 c5 a2
fle.d rd, rs1, rs2 Integer rd = 1 if rs1 ≤ rs2. D
31–251 0 1 0 0 0 1
24–20rs201100
19–15rs101011
14–120 0 0
11–7rd01010
6–01 0 1 0 0 1 1
Examplefle.d a0, fa1, fa2a2c5855353 85 c5 a2
fclass.d rd, rs1 Write a 10-bit one-hot mask classifying rs1 (±inf, normal, subnormal, zero, NaN). D
31–251 1 1 0 0 0 1
24–200 0 0 0 0
19–15rs101011
14–120 0 1
11–7rd01010
6–01 0 1 0 0 1 1
Examplefclass.d a0, fa1e205955353 95 05 e2
fcvt.w.d rd, rs1 Convert double-precision to signed 32-bit integer. D
31–251 1 0 0 0 0 1
24–200 0 0 0 0
19–15rs101011
14–12rm001
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.w.d a0, fa1, rtzc205955353 95 05 c2
fcvt.d.w rd, rs1 Convert a signed 32-bit integer to double precision. D
31–251 1 0 1 0 0 1
24–200 0 0 0 0
19–15rs101011
14–12rm000
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.d.w fa0, a1d205855353 85 05 d2
fcvt.wu.d rd, rs1 Convert double-precision to unsigned 32-bit integer. D
31–251 1 0 0 0 0 1
24–200 0 0 0 1
19–15rs101011
14–12rm001
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.wu.d a0, fa1, rtzc215955353 95 15 c2
fcvt.d.wu rd, rs1 Convert a unsigned 32-bit integer to double precision. D
31–251 1 0 1 0 0 1
24–200 0 0 0 1
19–15rs101011
14–12rm000
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.d.wu fa0, a1d215855353 85 15 d2
fcvt.l.d rd, rs1 Convert double-precision to signed 64-bit integer. RV64D
31–251 1 0 0 0 0 1
24–200 0 0 1 0
19–15rs101011
14–12rm001
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.l.d a0, fa1, rtzc225955353 95 25 c2
fcvt.d.l rd, rs1 Convert a signed 64-bit integer to double precision. RV64D
31–251 1 0 1 0 0 1
24–200 0 0 1 0
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.d.l fa0, a1d225f55353 f5 25 d2
fcvt.lu.d rd, rs1 Convert double-precision to unsigned 64-bit integer. RV64D
31–251 1 0 0 0 0 1
24–200 0 0 1 1
19–15rs101011
14–12rm001
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.lu.d a0, fa1, rtzc235955353 95 35 c2
fcvt.d.lu rd, rs1 Convert a unsigned 64-bit integer to double precision. RV64D
31–251 1 0 1 0 0 1
24–200 0 0 1 1
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.d.lu fa0, a1d235f55353 f5 35 d2
fcvt.s.d rd, rs1 Convert double to single precision. D
31–250 1 0 0 0 0 0
24–200 0 0 0 1
19–15rs101011
14–12rm111
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.s.d fa0, fa14015f55353 f5 15 40
fcvt.d.s rd, rs1 Convert single to double precision (exact). D
31–250 1 0 0 0 0 1
24–200 0 0 0 0
19–15rs101011
14–12rm000
11–7rd01010
6–01 0 1 0 0 1 1
Examplefcvt.d.s fa0, fa14205855353 85 05 42
fmv.x.w rd, rs1 Copy the raw 32 bits of an FP register to an integer register (sign-extended). F
31–251 1 1 0 0 0 0
24–200 0 0 0 0
19–15rs101011
14–120 0 0
11–7rd01010
6–01 0 1 0 0 1 1
Examplefmv.x.w a0, fa1e005855353 85 05 e0
fmv.w.x rd, rs1 Copy the low 32 bits of an integer register to an FP register (NaN-boxed). F
31–251 1 1 1 0 0 0
24–200 0 0 0 0
19–15rs101011
14–120 0 0
11–7rd01010
6–01 0 1 0 0 1 1
Examplefmv.w.x fa0, a1f005855353 85 05 f0
fmv.x.d rd, rs1 Copy the raw 64 bits of an FP register to an integer register. RV64D
31–251 1 1 0 0 0 1
24–200 0 0 0 0
19–15rs101011
14–120 0 0
11–7rd01010
6–01 0 1 0 0 1 1
Examplefmv.x.d a0, fa1e205855353 85 05 e2
fmv.d.x rd, rs1 Copy an integer register bit-for-bit into an FP register. RV64D
31–251 1 1 1 0 0 1
24–200 0 0 0 0
19–15rs101011
14–120 0 0
11–7rd01010
6–01 0 1 0 0 1 1
Examplefmv.d.x fa0, a1f205855353 85 05 f2
Bit manipulation
sh1add rd, rs1, rs2 rd = (rs1 << 1) + rs2: index an array of 2-byte elements. Zba
31–250 0 1 0 0 0 0
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 1 0 0 1 1
Examplesh1add a0, a1, a220c5a53333 a5 c5 20
sh1add.uw rd, rs1, rs2 rd = (zext32(rs1) << 1) + rs2. Zba
31–250 0 1 0 0 0 0
24–20rs201100
19–15rs101011
14–120 1 0
11–7rd01010
6–00 1 1 1 0 1 1
Examplesh1add.uw a0, a1, a220c5a53b3b a5 c5 20
sh2add rd, rs1, rs2 rd = (rs1 << 2) + rs2: index an array of 4-byte elements. Zba
31–250 0 1 0 0 0 0
24–20rs201100
19–15rs101011
14–121 0 0
11–7rd01010
6–00 1 1 0 0 1 1
Examplesh2add a0, a1, a220c5c53333 c5 c5 20
sh2add.uw rd, rs1, rs2 rd = (zext32(rs1) << 2) + rs2. Zba
31–250 0 1 0 0 0 0
24–20rs201100
19–15rs101011
14–121 0 0
11–7rd01010
6–00 1 1 1 0 1 1
Examplesh2add.uw a0, a1, a220c5c53b3b c5 c5 20
sh3add rd, rs1, rs2 rd = (rs1 << 3) + rs2: index an array of 8-byte elements. Zba
31–250 0 1 0 0 0 0
24–20rs201100
19–15rs101011
14–121 1 0
11–7rd01010
6–00 1 1 0 0 1 1
Examplesh3add a0, a1, a220c5e53333 e5 c5 20
sh3add.uw rd, rs1, rs2 rd = (zext32(rs1) << 3) + rs2. Zba
31–250 0 1 0 0 0 0
24–20rs201100
19–15rs101011
14–121 1 0
11–7rd01010
6–00 1 1 1 0 1 1
Examplesh3add.uw a0, a1, a220c5e53b3b e5 c5 20
add.uw rd, rs1, rs2 rd = zext32(rs1) + rs2. Zba
31–250 0 0 0 1 0 0
24–20rs201100
19–15rs101011
14–120 0 0
11–7rd01010
6–00 1 1 1 0 1 1

zext.w rd, rs is add.uw rd, rs, x0.

Exampleadd.uw a0, a1, a208c5853b3b 85 c5 08
slli.uw rd, rs1, shamt rd = zext32(rs1) << shamt. Zba
31–260 0 0 0 1 0
25–20shamt000010
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 1 0 1 1
Exampleslli.uw a0, a1, 20825951b1b 95 25 08
andn rd, rs1, rs2 rd = rs1 & ~rs2. Zbb
31–250 1 0 0 0 0 0
24–20rs201100
19–15rs101011
14–121 1 1
11–7rd01010
6–00 1 1 0 0 1 1
Exampleandn a0, a1, a240c5f53333 f5 c5 40
orn rd, rs1, rs2 rd = rs1 | ~rs2. Zbb
31–250 1 0 0 0 0 0
24–20rs201100
19–15rs101011
14–121 1 0
11–7rd01010
6–00 1 1 0 0 1 1
Exampleorn a0, a1, a240c5e53333 e5 c5 40
xnor rd, rs1, rs2 rd = ~(rs1 ^ rs2). Zbb
31–250 1 0 0 0 0 0
24–20rs201100
19–15rs101011
14–121 0 0
11–7rd01010
6–00 1 1 0 0 1 1
Examplexnor a0, a1, a240c5c53333 c5 c5 40
clz rd, rs1 Count leading zero bits (XLEN if rs1 is 0). Zbb
31–200 1 1 0 0 0 0 0 0 0 0 0
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 0 0 1 1
Exampleclz a0, a16005951313 95 05 60
ctz rd, rs1 Count trailing zero bits. Zbb
31–200 1 1 0 0 0 0 0 0 0 0 1
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 0 0 1 1
Examplectz a0, a16015951313 95 15 60
cpop rd, rs1 Population count (number of set bits). Zbb
31–200 1 1 0 0 0 0 0 0 0 1 0
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 0 0 1 1
Examplecpop a0, a16025951313 95 25 60
clzw rd, rs1 Count leading zeros of the low 32 bits. Zbb
31–200 1 1 0 0 0 0 0 0 0 0 0
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 1 0 1 1
Exampleclzw a0, a16005951b1b 95 05 60
ctzw rd, rs1 Count trailing zeros of the low 32 bits. Zbb
31–200 1 1 0 0 0 0 0 0 0 0 1
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 1 0 1 1
Examplectzw a0, a16015951b1b 95 15 60
cpopw rd, rs1 Population count of the low 32 bits. Zbb
31–200 1 1 0 0 0 0 0 0 0 1 0
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 1 0 1 1
Examplecpopw a0, a16025951b1b 95 25 60
max rd, rs1, rs2 Signed maximum. Zbb
31–250 0 0 0 1 0 1
24–20rs201100
19–15rs101011
14–121 1 0
11–7rd01010
6–00 1 1 0 0 1 1
Examplemax a0, a1, a20ac5e53333 e5 c5 0a
maxu rd, rs1, rs2 Unsigned maximum. Zbb
31–250 0 0 0 1 0 1
24–20rs201100
19–15rs101011
14–121 1 1
11–7rd01010
6–00 1 1 0 0 1 1
Examplemaxu a0, a1, a20ac5f53333 f5 c5 0a
min rd, rs1, rs2 Signed minimum. Zbb
31–250 0 0 0 1 0 1
24–20rs201100
19–15rs101011
14–121 0 0
11–7rd01010
6–00 1 1 0 0 1 1
Examplemin a0, a1, a20ac5c53333 c5 c5 0a
minu rd, rs1, rs2 Unsigned minimum. Zbb
31–250 0 0 0 1 0 1
24–20rs201100
19–15rs101011
14–121 0 1
11–7rd01010
6–00 1 1 0 0 1 1
Exampleminu a0, a1, a20ac5d53333 d5 c5 0a
sext.b rd, rs1 Sign-extend the low byte. Zbb
31–200 1 1 0 0 0 0 0 0 1 0 0
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 0 0 1 1
Examplesext.b a0, a16045951313 95 45 60
sext.h rd, rs1 Sign-extend the low halfword. Zbb
31–200 1 1 0 0 0 0 0 0 1 0 1
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 0 0 1 1
Examplesext.h a0, a16055951313 95 55 60
zext.h rd, rs1 Zero-extend the low halfword (RV64 encoding). Zbb
31–200 0 0 0 1 0 0 0 0 0 0 0
19–15rs101011
14–121 0 0
11–7rd01010
6–00 1 1 1 0 1 1
Examplezext.h a0, a10805c53b3b c5 05 08
rol rd, rs1, rs2 Rotate left by the low bits of rs2. Zbb
31–250 1 1 0 0 0 0
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–00 1 1 0 0 1 1
Examplerol a0, a1, a260c5953333 95 c5 60
ror rd, rs1, rs2 Rotate right by the low bits of rs2. Zbb
31–250 1 1 0 0 0 0
24–20rs201100
19–15rs101011
14–121 0 1
11–7rd01010
6–00 1 1 0 0 1 1
Exampleror a0, a1, a260c5d53333 d5 c5 60
rori rd, rs1, shamt Rotate right by an immediate. Zbb
31–260 1 1 0 0 0
25–20shamt001101
19–15rs101011
14–121 0 1
11–7rd01010
6–00 0 1 0 0 1 1

There is no roli: assemblers turn it into rori with XLEN - shamt.

Examplerori a0, a1, 1360d5d51313 d5 d5 60
rolw rd, rs1, rs2 32-bit rotate left, result sign-extended. Zbb
31–250 1 1 0 0 0 0
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–00 1 1 1 0 1 1
Examplerolw a0, a1, a260c5953b3b 95 c5 60
rorw rd, rs1, rs2 32-bit rotate right, result sign-extended. Zbb
31–250 1 1 0 0 0 0
24–20rs201100
19–15rs101011
14–121 0 1
11–7rd01010
6–00 1 1 1 0 1 1
Examplerorw a0, a1, a260c5d53b3b d5 c5 60
roriw rd, rs1, shamt 32-bit rotate right by an immediate, result sign-extended. Zbb
31–250 1 1 0 0 0 0
24–20shamt01101
19–15rs101011
14–121 0 1
11–7rd01010
6–00 0 1 1 0 1 1
Exampleroriw a0, a1, 1360d5d51b1b d5 d5 60
orc.b rd, rs1 Each result byte is 0xff if the source byte is non-zero, else 0x00. Zbb
31–200 0 1 0 1 0 0 0 0 1 1 1
19–15rs101011
14–121 0 1
11–7rd01010
6–00 0 1 0 0 1 1

Used by optimized strlen / memchr to find a zero byte in a word.

Exampleorc.b a0, a12875d51313 d5 75 28
rev8 rd, rs1 Reverse the byte order (RV64 encoding): endianness swap. Zbb
31–200 1 1 0 1 0 1 1 1 0 0 0
19–15rs101011
14–121 0 1
11–7rd01010
6–00 0 1 0 0 1 1
Examplerev8 a0, a16b85d51313 d5 85 6b
bclr rd, rs1, rs2 Clear bit rs2 of rs1. Zbs
31–250 1 0 0 1 0 0
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–00 1 1 0 0 1 1
Examplebclr a0, a1, a248c5953333 95 c5 48
bclri rd, rs1, shamt Clear bit shamt of rs1. Zbs
31–260 1 0 0 1 0
25–20shamt000101
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 0 0 1 1
Examplebclri a0, a1, 54855951313 95 55 48
bext rd, rs1, rs2 Extract bit rs2 of rs1 into bit 0. Zbs
31–250 1 0 0 1 0 0
24–20rs201100
19–15rs101011
14–121 0 1
11–7rd01010
6–00 1 1 0 0 1 1
Examplebext a0, a1, a248c5d53333 d5 c5 48
bexti rd, rs1, shamt Extract bit shamt of rs1 into bit 0. Zbs
31–260 1 0 0 1 0
25–20shamt000101
19–15rs101011
14–121 0 1
11–7rd01010
6–00 0 1 0 0 1 1
Examplebexti a0, a1, 54855d51313 d5 55 48
binv rd, rs1, rs2 Invert bit rs2 of rs1. Zbs
31–250 1 1 0 1 0 0
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–00 1 1 0 0 1 1
Examplebinv a0, a1, a268c5953333 95 c5 68
binvi rd, rs1, shamt Invert bit shamt of rs1. Zbs
31–260 1 1 0 1 0
25–20shamt000101
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 0 0 1 1
Examplebinvi a0, a1, 56855951313 95 55 68
bset rd, rs1, rs2 Set bit rs2 of rs1. Zbs
31–250 0 1 0 1 0 0
24–20rs201100
19–15rs101011
14–120 0 1
11–7rd01010
6–00 1 1 0 0 1 1
Examplebset a0, a1, a228c5953333 95 c5 28
bseti rd, rs1, shamt Set bit shamt of rs1. Zbs
31–260 0 1 0 1 0
25–20shamt000101
19–15rs101011
14–120 0 1
11–7rd01010
6–00 0 1 0 0 1 1
Examplebseti a0, a1, 52855951313 95 55 28
Privileged
mret Return from a machine-mode trap: pc = mepc, privilege restored from mstatus.MPP. Priv
31–250 0 1 1 0 0 0
24–200 0 0 1 0
19–150 0 0 0 0
14–120 0 0
11–70 0 0 0 0
6–01 1 1 0 0 1 1
Examplemret3020007373 00 20 30
sret Return from a supervisor-mode trap: pc = sepc, privilege restored from sstatus.SPP. Priv
31–250 0 0 1 0 0 0
24–200 0 0 1 0
19–150 0 0 0 0
14–120 0 0
11–70 0 0 0 0
6–01 1 1 0 0 1 1
Examplesret1020007373 00 20 10
wfi Wait for interrupt: hint that the hart can stall until an interrupt is pending. Priv
31–250 0 0 1 0 0 0
24–200 0 1 0 1
19–150 0 0 0 0
14–120 0 0
11–70 0 0 0 0
6–01 1 1 0 0 1 1
Examplewfi1050007373 00 50 10
sfence.vma rs1, rs2 Flush address-translation caches. rs1 = virtual address (x0 = all), rs2 = ASID (x0 = all). Priv
31–250 0 0 1 0 0 1
24–20rs201011
19–15rs101010
14–120 0 0
11–70 0 0 0 0
6–01 1 1 0 0 1 1

Required after changing page tables or satp.

Examplesfence.vma a0, a112b5007373 00 b5 12
Compressed (16-bit)
c.addi4spn rd', sp, nzuimm rd' = sp + nzuimm (multiple of 4). Expands to addi rd', sp, nzuimm. C
15–130 0 0
12–5nzuimm[5:4|9:6|2|3]01000000
4–2rd'010
1–00 0

The all-zero halfword 0x0000 is defined as illegal, so jumping into zeroed memory traps.

Examplec.addi4spn a0, sp, 16080808 08
c.fld rd', uimm(rs1') Expands to fld rd', uimm(rs1'). C
15–130 0 1
12–10uimm[5:3]001
9–7rs1'011
6–5uimm[7:6]00
4–2rd'010
1–00 0
Examplec.fld fa0, 8(a1)258888 25
c.lw rd', uimm(rs1') Expands to lw rd', uimm(rs1'). C
15–130 1 0
12–10uimm[5:3]000
9–7rs1'011
6–5uimm[2|6]10
4–2rd'010
1–00 0
Examplec.lw a0, 4(a1)41c8c8 41
c.ld rd', uimm(rs1') Expands to ld rd', uimm(rs1'). C
15–130 1 1
12–10uimm[5:3]001
9–7rs1'011
6–5uimm[7:6]00
4–2rd'010
1–00 0
Examplec.ld a0, 8(a1)658888 65
c.fsd rs2', uimm(rs1') Expands to fsd rs2', uimm(rs1'). C
15–131 0 1
12–10uimm[5:3]001
9–7rs1'011
6–5uimm[7:6]00
4–2rs2'010
1–00 0
Examplec.fsd fa0, 8(a1)a58888 a5
c.sw rs2', uimm(rs1') Expands to sw rs2', uimm(rs1'). C
15–131 1 0
12–10uimm[5:3]000
9–7rs1'011
6–5uimm[2|6]10
4–2rs2'010
1–00 0
Examplec.sw a0, 4(a1)c1c8c8 c1
c.sd rs2', uimm(rs1') Expands to sd rs2', uimm(rs1'). C
15–131 1 1
12–10uimm[5:3]001
9–7rs1'011
6–5uimm[7:6]00
4–2rs2'010
1–00 0
Examplec.sd a0, 8(a1)e58888 e5
c.nop No operation (addi x0, x0, 0). Encoding 0x0001. C
15–130 0 0
120
11–70 0 0 0 0
6–20 0 0 0 0
1–00 1
Examplec.nop000101 00
c.addi rd, nzimm Expands to addi rd, rd, nzimm. C
15–130 0 0
12nzimm[5]1
11–7rd01010
6–2nzimm[4:0]11101
1–00 1
Examplec.addi a0, -3157575 15
c.addiw rd, imm Expands to addiw rd, rd, imm (RV64). C
15–130 0 1
12imm[5]0
11–7rd01010
6–2imm[4:0]00001
1–00 1
Examplec.addiw a0, 1250505 25
c.li rd, imm Expands to addi rd, x0, imm. C
15–130 1 0
12imm[5]0
11–7rd10001
6–2imm[4:0]11111
1–00 1
Examplec.li a7, 3148fdfd 48
c.addi16sp sp, nzimm Expands to addi sp, sp, nzimm (multiple of 16): prologues and epilogues. C
15–130 1 1
12nzimm[9]1
11–70 0 0 1 0
6–2nzimm[4|6|8:7|5]01110
1–00 1
Examplec.addi16sp sp, -64713939 71
c.lui rd, nzimm Expands to lui rd, nzimm (rd not x0/x2). C
15–130 1 1
12nzimm[17]0
11–7rd01010
6–2nzimm[16:12]00001
1–00 1
Examplec.lui a0, 1650505 65
c.srli rd', shamt Expands to srli rd', rd', shamt. C
15–131 0 0
12shamt[5]0
11–100 0
9–7rd'010
6–2shamt[4:0]00011
1–00 1
Examplec.srli a0, 3810d0d 81
c.srai rd', shamt Expands to srai rd', rd', shamt. C
15–131 0 0
12shamt[5]0
11–100 1
9–7rd'010
6–2shamt[4:0]00011
1–00 1
Examplec.srai a0, 3850d0d 85
c.andi rd', imm Expands to andi rd', rd', imm. C
15–131 0 0
12imm[5]0
11–101 0
9–7rd'010
6–2imm[4:0]00111
1–00 1
Examplec.andi a0, 7891d1d 89
c.sub rd', rs2' Expands to sub rd', rd', rs2'. C
15–131 0 0
120
11–101 1
9–7rd'010
6–50 0
4–2rs2'011
1–00 1
Examplec.sub a0, a18d0d0d 8d
c.xor rd', rs2' Expands to xor rd', rd', rs2'. C
15–131 0 0
120
11–101 1
9–7rd'010
6–50 1
4–2rs2'011
1–00 1
Examplec.xor a0, a18d2d2d 8d
c.or rd', rs2' Expands to or rd', rd', rs2'. C
15–131 0 0
120
11–101 1
9–7rd'010
6–51 0
4–2rs2'011
1–00 1
Examplec.or a0, a18d4d4d 8d
c.and rd', rs2' Expands to and rd', rd', rs2'. C
15–131 0 0
120
11–101 1
9–7rd'010
6–51 1
4–2rs2'011
1–00 1
Examplec.and a0, a18d6d6d 8d
c.subw rd', rs2' Expands to subw rd', rd', rs2'. C
15–131 0 0
121
11–101 1
9–7rd'010
6–50 0
4–2rs2'011
1–00 1
Examplec.subw a0, a19d0d0d 9d
c.addw rd', rs2' Expands to addw rd', rd', rs2'. C
15–131 0 0
121
11–101 1
9–7rd'010
6–50 1
4–2rs2'011
1–00 1
Examplec.addw a0, a19d2d2d 9d
c.j offset Expands to jal x0, offset (±2 KiB). C
15–131 0 1
12–2imm[11|4|9:8|10|6|7|3:1|5]00000100000
1–00 1
Examplec.j 64a08181 a0
c.beqz rs1', offset Expands to beq rs1', x0, offset (±256 B). C
15–131 1 0
12–10imm[8|4:3]010
9–7rs1'010
6–2imm[7:6|2:1|5]00000
1–00 1
Examplec.beqz a0, 16c90101 c9
c.bnez rs1', offset Expands to bne rs1', x0, offset. C
15–131 1 1
12–10imm[8|4:3]010
9–7rs1'010
6–2imm[7:6|2:1|5]00000
1–00 1
Examplec.bnez a0, 16e90101 e9
c.slli rd, shamt Expands to slli rd, rd, shamt. C
15–130 0 0
12shamt[5]0
11–7rd01010
6–2shamt[4:0]00011
1–01 0
Examplec.slli a0, 3050e0e 05
c.fldsp rd, uimm(sp) Expands to fld rd, uimm(sp). C
15–130 0 1
12uimm[5]0
11–7rd01010
6–2uimm[4:3|8:6]01000
1–01 0
Examplec.fldsp fa0, 8(sp)252222 25
c.lwsp rd, uimm(sp) Expands to lw rd, uimm(sp). C
15–130 1 0
12uimm[5]0
11–7rd01010
6–2uimm[4:2|7:6]00100
1–01 0
Examplec.lwsp a0, 4(sp)451212 45
c.ldsp rd, uimm(sp) Expands to ld rd, uimm(sp). C
15–130 1 1
12uimm[5]0
11–7rd00001
6–2uimm[4:3|8:6]01000
1–01 0
Examplec.ldsp ra, 8(sp)60a2a2 60
c.jr rs1 Expands to jalr x0, 0(rs1). c.jr ra (0x8082) is the compressed ret. C
15–131 0 0
120
11–7rs100001
6–20 0 0 0 0
1–01 0
Examplec.jr ra808282 80
c.mv rd, rs2 Expands to add rd, x0, rs2. C
15–131 0 0
120
11–7rd01010
6–2rs201011
1–01 0
Examplec.mv a0, a1852e2e 85
c.ebreak Breakpoint (0x9002). Debuggers use it on targets with C. C
15–131 0 0
121
11–70 0 0 0 0
6–20 0 0 0 0
1–01 0
Examplec.ebreak900202 90
c.jalr rs1 Expands to jalr ra, 0(rs1). C
15–131 0 0
121
11–7rs100101
6–20 0 0 0 0
1–01 0
Examplec.jalr t0928282 92
c.add rd, rs2 Expands to add rd, rd, rs2. C
15–131 0 0
121
11–7rd01010
6–2rs201011
1–01 0
Examplec.add a0, a1952e2e 95
c.fsdsp rs2, uimm(sp) Expands to fsd rs2, uimm(sp). C
15–131 0 1
12–7uimm[5:3|8:6]001000
6–2rs201010
1–01 0
Examplec.fsdsp fa0, 8(sp)a42a2a a4
c.swsp rs2, uimm(sp) Expands to sw rs2, uimm(sp). C
15–131 1 0
12–7uimm[5:2|7:6]000100
6–2rs201010
1–01 0
Examplec.swsp a0, 4(sp)c22a2a c2
c.sdsp rs2, uimm(sp) Expands to sd rs2, uimm(sp). C
15–131 1 1
12–7uimm[5:3|8:6]001000
6–2rs200001
1–01 0
Examplec.sdsp ra, 8(sp)e40606 e4

No instruction matches this filter.