ComputerComputerOrganization&DesignOrganization&Design——TheHardware/SoftwareInterfaceTheHardware/SoftwareInterface25/1/271ArithmeticforComputersArithmeticforComputersArithmeticforComputersOperationsonintegersAdditionandsubtractionMultiplicationanddivisionWhataboutfractionsandrealnumbers?RepresentationandoperationsHowareoverflowscenarioshandled?e.g.AnoperationcreatesanumberbiggerthancanberepresentedHowdoeshardwarereallymultiplyanddividenumbers?MIPSArithmeticLogicUnit(ALU)MIPSArithmeticLogicUnit(ALU)MustsupporttheArithmetic/LogicoperationsoftheISAadd,addi,addiu,addusub,subumult,multu,div,divusqrtand,andi,nor,or,ori,xor,xoribeq,bne,slt,slti,sltiu,sltu323232m(operation)resultABALU4zeroovf11Withspecialhandlingforsignextend–addi,addiu,slti,sltiuzeroextend–andi,ori,xorioverflowdetection–add,addi,subComputerwordsarecomposedofbits;thuswordscanberepresentedasbinarynumbers.Whataboutfractionsandotherrealnumbers?WhathappenifanoperationscreatesanumberbiggerthancanberepresentedAndunderlyingthesequestionsisamystery:Howdoeshardwarereallymultiplyordividenumbers?3.1Introduction3.1Introduction25/1/274DifferentRepresentationsofNaturalNumbersXXVIIRomannumerals(notpositional)27Radix-10ordecimalnumber(positional)110112Radix-2orbinarynumber(alsopositional)Fixed-radixpositionalrepresentationwithkdigitsNumberNinradixr=(dk–1dk–2...d1d0)rValue=dk–1×rk–1+dk–2×rk–2+…+d1×r+d0Examples:(11011)2=1×24+1×23+0×22+1×2+1=27(2103)4=2×43+1×42+0×4+3=147PositionalNumberSystemsPositionalNumberSystemsBinaryNumbersBinaryNumbersEachbinarydigit(calledbit)iseither1or0Bitshavenoinherent(固有的)meaning,canrepresentUnsignedandsignedintegersCharactersFloating-pointnumbersImages,sound,etc.BitNumberingLeastsignificantbit(LSB)isrightmost(bit0)Mostsignificantbit(MSB)isleftmost(bit7inan8-bitnumber)10011101272625242322212001234567MostSignificantBitLeastSignificantBitConvertingBinarytoDecimalConvertingBinarytoDecimalEachbitrepresentsapowerof2Ev...