Electronic – what happens when the carry bit is zero in addition/subtraction algo for hardware

computersregister

img

This is the algorithm in flow diagram for addition and subtraction in computers.

A(s) is the sign bit of A
B(s) is the sign bit of B

//(s) denotes the subscript

E is the register that has a carry bit
AVF is the register that carries the overflow bit.
A + As is the accumulator register. (A saver !)
Initially the XOR operation is carried that checks if the sign bit of two numbers is same or not.

I understand this algorithm except the circled part. What is happening when E = 0 ? Please explain taking a simple example.

Best Answer

What is happening is:

  1. A is inverted.
  2. A has 1 added to it.
  3. A is inverted again.

This generates what is called the "Two's Complement" of the number in A.

Two's Complement is a way of encoding negative numbers in binary.

You can read more about Two's Complement here: http://en.wikipedia.org/wiki/Two%27s_complement