Handles AND, OR, and binary addition. Handles binary subtraction by
negating b
and doing addition. (Flip all the bits and set
CarryIn0 to 1 to compute two's complement.) Can also negate
a
to implement NOR operation. To determine whether
a < b
, calculate (a - b) and determine whether
result is negative (bit 31 is 1).
Overflow detection uses carry31 (overflow if unsigned), or
uses comparison of bit 31 of a
and b
(same
sign?) and comparison of that against bit 31 of the sum (different
sign?).
Stop and Think: How does the ALU execute the NOR operation? What control lines would be turned on?