From 9249454f332f6706a8fdae8756248cf9af0f8ccd Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sat, 21 Aug 2021 17:05:53 -0700 Subject: [PATCH] docs/DSP: Document overflow and carry behavior --- .../GameCube_DSP_Users_Manual.tex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/DSP/GameCube_DSP_Users_Manual/GameCube_DSP_Users_Manual.tex b/docs/DSP/GameCube_DSP_Users_Manual/GameCube_DSP_Users_Manual.tex index 7b875a0e79..b8e536c389 100644 --- a/docs/DSP/GameCube_DSP_Users_Manual/GameCube_DSP_Users_Manual.tex +++ b/docs/DSP/GameCube_DSP_Users_Manual/GameCube_DSP_Users_Manual.tex @@ -1038,6 +1038,16 @@ There are two pairs of conditions that work similarly: \texttt{EQ}/\texttt{NE} a \pagebreak{} +\section{Flags} + +Most opcodes update flags in the status register (\Register{\$sr}) based on their result. (Extended opcodes do not update flags.) + +Overflow (\texttt{O}) occurs when the result has wrapped around. The expression $C = A + B$ has overflown if $A > 0$ and $B > 0$ but $C \le 0$ or if $A < 0$ and $B < 0$ but $C \ge 0$. Any instruction that sets the \texttt{O} flag will also set the \texttt{OS} flag; when the \texttt{O} flag is set, \texttt{OS} is also set, but \texttt{OS} is not cleared when \texttt{O} is cleared. + +Carry (\texttt{C}) occurs when an arithmetic carry occurs and should be added to the next most significant word. The expression $C = A + B$ generates a carry if $A > C$. The DSP uses different logic for subtraction: the expression $C = A - B$ generates a carry if $A \ge C$ (so if $B = 0$, a carry is generated for all $A$). This is because the DSP uses a carry flag, not a borrow flag. + +\pagebreak{} + \section{Alphabetical list of opcodes} \pagebreak{}