diff options
author | Andrew Waterman <andrew@sifive.com> | 2019-06-21 18:05:40 -0700 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2019-06-21 18:05:40 -0700 |
commit | c9bfb416ea54c962c51ed4cd5955a1f638164cc5 (patch) | |
tree | aaee3ed512eee65c99e59b3feb0299f8d8d328d6 /src/m.tex | |
parent | a81b0a0cf2e2846a6af9f6a492780bec72baa5f3 (diff) | |
download | riscv-isa-manual-c9bfb416ea54c962c51ed4cd5955a1f638164cc5.zip riscv-isa-manual-c9bfb416ea54c962c51ed4cd5955a1f638164cc5.tar.gz riscv-isa-manual-c9bfb416ea54c962c51ed4cd5955a1f638164cc5.tar.bz2 |
Clarify sign of REM; add commentary
Closes #375
Diffstat (limited to 'src/m.tex')
-rw-r--r-- | src/m.tex | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -98,8 +98,15 @@ MULDIV & divisor & dividend & DIV[U]W/REM[U]W & dest & OP-32 \\ DIV and DIVU perform an XLEN bits by XLEN bits signed and unsigned integer division of {\em rs1} by {\em rs2}, rounding towards zero. -REM and REMU provide the remainder of the -corresponding division operation. If both the quotient and remainder +REM and REMU provide the remainder of the corresponding division operation. +For REM, the sign of the result equals the sign of the dividend. + +\begin{commentary} +For both signed and unsigned division, it holds that +\mbox{$\textrm{dividend} = \textrm{divisor} \times \textrm{quotient} + \textrm{remainder}$}. +\end{commentary} + +If both the quotient and remainder are required from the same division, the recommended code sequence is: DIV[U] {\em rdq, rs1, rs2}; REM[U] {\em rdr, rs1, rs2} ({\em rdq} cannot be the same as {\em rs1} or {\em rs2}). Microarchitectures can |