92 lines
3.4 KiB
TeX
92 lines
3.4 KiB
TeX
\documentclass{book}
|
|
\usepackage{tikz}
|
|
|
|
\title{Unnamed Machine}
|
|
\author{A Very Terrible 16-bit Machine}
|
|
|
|
\begin{document}
|
|
\maketitle
|
|
\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}
|
|
\item[] R1
|
|
\item[] ...
|
|
\item[] R8
|
|
\end{itemize}
|
|
\section{Memory Model}
|
|
Memory will be implicitly mapped I/O. The bottom 3201 bytes of memory will be reserved for the keyboard input and graphics.
|
|
A single byte is reserved for the keyboard's input. The current key will be stored in byte 0xF37E, with the most significant bit being a flag indicating that the keyboard
|
|
is ready to be read from. This means that the character encoding is actually 7 bits.
|
|
Video memory starts at 0xF37F (62335 decimal), and every byte represents an ASCII character in monochrome.
|
|
\begin{figure}
|
|
\centering
|
|
\begin{tikzpicture}
|
|
\fill[gray!5] (0,0)rectangle(5,10);
|
|
%\draw (0,10) .. controls (-2,6) and (-2,4) .. (0,1);
|
|
%\draw (0,10) arc (0:180:3cm);
|
|
\draw (0,10) -- (5,10);
|
|
\draw (0,1) -- node[above] {Video 0xF37F} (5,1);
|
|
\draw (0,0) -- (5,0);
|
|
\node[label=right:Top 0x0000] at (5,10) {};
|
|
\node[label=right:Bottom 0xFFFF] at (5,0) {};
|
|
\end{tikzpicture}
|
|
\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}
|