RISC-V-Instruction_Formats
RISC-V-Instruction_Formats
[Index]
The RISC-V Instruction Set Manual Volume I: User-Level ISA lists 15 instruction formats where some of the
formats have multiple variants. For the ‘.insn’ pseudo directive the assembler recognizes some of the formats.
Typically, the most general variant of the instruction format is used by the ‘.insn’ directive.
The following table lists the abbreviations used in the table of instruction formats:
rs1 First source register number for operand x, can be GPR or FPR.
rs2 Second source register number for operand x, can be GPR or FPR.
C0
C1
C2
LOAD
LOAD_FP
STORE
STORE_FP
AUIPC
LUI
BRANCH
JAL
JALR
OP_32
OP_IMM
OP_IMM_32
OP_FP
MADD
MSUB
NMADD
NMSUB
AMO
MISC_MEM
SYSTEM
CUSTOM_0
CUSTOM_1
CUSTOM_2
CUSTOM_3
An instruction is two or four bytes in length and must be aligned on a 2 byte boundary. The first two bits of the
instruction specify the length of the instruction, 00, 01 and 10 indicates a two byte instruction, 11 indicates a
four byte instruction.
The following table lists the RISC-V instruction formats that are available with the ‘.insn’ pseudo directive:
+-------+-----+-----+-------+----+---------+
| func7 | rs2 | rs1 | func3 | rd | opcode6 |
+-------+-----+-----+-------+----+---------+
31 25 20 15 12 7 0
R type with 4 register operands: .insn r opcode6, func3, func2, rd, rs1, rs2, rs3
R4 type: .insn r4 opcode6, func3, func2, rd, rs1, rs2, rs3
+-----+-------+-----+-----+-------+----+---------+
| rs3 | func2 | rs2 | rs1 | func3 | rd | opcode6 |
+-----+-------+-----+-----+-------+----+---------+
31 27 25 20 15 12 7 0
+--------------+-----+-------+----+---------+
| simm12[11:0] | rs1 | func3 | rd | opcode6 |
+--------------+-----+-------+----+---------+
31 20 15 12 7 0
+--------------+-----+-----+-------+-------------+---------+
| simm12[11:5] | rs2 | rs1 | func3 | simm12[4:0] | opcode6 |
+--------------+-----+-----+-------+-------------+---------+
31 25 20 15 12 7 0
+-----------------+-----+-----+-------+----------------+---------+
| simm12[12|10:5] | rs2 | rs1 | func3 | simm12[4:1|11] | opcode6 |
+-----------------+-----+-----+-------+----------------+---------+
31 25 20 15 12 7 0
+--------------------------+----+---------+
| simm20[20|10:1|11|19:12] | rd | opcode6 |
+--------------------------+----+---------+
31 12 7 0
+------------+--------------+------------+---------------+----+---------+
| simm20[20] | simm20[10:1] | simm20[11] | simm20[19:12] | rd | opcode6 |
+------------+--------------+------------+---------------+----+---------+
31 30 21 20 12 7 0
+-------+--------+-----+---------+
| func4 | rd/rs1 | rs2 | opcode2 |
+-------+--------+-----+---------+
15 12 7 2 0
CI type: .insn ci opcode2, func3, rd, simm6
+-------+----------+--------+------------+---------+
| func3 | simm6[5] | rd/rs1 | simm6[4:0] | opcode2 |
+-------+----------+--------+------------+---------+
15 13 12 7 2 0
+-------+------------+-----+---------+
| func3 | uimm8[7:0] | rd' | opcode2 |
+-------+-------- ---+-----+---------+
15 13 5 2 0
+-------+------------+----+---------+
| func3 | uimm6[5:0] | rd | opcode2 |
+-------+------------+----+---------+
15 13 7 2 0
+-------+------------+------+------------+------+---------+
| func3 | uimm5[4:2] | rs1' | uimm5[1:0] | rd' | opcode2 |
+-------+------------+------+------------+------+---------+
15 13 10 7 5 2 0
+-------+------------+------+------------+------+---------+
| func3 | uimm5[4:2] | rs1' | uimm5[1:0] | rs2' | opcode2 |
+-------+------------+------+------------+------+---------+
15 13 10 7 5 2 0
+-- ----+----------+-------+------+---------+
| func6 | rd'/rs1' | func2 | rs2' | opcode2 |
+-------+----------+-------+------+---------+
15 10 7 5 2 0
+-------+--------------+------+------------------+---------+
| func3 | simm8[8|4:3] | rs1' | simm8[7:6|2:1|5] | opcode2 |
+-------+--------------+------+------------------+---------+
15 13 10 7 2 0
+-------+-------------------------------+---------+
| func3 | simm11[11|4|9:8|10|6|7|3:1|5] | opcode2 |
+-------+-------------------------------+---------+
15 13 2 0
For the complete list of all instruction format variants see The RISC-V Instruction Set Manual Volume I: User-
Level ISA.
Next: RISC-V Object Attribute, Previous: RISC-V Floating Point, Up: RISC-V Dependent Features [Contents]
[Index]