Does REM raise an arithmetic exception on division by zero?
No. The M extension specifies that REM writes the dividend to rd as the remainder when the divisor is zero.
Signed remainder of rs1 / rs2, stored in rd
REM provides the XLEN-bit signed remainder of rs1 divided by rs2. A nonzero remainder has the dividend sign; a zero divisor returns the dividend; only most-negative divided by -1 overflows and returns zero. Except for overflow, dividend = divisor x quotient + remainder.
Starts with machine-code field decoding, then shows operand reads, instruction-specific execution, and ISA-visible state update.
This selector chooses only specification-defined division-result branches; it is not an exception, trap, or performance model.
The machine code is split by the current instruction format; the animation starts from encoding/decode.
This animation shows ISA-visible decode and state changes, not any specific CPU pipeline, cache, prediction, or timing implementation.
REM is the M-extension signed XLEN-bit remainder operation: rs1 is the dividend and rs2 is the divisor; the normal remainder is written to rd, and a nonzero remainder has the dividend sign.
Understand this scenario with real code like «rem a0, a1, a2 # a0 = a1 % a2 (signed)».
Understand this scenario with real code like «rem a0, a1, a2 # a0 = a1 % a2 (signed)».
No. The M extension specifies that REM writes the dividend to rd as the remainder when the divisor is zero.