Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
docs/DSP: Document overflow and carry behavior
  • Loading branch information
Pokechu22 committed Aug 22, 2021
1 parent a8ec0ad commit 9249454
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/DSP/GameCube_DSP_Users_Manual/GameCube_DSP_Users_Manual.tex
Expand Up @@ -1038,6 +1038,16 @@ \section{Conditional opcodes}

\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{}
Expand Down

0 comments on commit 9249454

Please sign in to comment.