Electronic – 4 Bit ALU addition

alu

What are the values of the Z, V, C and N bits in the status register after the operation 1000 + 1111 for a 4-bit ALU?

Best Answer

Let's look at bit level what happens in an addition. We're going to add 1111 to 1000.

  • First, take the Least Significant Bits (LSB, the most right). We have a 1 and a 0. Summed, that makes 1. There's no overflow here.
  • Now, the second bit. Again a 1 and a 0, so again a 1. No overflow, again.
  • The same goes for the third bit.
  • The Most Significant Bit (MSB, the most left) is different: two ones. This gives summed a 0, with an overflow. That would mean the fifth bit would get an extra 1, however, there's no fifth bit, so the overflow is placed in the carry.

The end result is thus: 0111

Now, let's have a look at the status bits.

  • Z: "Indicates that the result of an arithmetic or logical operation (or, sometimes, a load) was zero." Is 0111 zero?
  • V: "Indicates that the signed result of an operation is too large to fit in the register width using twos complement representation." Did we have an overflow?
  • C: "used to indicate when an arithmetic carry or borrow has been generated out of the most significant ALU bit position." Was the MSB carried out?
  • N: "Indicates that the result of a mathematical operation is negative." Is the result negative?