\mytitle{Assembly, at Last!}{\co}

After a long wait, we finally got to assembly. We began using a simple
assembly-like language called MARIE\footnote{\url{https://marie.js.org/}} which
is implemented as an online simulator, allowing us to write and run our projects
and having simple debugging tools at our disposal.

Being the first homework, the assignment didn't consist of too many questions
complex questions, but just enough to get us started.

Questions included introspection of the memory addresses, to figure out the
addresses and values of registers and memory locations. Additionally, we had to
write a simple program that would take two numbers from the user and multiply
them both by three. Since multiplication is not a built-in operation in MARIE,
we had to implement it using addition. Given that the multiplicand is a
constant, three, we could simply add the multiplicand to itself twice, for each
of the input numbers.

\begin{lstlisting}[language=Ant]
  Load  a / AC =  a (2)
  Add   a / AC = AC (2) + a (2)
  Add   a / AC = AC (4) + a (2)
  Store a /  a = AC (6)

  Halt

  a, DEC 2 / a = 2
\end{lstlisting}

That's the basics, but of course we had to implement input and output as well,
which wasn't all that much, just a few extra instructions.

Following that portion was a set of problems which had us answering what
hexadecimal opcodes would be generated for a given MARIE instruction, but
backwards, so which instruction would be generated for a given opcode. This was
a good exercise to get us familiar with the opcodes and their corresponding
instructions. Additionally, we dealt with a few theoretical problems such as
given a IR (instruction register) and the offsets for the opcode and operand
fields, what we would be able to accomplish with that information. The questions
included things such as the number of opcodes possible, the number of
addressable addresses, the most negative decimal number that would be
represented, and so on.

Finally, we had to write a program which would take two numbers from the user,
and just swap them around. Similar to how you would implement this in C, we had
to use a temporary variable to store one of the numbers while we overwrite it
with the other number.

\begin{lstlisting}[language=Ant]
  / t = a
  Load  a
  Store t

  / a = b
  Load  b
  Store a

  / b = t
  Load  t
  Store b

  Halt

  a, DEC 1 / a = 1
  b, DEC 2 / b = 2
  t, DEC 0 / t = 0
\end{lstlisting}

We had to implement input and output here as well, but you get the idea.

The quiz for this week was nearly identically to the homework, save for the
programming portion which was worth 40 points compared to the usual 4 or 8. The
question was similar to the homeworks, except we had to add a portion that
calculated the sum of the two numbers. 