1. Dec 8, 2007

### ECE

If two 4 bit numbers are being added in the Adder/Subtractor unit e.g. X and Y. Then according to my text book it is written that the Add/Sub Unit is built in a way that the add/sub signal (which chooses whether to add/subtract) is XOR with Y (the position where the number that is to be complemented is entered). But what if the user wants to enters { -5-3 }.How will the add/sub unit work then? Should the X input be also XOR with another signal similar to add/sub?

-Thanks

2. Dec 8, 2007

### rbj

but you must also add 1 to the inverted bits. you do that with this adder/subtractor by coupling in the same 1 that goes to the XORs (the add/subtract signal where add=0 and subtract=1) to the carry-in of the LSB (which is tied to 0 if you're adding).

no, just put in for A the bit pattern for -5, which is the same bit pattern for an unsigned 4-bit number that is 16-5 or 11. so -5 is 1011 and you subtact 3 (0011) which gets complimented to 1100 and goes into your full-adder, but then you gotta remember to couple in the 1 into the carry-in of the LSB (which effectively adds 1).

1011 + 1100 + 0001 = [1]1000

or -8 since the 1 that carries out falls off the edge.