\subsection{\index{sub}sub}

\index{substraction}
SUBstraction


\begin{tabular}{l}
 {\bf sub[b/f] r3, r2, r1} \\
 {\bf ssub[b/f] r3, r2, r1} \\
\end{tabular}


~~~~~~
Computes r1 = r2 - r3

~~~~~~
{\bf sub} performs an integer substraction 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 sub} performs the
substraction on the whole operands or only on a part of the operands.

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

\item The {\bf floor} flag indicates that {\bf sub} does not
wrap'' if the second operand is bigger than the first one.

\item The {\bf borrow} flag (same as carry) indicates that the borrow
value is written to register number(r1\^1). If no borrow has been generated,
the neighbour register is cleared, otherwise the neighbour register is set to
-1.
\end{itemize}


\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\_SUB
} & \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
} & {-f postfix
} & {1 if set
} & {Floor flag
 } \\
 \hline
\multicolumn{1}{|c| }{18
} & {-b postfix
} & {1 if set
} & {Borrow flag ( {\bf 2r2w} )
}
\\ \hline

\end{tabular}


~

{\bf Examples : }
\end{center}


{\em Scalar :}

R1 contains 0x05 (we only consider the lower byte in the registers)\\
R2 contains 0x07

{\tt
{\bf sub.b r1,r2,r3 }: r3 = 0xFE (default behaviour)\\
{\bf subf.b r1,r2,r3 }: r3 = 0x00 (floor) \\
{\bf subb.b r1,r2,r3 }: r3 = 0xFE, r4= 0xFF (borrow) \\
}

{\em SIMD :}

R1 contains 0x0000000500000003 (in a 64-bit system)\\
R2 contains 0x0000000700000001

{\tt
{\bf ssub.b r1,r2,r3 }: r3 = 0x0000000700000003 (default behaviour)\\
{\bf ssubf.b r1,r2,r3 }: r3 = 0x0000000000000002 (floor)\\
{\bf ssubb.b r1,r2,r3 }: r3 = 0x000000FE00000002, r4= 0x000000FF00000000
(borrow)
}

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


{\em Execution Unit :} Add/Sub Unit\\
{\em Latency :} 1 cycle for 8-bit data, 2 cycles for 16-bit to 64-bit
data\\
{\em Throughput :} 1 operation per cycle per ASU.\\
{\em Scheduling :}\\
\begin{center}
byte chunks :

\begin{tabular}{|c|c|c|c|c|c|c|}
 \hline
{Cycle
} & { 1
} & { 2
} & { 3
} & { 4
} & { 5
} & { 6
} \\
 \hline
\multicolumn{1}{|c| }{Stage ~ ~
} & \multicolumn{1}{c| }{Fetch
} & \multicolumn{1}{c| }{Decode/
} & \multicolumn{1}{c| }{Xbar
} & \multicolumn{1}{c| }{ASU(1)
} & \multicolumn{1}{c| }{Xbar
} & \multicolumn{1}{c| }{Register
}
\\
\multicolumn{1}{|c| }{
} & \multicolumn{1}{c| }{
} & \multicolumn{1}{c| }{Register Read
} & \multicolumn{1}{c| }{
} & \multicolumn{1}{c| }{
} & \multicolumn{1}{c| }{
} & \multicolumn{1}{c| }{write
}
\\ \hline

\end{tabular}

word chunks :

\begin{tabular}{|l|l|l|l|l|l|l|l|}
 \hline
{Cycle
} & { 1
} & { 2
} & { 3
} & { 4
} & { 5
} & { 6
} & { 7
 } \\
 \hline
\multicolumn{1}{|c| }{Stage ~ ~
} & \multicolumn{1}{c| }{Fetch
} & \multicolumn{1}{c| }{Decode/
} & \multicolumn{1}{c| }{Xbar
} & \multicolumn{1}{c| }{ASU(1)
} & \multicolumn{1}{c| }{ASU(2)
} & \multicolumn{1}{c| }{Xbar
} & \multicolumn{1}{c| }{Register
}
\\
\multicolumn{1}{|c| }{
} & \multicolumn{1}{c| }{
} & \multicolumn{1}{c| }{Register Read
} & \multicolumn{1}{c| }{
} & \multicolumn{1}{c| }{
} & \multicolumn{1}{c| }{
} & \multicolumn{1}{c| }{
} & \multicolumn{1}{c| }{write
}
\\ \hline

\end{tabular}
\end{center}

\pagebreak

