M instructions
Integer multiply and divide
This chapter describes the standard integer multiplication and division
instruction extension, which is named M and contains instructions
that multiply or divide values held in two integer registers.
Tip
We separate integer multiply and divide out from the base to simplify low-end implementations, or for applications where integer multiply and divide operations are either infrequent or better handled in attached accelerators.
Extension description from riscv-unified-db, reformatted.
Specification chapter: The RISC-V Instruction Set Manual, src/unpriv/m-st-ext.adoc.
Instructions (13)
| Mnemonic | Name (riscv-unified-db) | XLEN |
|---|---|---|
div | Signed division | RV32 and RV64 |
divu | Unsigned division | RV32 and RV64 |
divuw | Unsigned 32-bit division | RV64 only |
divw | Signed 32-bit division | RV64 only |
mul | Signed multiply | RV32 and RV64 |
mulh | Signed multiply high | RV32 and RV64 |
mulhsu | Signed/unsigned multiply high | RV32 and RV64 |
mulhu | Unsigned multiply high | RV32 and RV64 |
mulw | Signed 32-bit multiply | RV64 only |
rem | Signed remainder | RV32 and RV64 |
remu | Unsigned remainder | RV32 and RV64 |
remuw | Unsigned 32-bit remainder | RV64 only |
remw | Signed 32-bit remainder | RV64 only |