Chapter 10 - Computer Arithmetic LuisTarrataca [email protected] CEFET-RJ LuisTarrataca Chapter10-ComputerArithmetic 1/147 1 Motivation 2 ArithmeticandLogicUnit 3 Integerrepresentation Sign-MagnitudeRepresentation TwosComplementRepresentation RangeExtension LuisTarrataca Chapter10-ComputerArithmetic 2/147 4 IntegerArithmetic Negation Addition Subtraction HardwareBlockDiagramforAdder Multiplication UnsignedIntegers Twoscomplementmultiplication 5 Floating-pointrepresentation LuisTarrataca Chapter10-ComputerArithmetic 3/147 Motivation Motivation Howcanacomputerperformarithmeticoperations?Anyideas? LuisTarrataca Chapter10-ComputerArithmetic 4/147 Motivation Howcanacomputerperformarithmeticoperations?Anyideas? • Well,itdependsonthetypeofnumbers:integerandfloatingpoint; • Representationisacrucialdesignissue... • Guesswhatwewillbeseeingnext;) LuisTarrataca Chapter10-ComputerArithmetic 5/147 ArithmeticandLogicUnit What is the computer component responsible for calculations? Any ideas? LuisTarrataca Chapter10-ComputerArithmetic 6/147 ArithmeticandLogicUnit Arithmetic and Logic Unit What is the computer component responsible for calculations? Any ideas? ArithmeticLogicUnit • Componentthatperformsarithmeticandlogicaloperations; • Allothersystemcomponentsaretheremainlyto: • BringdataintotheALU; • Processdata; • Takeresultsbackout; LuisTarrataca Chapter10-ComputerArithmetic 7/147 ArithmeticandLogicUnit WhatisthegeneralorganizationoftheALU?Anyideas? LuisTarrataca Chapter10-ComputerArithmetic 8/147 ArithmeticandLogicUnit WhatisthegeneralorganizationoftheALU?Anyideas? Verygenerally: Figure:ALUInputsandoutputs(Source:[Stallings,2015]) LuisTarrataca Chapter10-ComputerArithmetic 9/147 ArithmeticandLogicUnit Textualdescriptionofthepreviousimage(1/2): • Operandsforarithmetic/logicoperationsareprovidedinregisters; • Resultsofanoperationarealsostoredinregisters; • ALUmayalsosetflagsastheresultofanoperation,e.g.: • Overflowflagissetto1: • Ifaresultexceedsthelengthoftheregisterintowhichitistobestored. • Zeroflagissetto1: • Ifaresultproducesvaluezero(JMP.Z,JMP.NZ,etc...) LuisTarrataca Chapter10-ComputerArithmetic 10/147
Description: