《计算机系统与应用课件 chapter6 Instruction system》由会员分享,可在线阅读,更多相关《计算机系统与应用课件 chapter6 Instruction system(46页珍藏版)》请在金锄头文库上搜索。
1、ComputerSystemandApplication Chapter6 InstructionSystemofCPU ConceptsofInstructionSystem Instructionsystem machineinstructionsetInterfacebetweenhardwareandsoftwareDetermineCPU sstructureandfunctionDeterminestructureandfunctionofprogramminglanguageThesamepartviewedbyarchitectandprogrammerAlargepartof
2、CPUdesigntaskisimplementinginstructionsetDifferentCPUarchitecture differentinstructionsetRISCvsCISCContentsofdesigninginstructionsetInstructionformatdesignInstructionfunctiondesignDatatypesupportAddressingmodedesign ComponentsofAnInstruction InstructionsetThecollectionofdifferentinstructionsthatthep
3、rocessorcanexecuteTens hundredsofinstructionsAninstructionincludesOpcodesAddressingmodeflagAddresses sourceoperandsandresultoperandsMainmemoryorvirtualmemoryRegisterI OdevicesSourceoperandmaybeimmediateoperandAddressofnextinstruction explicitorimplicitMachineinstructionispresentedasasequenceof0 1cod
4、esManyformatsexistininstructionset 4 OpcodeOptimizationDesign FrequentlyusedopcoderepresentationsFixed lengthopcodeHuffmanencodingExtendedHuffmanencodingFixed lengthopcodeOnebytelengthSimplehardware buttotalopcodeistoolongUsedinRISCCPUHuffmanencodingVariableopcodelengthShortestaverageopcodelengthExt
5、endedHuffmanencodingCombiningfixed lengthandHuffmanencoding 5 HuffmanEncoding PrincipleFrequentlyeventsarerepresentedbyshortcodeAveragecodelengthisshortestTheorybasisisentropycodingEntropyShortestaverageencodinglengthpi usageprobabilityofanopcodeinprogram amountofinformationoftheopcodeRedundantamoun
6、tofinformationH averagecodelengthofanencodingmode 6 ExampleforHuffmanEncoding SupposeaCPUhas7opcodesandoccurringprobabilityinprogramisshownasthetable Problems Iffixed lengthopcodeisused howmanybitsaretheopcode Howmanybitsaretheshortestaverageopcode entropy Howmuchisredundantamountofinformationforfix
7、ed lengthopcode 7 Solutions 7opcodes soinfixed lengthmode 3bitsareneededEntropyRedundantamountofinformationforfixed lengthopcode35 isredundantinformation 8 OpcodeEncodingMethodBasedonHuffman EncodingusingHuffmantree alsocalledminimumprobabilitymergingStep1 constructHuffmantreeStep2 encodingbranchesH
8、uffmantreeconstructingprocedureinaboveexampleArrangetheprobabilitiesof7opcodeshigh downMergingprobablenodesinbinarytreefromrighttoleftEncodeeachbranchusing0or1Leftbranchis0andrightbranchis10 1sequencefromtheroottoaleafnodeistheencodingoftheopcodeSeenextslide 9 HuffmanTree 10 AverageCodeLengthofHuffm
9、anEncoding Averagecodelengthpi usageprobabilityofithopcodeinprogramli lengthofithopcodeAccordingtovaluesofthefig Averagecodelength Amountofredundantinformation Huffmanencodingapproachesoptimizedentropy 11 ProsandConsofHuffmanEncoding ProsShortaveragecodelengthLittleredundantinformationConsOpcodeirre
10、gularityNoeasyforinstructiondecodingandcompilingNotesHuffmanencodingisnotuniqueTotalcodelengthandaveragecodelengthareunique 12 ExtendedHuffmanEncoding Huffmanencodingonthewholecombineswithlocalfixed lengthencodingTrade offbetweenHuffmanandfixed lengthSimplifydecoderandcompilerMultipleencodingmethods
11、 13 AddressCodeDesign Totaladdresslengthdependsonthenumberofaddresses typesandaddressingmodesTypicaladdressesininstructions3 2 1 0Toomanyaddressesmayexist butseldomusedAddressesselectionrulesMaketheprogramshortestMaketheprogramfastestShorteningaddresslengthtoavoidtoolonginstructionIndirectaddressing
12、RegisterindirectaddressingIndexaddressing 14 InstructionFormatDesign Itisaverycomplicatedproblem limitedbyInstructionfunctionandlengthFieldsandbitsofeachfieldAddressingmodesLengthofmainmemoryunitManyinstructionformatsexistinainstructionsetTrade offbetweenopcodelengthandaddressingabilityisneededVaria
13、bleopcodeMultipleopcodes 15 X86InstructionFormat Thex86isequippedwithavarietyofinstructionformatsTheinstructionformatisveryflexibleTypicalCISCinstructions 16 DataTypes DatatypedesignisanimportantcontentforinstructionsetInfluencingthestructureandfunctionofCPUDeterminingthedatatypesofHLLTypicaldatatyp
14、esAddressesNumbersCharactersLogicaldataSpecialdatatypesListsStrings 17 Numbers NumbersincomputerarelimitedanddiscreteTypicalnumbersBinaryintegerorbinaryfixedpointBinaryfloatingpointDecimalBinaryinteger itsvalueinTwosComplementRepresentationisWhere overflowwilloccurifavalueexceedsthisscope 18 Numbers
15、 BinaryfloatingpointnumbersAnyfloat pointnumbercannormalizedasor0 1 1 andbase2neednottobestoredExponentinbiasedrepresentationOriginalvalue 2k 1 1 RemovingsignofexponentIEEE754standardisnormallyused 19 Numbers PackeddecimalEachdecimaldigitisrepresentedbya4 bitcodeBCD BinaryCodedDecimal Standardsignva
16、luesare1100forpositiveand1101fornegativeateithertheleftorrightendExample 369 1100001101101001 369 1101001101101001MostofCPUssupportpackeddecimalAvoidingconvertingoverheadinfrequentI Oapplications 20 Characters CharacterorstringisnormallyrepresentedinASCIIcodeAnothercharacterrepresentationisEBCDICExtendedbinarycodeddecimalinterchangecode 0 1 codesof8bitsrepresentacharacterUsedinpastIBMlargecomputerWe dbetterrememberASCIIcodesofseveralspecialcharacters 0 48 A 65 enter 13 space 32Convertinglowercas