Updated the encoding figure to show the layout of the instructions, also decided that the mode byte will not be required for instructions with no arguments, but need to update the text to reflect this still.

This commit is contained in:
Garritt McCune
2024-08-09 15:09:43 -05:00
parent 8c0de609b5
commit 47f2f633c5
+35 -43
View File
@@ -1,4 +1,5 @@
\chapter{Instruction Set Architecture}
Instructions are variable width with their total length being determined by the mode setting byte that immediately follows the opcode byte. A break down of what a nibble means in the mode setting byte can be found in Figure \ref{fig:ModeSettingEncodingFigure}. Figure \ref{fig:opencoding} shows the layout of an instruction with the mode setting byte split down the middle to indicate the top nibble defines what \textit{Operand One} is meant to be interpreted as, followed by the lower nibble for \textit{Operand Two}. Depending on what mode is set for each operand there may be no bytes to follow the instruction (like in the case of nop) or there may be 8 bytes to follow (like in the case of mov [address], [address], assuming absolute addresses).
\newcommand{\OpcodeTable}[5] {
\noindent
@@ -14,36 +15,55 @@
\end{minipage}
}
\def\minY{-1.5em} \def\maxY{1.5em}
\def\minX{-7} \def\maxX{7}
\def\gap{0.25pt}
\def\minX{0}\def\maxX{\textwidth}
\def\minY{-0.25}\def\maxY{0.25}
\def\lnWidth{\textwidth / 4}
\section{Instruction Layout}
\section{Encoding Scheme}
Instructions are variable width with their total length being determined by the mode setting byte that immediately follows the opcode byte. A break down of what a nibble means in the mode setting byte can be found in Figure \ref{fig:ModeSettingEncodingFigure}. Figure \ref{fig:opencoding} shows the layout of an instruction with the mode setting byte split down the middle to indicate the top nibble defines what \textit{Operand One} is meant to be interpreted as, followed by the lower nibble for \textit{Operand Two}. Depending on what mode is set for each operand there may be no bytes to follow the instruction (like in the case of nop) or there may be 8 bytes to follow (like in the case of mov [address], [address], assuming absolute addresses).
% Placement info here: https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Figures
% Paths: https://tikz.dev/tikz-paths
\begin{figure}[h]
\begin{tikzpicture}
%Opcode Byte
\draw (-8, 0) -- (-4, 0) node[midway, below=1em] {Opcode};
\draw (-8, -0.25) -- (-8, 0.25) node[above] {7};
\draw (-4, -0.25) -- (-4, 0.25) node[above] {0};
%Mode Setting Byte
\draw (-3.75, 0) -- (0, 0) node[midway, below=1em] {Mode Setting};
\draw (-1.9, -0.25) -- (-1.9, 0.25) node[above] {3};
\draw (-3.75, -0.25) node[below] {7} -- (-3.75, 0.25) node[right] {Op. One};
\draw (0, -0.25) node[below] {0} -- (0, 0.25) node[left] {Op. Two};
\draw (\minX, 0) -- (\lnWidth, 0) node[midway, below=1em] {Opcode};
\draw (\minX, \minY) -- (\minX, \maxY) node[above] {7};
\draw (\lnWidth, \minY) -- (\lnWidth, \maxY) node[above] {0};
%Mode setting byte
\draw (\lnWidth, 0) -- (\lnWidth * 2, 0) node[midway, below=1em] (ModeByteLabel) {Mode};
\draw node[below of=ModeByteLabel] {(if required)};
\draw (\lnWidth, \minY) node[below] {7} -- (\lnWidth, \maxY);
\draw (\lnWidth * 2, \minY) node[below] {0} -- (\lnWidth * 2, \maxY);
\draw (\lnWidth + \lnWidth / 2, \minY) -- (\lnWidth + \lnWidth / 2, \maxY) node[above] {4 3};
%Operand One
\draw (\lnWidth * 2, 0) -- (\lnWidth * 3, 0) node[midway, below=1em] (OperOneLabel) {Operand One};
\draw (\lnWidth * 2, \minY) -- (\lnWidth * 2, \maxY) node[above] {31/15/7};
\draw (\lnWidth * 3, \minY) node[below] {0} -- (\lnWidth * 3, \maxY);
\draw node[below of=OperOneLabel] {(if required)};
%Operand Two
\draw (\lnWidth * 3, 0) -- (\lnWidth * 4, 0) node[midway, below=1em] (OperTwoLabel) {Operand Two};
\draw (\lnWidth * 3, \minY) -- (\lnWidth * 3, \maxY) node[above] {31/15/7} node[above=1.5em] {Operand Widths Based on Mode};
\draw (\lnWidth * 4, \minY) node[below] {0} -- (\lnWidth * 4, \maxY);
\draw node[below of=OperTwoLabel] {(if required)};
\end{tikzpicture}
\caption{Encoding}
\label{fig:opencoding} % https://www.overleaf.com/learn/latex/Referencing_Figures
\paragraph{Note} The \textit{Mode Setting} byte is split into an upper nibble and a lower nibble which will contain any of the values shown in Figure \ref{fig:ModeSettingEncodingFigure}.
\paragraph{Note} The \textit{Mode} byte is split into an upper nibble and a lower nibble which will contain any of the values shown in Figure \ref{fig:ModeSettingEncodingFigure}.
\end{figure}
\def\register{0000}\def\registerA{1000}
\def\eightBit{0001}\def\eightBitA{1001}
\def\sixteenBit{0010}\def\sixteenBitA{1010}
\def\thirtyBit{0100}\def\thirtyBitA{1100}
\def\none{1111}
\begin{figure}
\begin{tabularx}{\textwidth}{ | X | X | X | }
\hline
Operand & Immediate Value & Value As Address \\
\hline
Register & 0000 & 1000 \\
Register & \register & 1000 \\
8-Bit & 0001 & 1001 \\
16-Bit & 0010 & 1010 \\
32-Bit & 0100 & 1100 \\
@@ -53,39 +73,11 @@ Instructions are variable width with their total length being determined by the
\caption{Operand Modes Bit Pattern}
\label{fig:ModeSettingEncodingFigure} % https://www.overleaf.com/learn/latex/Referencing_Figures
\end{figure}
\begin{figure}
\begin{tikzpicture}
\draw (\minX, 0) -- (\maxX, 0);
\draw (\minX, \minY / 2) -- (\minX, \maxY / 2); %{$y$}; Note the $'s, those make something math stylized.
\draw (0, \minY / 2) -- (0, \maxY / 2); % Halfway mark
\draw (\maxX, \minY / 2) -- (\maxX, \maxY / 2);
\draw (\minX, -\maxY) node[below=1em] {31} [decorate, decoration={brace, amplitude=1em, mirror}] -- (0, -\maxY) node[below=1em] {16} node[midway, below=1em] {Op Code (16-bits)};
\draw (0, \maxY) node[above=1em] {15} [decorate, decoration={brace, amplitude=1em}] -- (\maxX, \maxY) node[above=1em] {0} node[midway, above=1em] {Near Address (16-bits)};
\end{tikzpicture}
\caption{Short Valued Opcodes}
\label{fig:OpShortEncodingFigure} % https://www.overleaf.com/learn/latex/Referencing_Figures
\end{figure}
\begin{figure}
\begin{tikzpicture}
\draw (\minX, 0) -- (\maxX, 0);
\draw (\minX, \minY / 2) -- (\minX, \maxY / 2); %{$y$}; Note the $'s, those make something math stylized.
\draw (0, \minY / 2) -- (0, \maxY / 2); % Halfway mark
\draw (\maxX, \minY / 2) -- (\maxX, \maxY / 2);
\draw (\maxX / 2, \minY / 2) -- (\maxX / 2, \maxY / 2); % Halfway mark for the lower 16 bits
\draw (\minX, -\maxY) node[below=1em] {31} [decorate, decoration={brace, amplitude=1em, mirror}] -- (0, -\maxY) node[below=1em] {16} node[midway, below=1em] {Op Code (16-bits)};
\draw (0, \maxY) node[above=1em] {15} [decorate, decoration={brace, amplitude=1em}] -- (\maxX / 2, \maxY) node[above=1em] {8} node[midway, above=1em] {Destination};
\draw (\maxX / 2, -\maxY) node[below=1em] {7} [decorate, decoration={brace, amplitude=1em, mirror}] -- (\maxX, -\maxY) node[below=1em] {0} node[midway, below=1em] {Source};
\end{tikzpicture}
\caption{Register Based Opcodes}
\label{fig:OpArgEncodingFigure} % https://www.overleaf.com/learn/latex/Referencing_Figures
\paragraph{Note} How the \textit{Destination} and \textit{Source} are interpreted is dependent on the opcode and operand mode bits as shown in Figure \ref{fig:AddressingModeBitPattern}.
\end{figure}
\clearpage
\section{Instructions}
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.
\subsection{Add}
\OpcodeTable{01 /r /r}{add /r, /r}{Register}{Register}{Sums \textit{Operand 1} and \textit{Operand 2} placing the result into \textit{Operand 1}.}
\OpcodeTable{01 /m /r /r}{add /r, /r}{Register}{Register}{Sums \textit{Operand 1} and \textit{Operand 2} placing the result into \textit{Operand 2}.}
\subsection{Sub}
\OpcodeTable{01 /r /r}{sub /r, /r}{Register}{Register}{Subtracts \textit{Operand 1} and \textit{Operand 2} placing the result into \textit{Operand 1}.}
\subsection{Mul}