# TIS-100 | Differential Converter

For the “Differential Converter” (Segment 20176) challenge we need to complete the following tasks:

• Read values from IN.A and IN.B.
• Write IN.A - IN.B to OUT.P.
• Write IN.B - IN.A to OUT.N.

## Solution

To start things off let’s look at our expected output, we can see that the outputs are opposite of each other. My solution to this challenge was to take input from IN.A MOV it to the ACC register and take the input from IN.B, MOV it to node #2 and subtract it from the value in the ACC register in node #2. So the first two inputs are IN.A=44 and IN.B=93 if we subtract the two values, the result will be -49 in node #2’s ACC register. Once we have the expected result, we then MOV the result from the ACC register to node #3 and use the NEG instruction to negate whatever value that is passed from node #2. After doing these steps, majority of the logic for this challenge is done, all there is left to do now is to transfer the results from the arithmetic to their respective outputs. The sequence of commands to solve for this challenge are:

MOV UP, ACC     #N2
SUB RIGHT       #N2
MOV ACC, RIGHT  #N2
MOV ACC, DOWN   #N2
MOV UP, LEFT    #N3
MOV LEFT, ACC   #N3
NEG             #N3
MOV ACC, DOWN   #N3
MOV ACC, DOWN   #N6
MOV ACC, DOWN   #N7
MOV ACC, DOWN   #N10
MOV ACC, DOWN   #N11



After completing the following sequences, you can now press F5 to run and solve the program!