How does an adder perform unsigned integer subtraction?

Your analysis is not correct. Actually is CPU ALU unit dependent. 🙂

In first case you are using 4 bit integer but you forgotten that the highest bit of 4 bit sign integer is sign! So you are checking only the Carry and Overflow status and not also Negative status bit.

In generally binary arithmetic operations add and sub are the same for signed integers and unsigned integers. Only affected flags are different.

Actually you must consider:

  • at signed integer arithmetic Carry, Overflow and Negative flags.
  • at unsigned integer arithmetic only Carry flags.

Detail explanation:

The mining of complement function is negation, so to get opposite negative number from positive and positive from negative. We can make binary complement on two ways. Lets see both cases for number 3.

  1. At unsigned arithmetic is compl (3) = b’0011′ xor b’1111′ + b’0001′ =
    b’1101′ + Carry (Carry is set only at compl (0))
  2. At signed arithmetic numbers is comply (3) = b’10000′ – b’0011′ = b’1101′ what
    is equal b’0000′ – b’0011′ = b’1101′ + Carry (Carry is clear only at
    compl (0))

In first case function complement also complement the carry bit and we have also the second interpretation of carry flag named borrow.

In second case everything is clear. If we have got carry (overflow) at complement that mean that we need another overflow to normalize the result of subtraction.

Leave a Comment