3.6 MIC-1 Calculator

In MIC-1 assembly, write a program that reads pairs of 16-bit integers from the UART and adds them together then displays the result.

You only need to deal with positive numbers.

Your program should expect any number of pairs of numbers. Each element of the pair should be delimited by a space character ( ) and each pair should be delimited by newline characters (\n). The addition of each pair should be printed one-by-one with a separating newline character (\n).

The input values must be in base-10 and the output must be in base-10. You will need the microcode instructions you implemented in MIC-1 Microcode Extension to do this. The MULT and DIV operations are useful for converting to and from base-10. The RSHIFT operation is useful for shifting string bytes into position for the UART.

The output must be displayed in the following format, as demonstrated with the input 1 2:

1 + 2 = 3

The program should run indefinitely until an addition that would overflow occurs. In that case, then you must output a message in the following format, as demonstrated with the input 32000 32000:

32000 + 32000 = OVERFLOW

After outputting this message, you must HALT.

The program should have no other output.

In addition to outputting sums, your program should store the actual sums in the program’s memory somewhere that you decide. The sums should be in memory in order starting from the first sum outputted. In the event of overflow, the record should show the number -1. You are not responsible for dealing with situations where so many numbers have been entered that the stack is overwritten, provided the stack is started as high in memory as possible.

You must turn in
  • A README file that contains a short write-up of your project. It should discuss the approach you took to solving the problem, it should discuss any problems or issues that still remain, it should discuss any interesting things that you learned in the course of the project. Finally, it should provide the grade you believe the project deserves with a detailed explanation of why. This explanation should almost certainly focus on why you believe the program is correct.

    This file must be in plain-text. If you need formatting, use Markdown. It must be limited to 80 characters wide, unless you are quoting program output.

  • Your assembly source, named calc.asm.

  • Your compiled object file, named calc.o.

  • A test input file, named test.in, than contains example input. It must contain at least ten (10) pairs of numbers. In addition to five (5) pairs of your choosing, it must contain these pairs:

    235 0

    16341 957

    23786 12400

    12 23

    1 1343

    Your test input should end with debugger input to display the in-memory sum table.

  • A test output file, named test.out, that contains the expected output for the test input file.

  • A Makefile that builds the program and then tests it by running it with test.in as the input and compares the actual output to test.out. You may assume that the masm binary from MIC-1 Microcode Extension is in the PATH. You may also assume that the mic1 binary is in the PATH and that rmd.prom is a compiled, correct microcode interpreter from MIC-1 Microcode Extension.

This assignment will be graded based on its correctness and your ability to articulate why it is correct.