Updated the opcode tables.

This commit is contained in:
2025-02-28 00:54:05 -06:00
parent 043311b2e0
commit 4f155090f3
+40 -24
View File
@@ -1,37 +1,49 @@
\ExplSyntaxOn
\int_new:N \l_options_count
\int_new:N \l_options_loop_count
% Opcode, Opcode Name, Description, Flags Affected, Options
% Maybe have an optional argument to relabel the operands Source and Destination
\NewDocumentCommand{\createoptabletwoparam}{ m m m m m }{
\int_set:Nn \l_options_loop_count {1}
\clist_clear_new:N \l_options
\clist_set:Nn \l_options {#3}
\int_set:Nn \l_options_count { \clist_count:N \l_options }
\__start_op_table:
\clist_map_inline:Nn \l_options {
\str_case:nnF{##1} {
{0}{
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~/r,~/r & r & r \\ \hline }
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~r,~r & r & r \\ }
}{1}{
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~/r,~[/r] & r & [r] \\ \hline }
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~r,~[r] & r & [r] \\ }
}{2}{
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~[/r],~/r2 & [r] & r \\ \hline }
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~[r],~r & [r] & r \\ }
}{5}{
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~/r,~[imm] & r & [imm] \\ \hline }
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~r,~[imm] & r & [imm] \\ }
}{8}{
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~imm,~/r & imm & r \\ \hline }
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~imm,~r & imm & r \\ }
}{9}{
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2 ~imm,~[r] & imm & [r] \\ \hline }
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2 ~imm,~[r] & imm & [r] \\ }
}{A}{
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~[imm],~/r & imm & r \\ \hline }
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~[imm],~r & imm & r \\ }
}{C}{
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~imm,~imm & imm & imm \\ \hline }
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~imm,~imm & imm & imm \\ }
}{D}{
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~imm,~[imm] & imm & [imm] \\ \hline }
\tl_put_right:Nn \l_tmpa_seq { #1~##1\_ & #2~imm,~[imm] & imm & [imm] \\ }
}
}{ \tl_put_right:Nn \l_tmpa_seq {#1~##1\_ & INVALID & -- & -- \\ \hline} }
}{ \tl_put_right:Nn \l_tmpa_seq {#1~##1\_ & INVALID & -- & -- \\ } }
\int_compare:nT { \l_options_loop_count < \l_options_count }
{
\tl_put_right:Nn \l_tmpa_seq { \midrule }
}
\int_incr:N \l_options_loop_count
}
\__end_op_table:nn {#5} {#4}
@@ -44,11 +56,11 @@
\str_case:nnF{#3} {
{imm}{
\tl_put_right:Nn \l_tmpa_seq { #1 & #2~imm & imm & None \\ \hline }
\tl_put_right:Nn \l_tmpa_seq { #1 & #2~imm & imm & None \\ }
}{reg}{
\tl_put_right:Nn \l_tmpa_seq { #1 & #2~/r & r & None \\ \hline }
\tl_put_right:Nn \l_tmpa_seq { #1 & #2~r & r & None \\ }
}
}{ \tl_put_right:Nn \l_tmpa_seq {#1 & INVALID & -- & -- \\ \hline} }
}{ \tl_put_right:Nn \l_tmpa_seq {#1 & INVALID & -- & -- \\ } }
\__end_op_table:nn {#5} {#4}
@@ -59,7 +71,7 @@
\__start_op_table:
\tl_put_right:Nn \l_tmpa_seq { #1 & #2 & None & None \\ \hline }
\tl_put_right:Nn \l_tmpa_seq { #1 & #2 & None & None \\ }
\__end_op_table:nn {#4} {#3}
@@ -69,13 +81,14 @@
\cs_new:Nn \__start_op_table: {
\seq_clear:N \l_tmpa_seq
\tl_set:Nn \l_tmpa_seq { \begin{tabularx}{\textwidth}{ | c | X | c | c | } \hline }
\tl_set:Nn \l_tmpa_seq { \begin{tabular}{ l l l l } \toprule }
\tl_put_right:Nn \l_tmpa_seq { Opcode & Instruction & Operand One & Operand Two \\ \hline }
\tl_put_right:Nn \l_tmpa_seq { Opcode & Instruction & Operand~One & Operand~Two \\ \midrule }
}
\cs_new:Npn \__end_op_table:nn #1 #2 {
\tl_put_right:Nn \l_tmpa_seq { \end{tabularx} }
\tl_put_right:Nn \l_tmpa_seq { \bottomrule }
\tl_put_right:Nn \l_tmpa_seq { \end{tabular} }
\tl_put_right:Nn \l_tmpa_seq { \paragraph{Description} #1 }
\tl_put_right:Nn \l_tmpa_seq { \paragraph{Flags Affected} #2 }
}
@@ -98,7 +111,7 @@ For the exact definition of these data types please refer to section \ref{sec:co
%Because this machine is little endian, the opcode byte is physically located on the right hand-side of a word.
% Placement info here: https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Figures
% Paths: https://tikz.dev/tikz-paths
\begin{figure}[h]
\begin{figure}[ht]
\begin{tikzpicture}
%\draw[help lines] (-8,-5) grid (8,5);
\node [draw, fit={(- 8.00, 0.00) (-12.00, 0.75)}, inner sep=0, label=center:Destination] (argtwo) {};
@@ -129,21 +142,24 @@ For the exact definition of these data types please refer to section \ref{sec:co
\subsection{Options Bit}
The Options byte makes use of all 8 bits to encode something about the instruction that precedes it. Reading the byte from left to right, we have the following properties:
\begin{verbatim}
Operand Type, Operand as Pointer, Destination Offset, Source Width
\end{verbatim}
\begin{itemize}
\item Operand Type
\item Operand as Pointer
\item Destination Offset
\item Source Width.
\end{itemize}
Starting with the high nibble we have two \quotes{columns}, \textit{Operand Type} and \textit{Operand as Pointer}, both spanning 2 bits for a total of 4 bits. The first two bits describe the type of operand we're expecting, zero (0) for \textit{register} and one (1) for an \textit{immediate} value. Bit 7 is for the source operand and bit 6 for the destination operand. Following this same layout (source then destination) we have two bits that say whether or not the operand should be treated as a pointer, zero (0) for no and one (1) for yes. For register type arguments this means to read the contents of whatever register is specified and treat that value as a full width pointer. If the argument is an immediate value, then we simply read one word and treat that word as a pointer.
The lower nibble consists of two \quotes{columns}, the same width as the previous two, that describe what kind of offset, if any, to apply to the destination operand and how many bytes are to be read from the source operand. Starting with bit 3 and ending on bit 2 we have the number of bytes to read for an offset. Bits 1 and 0 say how many bytes should be read from the source, which could be a register, an immediate value, or a pointer.
\begin{figure}[h]
\begin{figure}[ht]
\begin{tabular}{cccccccc}
\toprule
%\multicolumn{8}{c}{Bit Position} \\
\multicolumn{2}{c}{Type} & \multicolumn{2}{c}{Pointer} & \multicolumn{2}{c}{ } & \multicolumn{2}{c}{ } \\
7 & 6 & 5 & 4 & 3 & 2 & 1 & 0 \\
\midrule
Source & Destination & Source & Destination & \multicolumn{2}{c}{Destination Offset} & \multicolumn{2}{c}{Source Width} \\
Source & Destination & Source & Destination & \multicolumn{2}{c}{Offset} & \multicolumn{2}{c}{Source Width} \\
\bottomrule
\end{tabular}
\caption{Options Bit Physical Layout}
@@ -303,5 +319,5 @@ The Instruction column shows the assembly syntax that represents the opcode, wit
\subsection{POP}
\createoptableoneparam{24}{pop}{reg}{ None. }
{
Pops 32-bits from the top of the stack into the register \textit{Operand One}.
Pops one word from the top of the stack into the register \textit{Operand One}.
}