Assembly to Machine Code

RISC-V Instruction Encoder

Enter a RISC-V assembly instruction and inspect the 32-bit machine word, hex value, binary bits, and field breakdown for learning opcode, funct, register fields, and immediate encoding. The current tool covers a verified integer-instruction subset.

Input

Examples
!Supported Scope

Supports a verified subset of 32-bit R/I/S/B/U/J integer instructions with x0-x31 and ABI register names, decimal/hex immediates, load/store offset(base) operands, common CSR names, and selected RV64 instructions. Pseudo instructions, labels, multi-line assembly, compressed instructions, A/F/D/C/V extensions, and most privileged or FENCE instructions are not supported here.

Encoding Result

Hex
0x003100B3
Format
R-type
Extension
RV32I
32-bit Field Layout
0000000
00011
00010
000
00001
0110011
310
funct7function code
bits 31..25
rs2source register 2
bits 24..20
rs1source register 1
bits 19..15
funct3function code
bits 14..12
rddestination register
bits 11..7
opcodeopcode
bits 6..0
0000 0000 0011 0001 0000 0000 1011 0011
Field Breakdown
funct7
bits 31..25
0x0
0000000
rs2
bits 24..20
3
00011
rs1
bits 19..15
2
00010
funct3
bits 14..12
0x0
000
rd
bits 11..7
1
00001
opcode
bits 6..0
51
0110011

Built-in Accuracy Checks

These fixed examples cover R/I/S/B/U/J formats and act as regression checks for the encoder's core paths.

add x1, x2, x3
0x003100B30x003100B3
addi x1, x2, 10
0x00A100930x00A10093
sw x1, 8(x2)
0x001124230x00112423
beq x1, x2, 16
0x002088630x00208863
lui x1, 0x10
0x000100B70x000100B7
jal x1, 32
0x020000EF0x020000EF