\chapter{Overview} This is an attempt to distill what I know about how computers work into some kind of emulator / simulator. I'm curious to see if what I know at the moment is enough to allow me to emulate a general purpose computer. A computer that will be big-endian, using 8-bit bytes for its char type. The memory is a 32 bit linear address space allowing for a maximum of 2\textsuperscript{32} bytes to be addressable. \section{Registers} Eight 32-bit general purpose registers are available for holding operands and memory addresses along with a Flags Register. The Flags Register is a 32-bit register allowing for 32 flags. Currently there are only arithmetic flags which are Overflow (OF), Underflow (UF), and a Zero Flag (ZF). The overflow flag is set if there is a carry. A base pointer register contains a 32 bit address that points to the start of the current stack frame, which is the first opcode of the stack frame. Therefore the first argument would be addressed as such: \begin{verbatim} mov r1, bp - sizeof(void *) \end{verbatim} Finally we have the Program Counter which contains a 32 bit address that points to the next instruction to execute. \def\minY{-5} \def\maxY{5} \def\minX{-5} \def\maxX{5} \begin{figure}[h] \centering \begin{tikzpicture}[node distance=0cm] \node [draw, fit={(\minX, 0) (0, 0.5)}, label=center:Flags] (flags) {}; \node [draw, fit={(\minX, -1) (0, -1.5)}, label=center:r1] (r1) {}; \node [draw, fit={(\maxX / 2, 0) (\maxX, \minY)}, label=center:Memory] (memory) {}; \draw (flags); \node[above =of flags] {Status Register}; \node[above left=of flags] {31}; \node[above right=of flags] {0}; \draw (r1); \node[above=of r1] {General Purpose Registers}; \node[above left=of r1] {31}; \node[above right=of r1] {0}; \foreach \pos in {2,...,8} { \node [draw, fit={(\minX, -\pos) (0, -\pos - 0.5)}, label=center:r\pos] (r\pos) {}; \draw (r\pos); } \draw (memory); \node [above =of memory] {Linear Memory (2\textsuperscript{32} Bytes)}; \node [above right =of memory, yshift=-1em] {0x00000000}; \node [below right =of memory, yshift=1em] {0xFFFFFFFF}; %\draw (memory.north east) -- (memory.south west); %\node at (memory.south east) {test}; \end{tikzpicture} \caption{Register Bit Layout} \end{figure} \section{Memory Layout}