# How do you subtract a constant using only an adder?

#### katevable

Joined Oct 23, 2015
7
I need to build a Logisim circuit in which I only have two inputs (two 8-bit immediates), an adder, and as many constants, inverters, and spitters as I need. I have 2 MUXs available to me and an Opcode that specifies the output. When the opcode is 00 or 10, I need A-1 and A-B as an output, respectively.

How do I do this with only an adder? That is, how do I subtract 1 from A and how do I subtract B from A with only an adder?

#### joeyd999

Joined Jun 6, 2011
4,477
Can you think of a way to redefine C=A-B as an addition problem?

#### katevable

Joined Oct 23, 2015
7
Do I just negate the thing being subtracted? I think I got it then

#### Attachments

• 55.1 KB Views: 5

#### joeyd999

Joined Jun 6, 2011
4,477
Do I just negate the thing being subtracted? I think I got it then
Close. Negation, though, is not exactly the same as inversion. Look up "2's complement".

#### katevable

Joined Oct 23, 2015
7
Ah right, two's complement. So I have to invert with the NOT gate and add 1 as the second input into the adder. But how do I add one in my circuit if I only am allowed one adder?

#### joeyd999

Joined Jun 6, 2011
4,477
Can you think of a way to input an extra 1 into the LSB of the adder? Hmmm.

#### MikeML

Joined Oct 2, 2009
5,444

#### katevable

Joined Oct 23, 2015
7
The adder has a carry-in, but how can I have a carry-in of 1 exclusively for subtraction (opcode 00 and 10)? I have splitters available to me but no additional MUXs

#### MikeML

Joined Oct 2, 2009
5,444
What is the rule for creating a Two's complement?

#### katevable

Joined Oct 23, 2015
7
I know I need to have a carry-in only when I'm subtracting, which is when the select line in my second MUX is 0. But my MUX-ing, if you will, happens before my adding, so I don't understand how I could possibly selectively have a carry-in. Is there something obvious that I'm missing?

#### katevable

Joined Oct 23, 2015
7
Wait, I'm trying to add an inverter to the output from the splitter of the first bit and wire that into my carry-in. I'm hoping this will work

#### katevable

Joined Oct 23, 2015
7
I think this works!

#### Attachments

• 46.8 KB Views: 15

#### MikeML

Joined Oct 2, 2009
5,444

#### joeyd999

Joined Jun 6, 2011
4,477
I think this works!
Yes. Addition has an amazing property that it is commutative.

#### WBahn

Joined Mar 31, 2012
26,398
I think this works!
Now THIS is how Homework Help is supposed to work. Great job, everyone!

What is the purpose of the left-most MUX? What does it mean to have an eight-bit input on one side of the MUX and a two-bit input on the other? I'm assuming you want an eight-bit constant that is equal to 1 (i.e., "00000001"). Can you show it that way on the diagram? If so, it will be less confusing. You should also annotate your diagram with a small table showing the defined OP codes and what operation is performed. Try to make the diagram self-sufficient and self-explanatory.

#### joeyd999

Joined Jun 6, 2011
4,477
Now THIS is how Homework Help is supposed to work. Great job, everyone!
Does this mean I get promoted to TA?

#### WBahn

Joined Mar 31, 2012
26,398
Does this mean I get promoted to TA?
Is there a "shudder-at-the-thought" emoticon?