版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
ComputerOrganization&ArchitectureChapter9
ComputerArithmetic9.1Arithmetic&LogicUnitDoesthecalculationsEverythingelseinthecomputeristheretoservethisunitController,registers,memory,I/OHandlesintegers,floatingpoint(real)numbersMaybeseparateFPU(mathsco-processor)MaybeonchipseparateFPU(486DX+)ALUInputsandOutputs4.2IntegerRepresentationOnlyhave0&1torepresenteverythingPositivenumbersstoredinbinarye.g.41=00101001NominussignNoperiod(.)n-bitbinarydigitsan-1an-2….a1a0denotesanunsignedintegerASign-MagnitudeRepresentationLeftmostbitissignbit0meanspositive1meansnegative+18=00010010-18=10010010ProblemsNeedtoconsiderbothsignandmagnitudeinarithmeticTworepresentationsofzero(+0and-0)RarelyusedTwo’sComplementRepresentation+3=00000011+2=00000010+1=000000010=00000000-1=11111111-2=11111110-3=11111101Complementofpositivenumber=unsignednumbercomplementofnegativenumber=bitwisenotunsignednumber+1GeometricDepictionofTwosComplementIntegersBenefitsOnerepresentationofzeroArithmeticworkseasily(seelater)Negatingisfairlyeasy3=00000011Booleancomplementgives 11111100Add1toLSBNegationSpecialCase10=00000000Bitwisenot11111111Add1to+1Result100000000Overflowisignored,so:0=0NegationSpecialCase2-128=10000000bitwisenot01111111Add1toLSB+1Result10000000So:-(-128)=-128XMonitorMSB(signbit)ItshouldchangeduringnegationRangeofNumbers8bit2’scomplement+127=01111111=27-1-128=10000000=-2716bit2scomplement+32767=01111111111111111=215-1-32768=10000000000000000=-215ConversionBetweenLengthsPositivenumberpackwithleadingzeros+18=00010010+18=0000000000010010Negativenumberspackwithleadingones-18=11101110-18=1111111111101110Extensionruleofcomplement:leftpacksignbitProofForabinarynumber:A,an-1an-2….a1a0
IfAispositive,an-1=0,then:IfAisnegative,an-1=1,then:9.3IntegerArithmeticNegationSign-magnitude:invertthesignbitComplement:bitwisenot+1E.g.18=0001001011101101+111101110-18=1110111000010001+100010010An-bitbinary:[-2n-1,2n-1-1]proofAddition&SubtractionCommentonAdditionandSubtractionNormalbinaryadditionMonitorsignbitforoverflowOverflowRule:iftwopositivenumbersortwonegativenumbersareadded,iffthesignofresultbecomesinversion,overflowoccurs.
SubtractionRule:Takecomplementofsubtrahendandaddtominuendi.e.a-b=a+(-b)NosubtractorinacomputerSoweonlyneedadditionandcomplementcircuitsHardwareforAdditionandSubtractionMultiplicationUnsignedintegersbyPencil-and-paper1011Multiplicand(11dec)x1101Multiplier(13dec) 1011Partialproducts0000Note:ifmultiplierbitis1copy1011 multiplicand(placevalue)1011 otherwisezero10001111Product(143dec)Note:needdoublelengthresultBycomputerMoreefficientAdditiononpartialproductratherthanwaitinguntiltheendNoneedforstorageallthepartialproducts,fewerregistersareneededSavesometimeForeach1onthemultiplier,anadditionandashiftoperationarerequired,butforeach0,onlyashiftisrequiredBlockDiagramofMultiplierSpecification3n-bitregisters:Q,M,A;one1-bitregister:C;initiallysetA,Cto0ControllogicreadsthebitsofthemultiplieroneatatimeIfQ0=1,thenthemultiplicandisaddedtotheAandtheresultsisstoredintheAThen,allofthebitsofC,AandQareshiftedrightonebit,Q0islostIfQ0=0,justrightshiftTheresulting2n-bitproductisintheAandQExecutionofExampleFlowchartforUnsignedBinaryMultiplicationMultiplyingNegativeNumbersStraightforwardmultiplicationdoesnotwork!1001(-7)x0011(3)1001100111011(27)(-5)XSolution1ConverttopositiveifrequiredMultiplyasaboveIfsignsweredifferent,negateanswerSolution2Booth’salgorithmBooth’sAlgorithmExampleofBooth’sAlgorithmExampleofBooth’sAlgorithm0000001101001InitialValues0011100111001ShiftRight0001110011001ShiftRight
1010110011001A=A+M1101011001001ShiftRight
0111001101001A=A-M
AQQ-1M1110101101001ShiftRight
ExampleofBooth’sAlgorithm(3)DivisionMorecomplexthanmultiplicationNegativenumbersarereallybad!BasedonlongdivisionDivisionofUnsignedBinaryIntegersFlowchartforUnsignedBinaryDivisionNegativeNumbersDivisionThemethodgiveninourbookistootroublesomeAsimpleschemeConverttopositiveifrequireddivisionasaboveIfsignsweredifferent,negateanswerSignIntegerdivision9.4FloatingPointRepresentationRealNumbersNumberswithfractionsCouldbedoneinpurebinary1001.1010=24+20+2-1+2-3=9.625Whereisthebinarypoint?Fixed?VerylimitedMoving?Howdoyoushowwhereitis?Principles±SB±E±:SignS:significandE:exponent,incomputer,usuallybiasedrepresentation±SBE‘B:baseisimplicit,neednotbestoredTypically,thebias=2k-1-1k:numberofbitsofexponentE.g.8-bitfield,thebiasis127Trueexponentvalues:[-127,128]Exponentvalue=trueexponent+biasThus,storedexponentvalueisunsignedTypical32-bitFloat-pointFormatSignsforExponentExponentisinexcessorbiasednotatione.g.Excess(bias)127means8bitexponentfieldPurevaluerange0-255Subtract127togetcorrectvalueRange-127to+128NormalizationFPnumbersareusuallynormalizedi.e.exponentisadjustedsothatleadingbit(MSB)ofmantissais1Sinceitisalways1thereisnoneedtostoreitc.f.Scientificnotationwherenumbersarenormalizedtogiveasingledigitbeforethedecimalpointe.g.3.123x103FPRangesFPRangesFora32bitnumber8bitexponent+/-21283.4x1038AccuracyTheeffectofchanginglsbofmantissa23bitmantissa2-231.2x10-7About6decimalplacesRelation:whenbitsofEareincreased,weexpandtherangeofexpressibledata,butresultinreductionofprecision(Elarger,mantissasmaller,scopelarger,precisionsmaller)Trade-offbetweenrangeandprecision
DensityofFloatingPointNumbers9.5Floating-pointarithmeticForadditionandsubtraction,wemustensurethatbothoperandshavethesameexponentvalue,whilemultiplicationanddivisionaremoresimple.X=XSBXe,Y=YSBYeX+Y=(XSBXe-Ye+YS)
BYeX-Y=(XSBXe-Ye-YS)
BYeXY=(XSYS)
BXe+Ye
X/Y=(XSYS)
BXe-YeFloating-pointoperationmaycausesomeproblems:ExponentoverflowExponentunderflowSignificantunderflowSignificantoverflowFPArithmetic+/-CheckforzerosAlignsignificands(adjustingexponents)ShiftingtheradixpointonthesmalleroperandOncetheoverflowoccurs,theinfluenceissmaller
AddorsubtractsignificandsNormalizeresultFPAdd&SubFPArit
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026 年骨科骨折术后快速康复护理实施课件
- 2026年小儿支原体肺炎护理个案
- 2026 年主动脉夹层患者血压管控监护护理
- 腹水分类题目及参考答案分享
- 降尘相关试题及答案解析
- 2026年安徽理工大学附属小学专职教师招聘建设考试参考题库及答案
- 金属工艺学经典试题及答案揭秘
- 2026年度税务师考试《税法(一)》核心考点解析
- 2026年零售产业数字化转型方案
- 2026年企业员工职业发展规划指导方案
- 2026福建福州古厝运营服务有限公司招聘5人考试模拟试题及答案详解
- 智慧医疗分级评价方法及标准(2025版)
- 2026湖南娄底涟源市明宏水利电力开发有限公司招聘12人笔试参考题库及答案详解
- 矿井灾害预防与应急处理全流程培训
- 北海市2025广西北海市招聘县级政府统计机构统计协管员(协统员)6人笔试历年参考题库典型考点附带答案详解
- 【中建】机电工程创优策划方案
- 机电设备安装项目施工进度计划模板
- 2026年工业机器人公司销售业绩考核与提成核算管理制度
- GB/T 7582-2025声学听阈与年龄和性别关系的统计分布
- 机关食堂运营服务方案
- GB/T 5782-2025紧固件六角头螺栓
评论
0/150
提交评论