\documentclass{sig-alternate-05-2015}
\begin{document}

% ACM templates include ISBN and DOI...
\isbn{N.A.}
\doi{N.A.}

\title{EE480 Assignment 1: Logick Encoding And Assembler}
\subtitle{Implementor's Notes}

\numberofauthors{1}
\author{
Hank Dietz\\
       \affaddr{Department of Electrical and Computer Engineering}\\
       \affaddr{University of Kentucky, Lexington, KY USA}\\
       \email{\texttt{hankd@engr.uky.edu}}
}

\maketitle
\begin{abstract}
This project involved the design of an encoding scheme for the
Logick instruction set. The encoding was then to be embodied in
an AIK specification.
\end{abstract}


\section{General Approach}

The first issue is how to encode 20 instruction types in a
16-bit instruction words where 12 bits are needed for the
operands of some instructions. The remaining 4 bits can only
distinguish 16 instruction types. Complicating matters a bit, I
also wanted the encoding of similar integer and LNS operations
to differ in just one bit.  I further imposed the constraint
that I wanted the \texttt{sy} instruction to encode as 0, so
that any instruction sequence wandering into empty memory will
cause a trap to the operating system.

The resulting scheme divides what could be viewed as a 4-bit
opcode into 3 bits of opcode and single bit that is 0 for
integer operations, and 1 for LNS operations.

I also wanted the destination register to always be in next
4-bit field, but took advantage of the fact that register 0 is
not a valid destination to keep the two sources in the last two
4-bit fields for the \texttt{cl} and \texttt{co} comparisons and
also to distinguish \texttt{st} from \texttt{or}. I was able to
keep the two registers being read as always the last two 4-bit
fields, except for the \texttt{li} and \texttt{si} instructions,
which are still consistent about where the destination register
field is.

The condition code selection is really just 3 bits, but I put that
into a 4-bit field by using 1 bit at the end to distingush between
\texttt{br} and \texttt{jr}.

% insert a break to roughly level columns...
\vfill\pagebreak

\section{Macros}

Two intelligent macros are implemented that pick the
smallest-size implementation of a pseudo-instruction. The
\texttt{la} operation either does an \texttt{li} or an
\texttt{li} followed by an \texttt{si}.  Similarly, \texttt{jb}
selects between a \texttt{br} and a \texttt{jr}, but loading the
register is further optimized rather like \texttt{la} was. There
is also the slight complication that \texttt{u10} is used to
hold the target address, so it had better not be used to mean
something else in the program.

\section{constants}

Not much to report here; all constants were given the values
that correspond to the order they were listed in the assignment.

\section{Issues}

Really nothing terrible. There was a potential name conflict
between use of \texttt{ne} to mean negate or not-equal, but
this was resolved by making the negate instruction be called
\texttt{mi}, for minus.  I avoided using \texttt{.alias} because
I think this spec makes a better human reference for what the
assembly language looks like. I also changed the symbolic names
for some operands to make their field use more obvious -- e.g.,
\texttt{st} has arguments t and s, not d and s.

The hardest thing to do is to test this. It really isn't
testable in any obvious way... so this was tested only by manual
inspection with a variety of simple test cases, including the
one given in the handout.  There were no errors flagged by AIK.

\end{document}
