版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 甲壳多糖提炼工操作水平竞赛考核试卷含答案
- 音圈绕制工班组考核评优考核试卷含答案
- 淡水鱼类繁育工安全知识竞赛知识考核试卷含答案
- 石雕工岗前安全生产基础知识考核试卷含答案
- 考古探掘工安全专项考核试卷含答案
- 626 QZCY9手动气动阻车器
- 《某品牌水果发展的PEST分析案例》
- 5.3 社会历史的主体 课件-高中政治统编版必修四哲学与文化
- 室内卡丁车竞技免责协议书
- 2026年北京市海淀区初三下学期一模化学试卷和答案
- 2026山东菏泽生物医药职业学院招聘工作人员120人农业考试参考题库及答案解析
- 2026年音乐教资考前冲刺测试卷附参考答案详解【达标题】
- 2026年北京理工大学博士英语真题及答案
- 3.4 我们来造“环形山”课件(内嵌视频) 2025-2026学年教科版科学三年级下册
- 广东省茂名电白区七校联考2026届中考一模数学试题含解析
- 直播基地规划建设方案报告
- (新疆二模)新疆2026年普通高考三月适应性检测文科综合试卷(含答案)
- 喷漆房安全管理制度
- 《无人机导航定位技术》全套教学课件
- 山东中烟工业有限责任公司招聘笔试题库2026
- 基因型知识点讲解课件
评论
0/150
提交评论