[x]双补=x1>x≥022+x0>x≥–1(mod4)[x]双补=0,x2n>x≥02n+2+x0>x≥2n(mod2n+2)[A]补=00.1010[A]补=11.0001[B]补=00.1001[A+B]补=01.0011[B]补=11.0101[A+B]补=10.0110UsingDoublesignsTwosComplementinoverflowdetectionMethod2:双符号位法溢出的检测方法00,×××××11,×××××10,×××××01,×××××whentwosignbitsoftheresultaresamethereisnooverflowsumisnegativesumispositivewhentwosignbitsoftheresultaredifferentthereisoverflowNegativeoverflowPositiveoverflowMSBisthesignoftheresult溢出的检测方法CarryInCarryInCarryOutCarryOutALU31ALU30…result31(符号位)result30(符号位)CarryIn29CarryIn31CarryIn30a31a30b31b30OverflowMethod2:双符号位法UsingDoublesignsTwosComplementinoverflowdetectionwhentwosignbitsoftheresultaredifferentthereisoverflowwhentwosignbitsoftheresultaresamethereisnooverflowOverflow=1,溢出;0,没有溢出注:最高两位是符号位OverflowDetectionLogic(溢出检测逻辑)A-B=A+(–B)=A+B+1formtwocomplementbyinvertandaddoneSoweonlyneedadditionandcomplementcircuitsTaketwoscomplimentofsubtrahendandaddtominuend-i.e.a-b=a+(-b)HowtoperformSubtractionontheALUweconstructedbefore?abCarryInCarryOutresultabCarryOutCarryIn+Operation210OperationresultCarryInCarryOutALU01BinvertBinvertHowtoperformSubtractionontheALU
weconstructedbefore?WhenBinvert=1inputsoffulladderareaandb已有全加器加入输入为Ba0CarryIn=1result0Operationresult1CarryInALU0CarryOutCarryInCarryInCarryInCarryOutCarryOutCarryOutALU1ALU2ALU31b0result2result31a1a2a31b1b2b31……Binvert=1CarryIn=1Binvert=1Subtractionon32-bitALUForSubtractionA-B=A+(-B)=A+B+1a0CarryInresult0Operationresult1CarryInALU0CarryOutCarryInCarryInCarryInCarryOutCarryOutCarryOutALU1ALU2AL