Getting Started
Synopsis
• Read the lab writeup on Canvas.
• This lab is due on September 12, 2017 at 23:59:59.
Requirements
• Arduino Due
• Logisim
Synopsis
This lab is half tutorial, half the real deal. You will be tasked with doing stuff with Logisim (read the writeup for details). Afterwards, it's off to programming in C++ with your Arduino. You will be making a calculator that does the basic mathematic operations... in binary. You are NOT allowed to use operators like +, -, *, /, %, and !. However, you are allowed to use &, |, ^, ~, <<, and >> Good luck!

NOTE: This page is actually under construction. I haven't got to writing tips that will help you in coding this assignment just yet. Check often!
A trick to Subtraction
One thing that you have learned recently is Two's compliment. If you recall during the Lab 2, I mentioned (in lab) to use "unsigned int" on a few lines of code to force no negatives to appear. Two's compliment can be abused in order to do subtraction on signed integers. To change a number from positive to negative, simply flip the bits, and then increment by 1.

Let's look at an example with 8 bit numbers (char)... How about the number 5?
``0000 0101 -> 1111 1010 -> 1111 1011``
Excellent. Now we have -5. So how would we compute 8 - 5? Just add 8 by the two's compliment of 5.
``````  0000 1000 -  8
+ 1111 1011 - -5
-----------
0000 0011 -  3``````
Therefore, you are allowed to implement your subtraction function with a function that does Addition, and a function that performs Two's Compliment.
Bypassing the restrictions
In your lab, you are told to implement "add", "two" (Flips the bits and increments by 1), "subtract", "multiply", and "divide" only with logical operations. However, if you manage to implement some of the functions, then you are allowed to use them in place of the "+=", "-=", etc operations. You worked hard to implement them, and they do the operations strictly through logical operators. Hence why they are allowed.

e.g., If you have implemented your "add" function, you may use it to increment a for loop like:
``````for (int i = 0; i < 32; i = Add(i, 1)) {