diff --git a/docs/document.tex b/docs/document.tex index ab9c5b5..a56f919 100644 --- a/docs/document.tex +++ b/docs/document.tex @@ -9,6 +9,7 @@ \tableofcontents \chapter{Overview} \section{Introduction} + This is a very poorly thought out 16-bit machine, but you've got to start somewhere. Currently debating between a CPU status register, 80x86 style, or just placing arithmetic results into a predetermined register. \section{Registers} The following are the general purpose registers that can be used. \begin{itemize} @@ -36,6 +37,55 @@ \caption{Memory Layout} \end{figure} \chapter{ISA} + \section{Instruction Encoding} + Instructions are fixed to one byte in length. For instructions that can take a register as their first or second operand the 3 least significant bits are set + to indicate the register file to use. So an instruction with format XXXX X000 will use Register 1 and so forth all the way to the pattern XXXX X111, which will be Register 8. + In instances where the second operand may be one of three options bits 4 and 5 are set as shown below:\\\\ + \begin{tabular}{ c c } + \hline + Bit Pattern & Type \\ + \hline + XXX0 0XXX & Register \\ + XXX0 1XXX & Constant \\ + XXX1 0XXX & Address \\ + \hline + \end{tabular} \section{COPY} + \begin{tabular}{ c c c c } + \hline + Opcode & Mnemonic & Operand 1 & Operand 2 \\ + \hline\hline + 0x20 & COPY & Register & Immediate 16 / Address, Register \\ + 0xA0 & COPY & Address & Immediate 16 / Address, Register \\ + \hline + \end{tabular}\\[6pt] + Copies 2 bytes of data from either a memory address, a runtime constant or a CPU register into either another CPU register or a memory location. \section{CMP} + \begin{tabular}{ c c c c } + \hline + Opcode & Mnemonic & Operand 1 & Operand 2 \\ + \hline\hline + 0x80 & CMP & Register & Register, Immediate 16 / Address \\ + \hline + \end{tabular}\\[6pt] + Compares two values and sets a CPU status flag (maybe...). + \section{ADD} + \begin{tabular}{ c c c c } + \hline + Opcode & Mnemonic & Operand 1 & Operand 2 \\ + \hline\hline + 0x40 & ADD & Register & Register, Immediate 16 \\ + \hline + \end{tabular}\\[6pt] + Performs addition on a register with a value from another (or the same) register or a runtime constant. + \section{SUB} + \begin{tabular}{ c c c c } + \hline + Opcode & Mnemonic & Operand 1 & Operand 2 \\ + \hline\hline + 0x60 & SUB & Register & Register, Immediate 16 \\ + \hline + \end{tabular}\\[6pt] + Performs subtraction on a register with a value from another (or the same) register or a runtime constant. + \end{document}