Why is overflow error in two's complement addition represented by XOR-ing the last two carries?
Overflow can only occur if the two numbers have the same sign. If it has occurred then the result will have the opposite sign.
Consider the following 8 possibilities where A &amp; B represent the MSB of the number (sign) and S is the sum sign.
A B Cp   S  Cf  Overflow?
0 0 0    0  0
0 0 1    1  0  Y
0 1 0    1  0
0 1 1    0  1
1 0 0    1  0
1 0 1    0  1
1 1 0    0  1   Y
1 1 1    1  1
So overflow has occurred iff Cp⊕Cf = 1