\subsection{\index{rem}rem}

\index{remainder}
REMainder


\begin{tabular}{l}
  {\bf rem[s] r3, r2, r1} \\
  {\bf srem[s] r3, r2, r1} \\
\end{tabular}

~~~~~~
Computes r1 = r3 \% r2

~~~~~~
{\bf rem} performs an integer remainder of the two source operands
(r3 \% r2) and puts the result in destination operand (r1).

\begin{itemize}
\item The {\bf size} flag indicates that {\bf rem} performs the
remainder on the whole operands or only on a part of the operands.

\item The {\bf SIMD} flag indicates that {\bf rem} performs
multiple remainder on parts of the operand (the size of these parts
is defined by the {\bf size} flags).

\item The {\bf Sign} flag determines if the operands should be treated
as unsigned or signed values.

\end{itemize}

~~~~~~
This instruction triggers a math fault if the Reg2 operand is cleared (=0).
This behaviour could be avoided with saturated arithmetics.

~~~~~~
{ \em Remark :} the remainder computation is slow and heavy, try to use
powers-of-two remainder as to simply mask the MSB of the source operand,
which takes only a cycle to perform in the FC0.

\begin{center}

\begin{tabular}{|l|l|l|l|l|l|}
 \hline
\multicolumn{1}{|r| }{size :
} & \multicolumn{1}{c| }{8
} & \multicolumn{1}{c| }{6
} & \multicolumn{1}{c| }{6
} & \multicolumn{1}{c| }{6
} & \multicolumn{1}{c| }{6
 } \\
 \hline
\multicolumn{1}{|r| }{bits :
} & {31 ~ ~ ~ ~ ~ ~ ~ ~ 24
} & {23 ~ ~ ~ ~ ~ ~ 18
} & {17 ~ ~ ~ ~ ~ ~ 12
} & {11 ~ ~ ~ ~ ~ ~ 6
} & {5 ~ ~ ~ ~ ~ ~ 0
 } \\
 \hline
\multicolumn{1}{|r| }{function :
} & \multicolumn{1}{c| }{OP\_REM
} & \multicolumn{1}{c| }{Flags
} & \multicolumn{1}{c| }{Reg 3
} & \multicolumn{1}{c| }{Reg 2
} & \multicolumn{1}{c| }{Reg 1
}
\\ \hline

\end{tabular}



\begin{tabular}{|l|l|l|l|}
 \hline
\multicolumn{1}{|c| }{~ ~ Flags ~ ~
} & \multicolumn{1}{c| }{Syntax
} & {Values
} & {Function
 } \\
 \hline
\multicolumn{1}{|c| }{23-22
} & {.q, .d or .b postfix
} & {*
} & {Defines the size parameter
 } \\
 \hline
\multicolumn{1}{|c| }{21
} & {s- prefix
} & {1 if set
} & {Defines if the operation is SIMD
 } \\
 \hline
\multicolumn{1}{|c| }{20
} & {(none yet)
} & {0
} & {Reserved
 } \\
 \hline
\multicolumn{1}{|c| }{19
} & {-s postfix
} & {1 if set
} & {Signed flag
 } \\
 \hline
\multicolumn{1}{|c| }{18
} & {(none yet)
} & {0
} & {Reserved
}
\\ \hline

\end{tabular}


~
{\bf Performance (FC0 only) :}
\end{center}


{\em Execution Unit :} Integer Divide Unit\\
{\em Latency :} unknown ATM, depends on the size of the operands.\\
{\em Throughput :} unknown ATM, probably equal to the latency (not pipelined).\\

~

\pagebreak


