Files
lang/chapter 2.tex
T
2024-07-19 00:53:29 -05:00

50 lines
2.2 KiB
TeX

\chapter{Instruction Set Architecture}
\newcommand{\OpcodeTable}[4] {
\begin{tabularx}{\textwidth}{ | X | X | X | X | }
\hline
Opcode Hex & Instruction & Operand 1 & Operand 2 \\
\hline
#1 & #2 & #3 & #4 \\
\hline
\end{tabularx}
}
\def\minY{0} \def\maxY{0.5}
\def\minX{-7} \def\maxX{7}
\usetikzlibrary{decorations.pathreplacing}
\section{Encoding Schemes}
The /r represents a byte that specifies a register. /iX is for the immediate data type, where \textit{X} defines the width, which are 8, 16, or 32 bits.
\begin{figure}[!htb]
\begin{tikzpicture}
\draw (\minX, \minY) -- (\maxX, \minY);
\draw (\minX, \minY) -- (\minX, \maxY) node[above] {31}; %{$y$}; Note the $'s, those make something math stylized.
\draw (\maxX, \minY) -- (\maxX, \maxY) node[above] {0};
\draw (0, \minY) -- (0, \maxY) node[above] {15};
\draw [dotted] ({\maxX / 2}, \minY) -- ({\maxX / 2}, \maxY) node[above] {7};
\draw [decorate, decoration={brace, amplitude=1em, mirror}] (\minX, -\maxY) -- (0, -\maxY) node[midway, below=1em] {Op Code (16-bits)};
\draw [decorate, decoration={brace, amplitude=1em, mirror}] (0, -\maxY) -- ({\maxX / 2}, -\maxY) node[midway, below=1em] {Destination (8-bits)};
\draw [decorate, decoration={brace, amplitude=1em, mirror}] ({\maxX / 2}, -\maxY) -- (\maxX, -\maxY) node[midway, below=1em] {Source (8-bits)};
\end{tikzpicture}
\caption{Register Based Opcodes}
\end{figure}
\begin{figure}[!htb]
\begin{tikzpicture}
\draw (\minX, \minY) -- (\maxX, \minY);
\draw (\minX, \minY) -- (\minX, \maxY) node[above] {31}; %{$y$}; Note the $'s, those make something math stylized.
\draw (\maxX, \minY) -- (\maxX, \maxY) node[above] {0};
\draw (0, \minY) -- (0, \maxY) node[above] {15};
\draw [decorate, decoration={brace, amplitude=1em, mirror}] (\minX, -\maxY) -- (0, -\maxY) node[midway, below=1em] {Op Code (16-bits)};
\draw [decorate, decoration={brace, amplitude=1em, mirror}] (0, -\maxY) -- (\maxX, -\maxY) node[midway, below=1em] {Near Address (16-bits)};
\end{tikzpicture}
\caption{Short Valued Opcodes}
\end{figure}
\section{Instructions}
\subsection{Add}
\OpcodeTable{01 /r /r}{add /r, /r}{Register}{Register}
\paragraph{Description} Sums \textit{Operand 1} and \textit{Operand 2} placing the result into \textit{Operand 1}.