9 `.insn`
Emit an arbitrary instruction. This is useful for custom instructions or for very new instructions which an assembler may not support.
There are three overloads:
.insn \<value\>- emit a raw instruction with the given value.insn \<insn_length\>, \<value\>- the same, but also verify that the instruction length has the given value in bytes.insn \<type\> \<fields\>
<type> is the instruction type (e.g. r, i, s, cj, …). These types are specified in the RISC-V ISA specification.
<fields> is a comma-separated list of the instruction fields. The order of the fields is achieved by grouping them and listing them from LSB to MSB. The groups are:
- opcode fields
- function fields
- register fields
- immediates and symbols
E.g. an instruction with the fields (sorted from LSB to MSB):
opcode7, rd, func3, rs1, rs2, func7
Gets listed as follows:
opcode7, func3, func7, rd, rs1, rs2
For more examples, refer to the Binutils documentation.