计算机组成与结构:chapter10 Instruction Sets Characteristics and Functions_第1页
计算机组成与结构:chapter10 Instruction Sets Characteristics and Functions_第2页
计算机组成与结构:chapter10 Instruction Sets Characteristics and Functions_第3页
计算机组成与结构:chapter10 Instruction Sets Characteristics and Functions_第4页
计算机组成与结构:chapter10 Instruction Sets Characteristics and Functions_第5页
已阅读5页,还剩56页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

ComputerOrganization&ArchitectureChapter10

InstructionSets:CharacteristicsandFunctions10.1MachineinstructioncharacteristicsWhatisTheInstructionSetArchitectures?Theattributesofasystemasseenbytheprogrammer,i.e.,theconceptualstructureandfunctionalbehavior,asdistinctfromtheorganizationofthedataflowsandcontrols,thelogicdesign,andthephysicalimplementation.

-Amdahl,BlaawandBrooks,1964...theportionofthemachinevisibletotheprogrammerorcompilerwriter.

-HennesseyandPatterson,1990SoftwareHardwareISAInstructionSetThecollectionofinstructionsthatCPUcanexecuteTheinstructionsetdeterminatesthefunctionofCPUMachineCode,BinaryForconvenience,usuallyrepresentedbyassemblycodesElementsofanInstructionOperationcode(Opcode)DothisSourceOperandreferenceTothisResultOperandreferencePuttheanswerhereNextInstructionReferenceWhenyouhavedonethat,dothis...BranchinstructionPC

InstructionCycleStateDiagramWherearealltheOperands?Cache

or

mainmemoryorvirtualmemoryCPUregistersIfonlyoneregisterexists,referencetoitmaybeimplicitFormanyregisters,eachisassignedauniquenumberI/OdeviceTheinstructionmustspecifytheI/Omodule&deviceoranothermemoryaddressfortheoperationInstructionRepresentation

Inmachinecode,eachinstructionhasauniquebitsequenceTheinstructionisdividedintofieldssuchasthefollowingformat:Itisdifficultforboththeprogrammerandreaderstodealwithbinarycodeofmachineinstructions,thus,asymbolicrepresentationisusede.g.ADD,SUB,MPY,DIV

LOAD,STOR,etc.OperandscanalsoberepresentedinthiswayADDA,BInstructionTypesDataprocessingDatastorage(mainmemory)Datamovement(I/O)Programflowcontrol:testandbranchAnydata-processingtaskmaybeexpressedbyaboveinstructionsAnyprogramwritteninhigh-levellanguagemaybetranslatedintoaboveinstructionsNumberofAddresses3addressesOpcodeOperand1,Operand2,Result(Operand1)OP(Operand2)→Resulta=b+c;Maybeaforth-nextinstruction(usuallyimplicit)NotcommonNeedsverylongwordstoholdeverything2addressesOpcodeOperand1,Operand2(Operand1)OP(Operand2)→Operand1Oneaddressdoublesasoperandandresulta=a+bReduceslengthofinstructionSometimes,requiressomeextrawork:usingMOVinstructionTemporarystoragetoholdsomeresults1addressOpcodeOperand1OP(Operand1)→Operand1or(Operand1)OP(OperandX)→Operand1ImplicitsecondaddressUsuallyaregister(accumulator,AC)Commononearlymachines

E.g:ACACOPA0(zero)addressesOpcodeAlladdressesimplicitornoaddressUsesastack0addressesinstructionswouldreferencetoptwounitsofstackE.g.TTOP(T-1)NOPHowManyAddresses?MoreaddressesMorecomplex(powerful?)instructionsMoreregistersInter-registeroperationsarequickerFewerinstructionsperprogramFeweraddressesLesscomplex(powerful?)instructionsMoreinstructionsperprogramFasterfetch/executionofinstructions,buttheprogramislonger,morecomplicatedandslowerModerncomputersadopttwo-orthree-addressinstructionsInstructionSetDesignDecisionsOperationrepertoireHowmanyops?Whatcantheydo?Howcomplexarethey?DatatypesAddresses,Numbers,Characters,LogicalDataInstructionformatsLengthofopcodefieldNumberofaddresses

RegistersNumberofCPUregistersavailableWhichoperationscanbeperformedonwhichregisters?Addressingmodes(later…)RISCvCISC10.2TypesofOperandsAddressesUnsignedintegerNumbersInteger/floatingpoint/decimalUsingdecimalcanavoidconversionManymachinessupportpackeddecimal4bitsbinarycodeadecimaldigit246=001001000110CharactersASCII,EBCDIC,etc.LogicalDataBitsorflagsBoolean10.3PentiumandPowerPCdatatypePentiumDataTypes8bit(Byte)16bit(word)32bit(doubleword)generaldatatypes64bit(quadword)Addressingisby8bitunitA32bitdoublewordisreadataddressesdivisibleby4(32bitdatabus)Little-endian:theleastsignifcandisstoredinthelowestaddressSpecificDataTypesGeneral-arbitrarybinarycontentsInteger-signedbinaryvalue,complementrepresentationOrdinal-unsignedintegerUnpackedBCD-OnedigitperbytePackedBCD-2BCDdigitsperbyteNearPointer-32bitoffsetwithinsegmentBitfieldByteStringFloatingPointPentiumDataTypesPowerPCDataTypes8(byte),16(halfword),32(word)and64(doubleword)lengthdatatypesSomeinstructionsneedoperandalignedon32bitboundaryCanbebig-orlittle-endianFixedpointprocessorrecognises:Unsignedbyte,unsignedhalfword,signedhalfword,unsignedword,signedword,unsigneddoubleword,bytestring(<128bytes)FloatingpointIEEE754Singleordoubleprecision10.4TypesofOperationsDataTransferArithmeticLogicalConversionI/OSystemControlTransferofControlDataTransferDatatransferinstructionsarethemostfundamentaltypeofmachineinstructionSpecifySourceDestination:registers,memory,topofstackAmountofdataModeofaddressingDatatransferinstructionsMoveStoreLoadExchange:swapcontentsofsourceanddestinationClear:all0Set:all1Push/popArithmeticAdd,Subtract,Multiply,DivideSignedIntegerFloatingpointMayincludeIncrement(a++)Decrement(a--)Negate(-a)absoluteLogicalBitwiseoperations/BooleanoperationsAND,OR,NOT,Exclusive-ORTest,compareSetcontrolVariables:setcontrolsforprotectingpurpose,interrupthandling,timercontrol,etc.ShiftRotateshiftLogicalShiftArithmeticShiftCyclicShiftConversionTranslateSomevaluesinmemoryareconvertedbytablequeryASCIIEBCDICConvertBaseconversionE.g.BinarytoDecimalInput/OutputInput/readOutput/writeStartI/OTestI/OMaybespecificinstructionsMaybedoneusingdatamovementinstructions(memorymapped)Maybedonebyaseparatecontroller(DMA)SystemsControlPrivilegedinstructionsCPUneedstobeinspecificstateUpdatecontrolregisterForoperatingsystemsuseScheduleaprocessUpdatePCBTransferofControlBranch/jumpJumpconditionalJumptosubroutineReturnexecuteSkipSkipconditionalHaltWait(hold)NooperationProcedureCallInstructionAprocedureisaself-containedcomputerprogramthatisincorporatedintoalargerprogramCodereuseTaskdecomposingProcedureCallInstructionisajumpinstructionAcallinstructionAreturninstructionNestedProcedureReturnAddressForcorrectlyexecutingmainprogram’ssequence,thereturnaddressmustbeprotectedThreemainmethods:RegisterStartofprocedureTopofstackStack&ReturnAddressStack&ParameterspassingWithaprocedurecall,inadditiontoprovidingareturnaddress,passingorreturnedparametersisalsoneededHowtopassparameters?RegistersMemorystackStackFrame:asetofparametersincludingreturnaddress10.5PentiumIIOperationTypesPp.356~357–table10.8NoneedtorememberCall/ReturnInstructionsPIIprovides4instructionstosupportprocedurecall/returnCALL:pushPCintostack,PC=startaddressoftheprocedure(jump)ENTER:createastackframeLEAVE:clearastackframeRETURN:endofprocedureMemoryManagementInstructionsDealwithmemorysegmentationsPrivilegedinstructionsusedbyOSE.g.loadasegmenttablecheckoralteraprivilegeofasegmentConditionCodesBitsinspecialregistersSetbycertainoperationsandusedinconditionaljumpinstructionsPIICCsC:carryP:parity–1meansevenA:auxiliarycarry—carryofhalfbytesinALZ:0S:signO:overflowThesecodescanbecombinedtoformaconditionMMXTechniquesMMX—MultiMedia

eXtensionAsetofhighlyoptimizedinstructionsformultimediaapplications57SIMDinstructions,64-bitdatafieldPerformthesameoperationonmultipledataelementsatonceinasingleclockcycleForproperapplications,theseparalleloperationscanyieldaspeedupof2~8timesMMXRegisters864-bitregistersMMXDataTypes64-bitdatafield,3types:SIMDExecutionModelSIMDallowsthesameoperationtobecarriedoutonmultipledataelementsinparallel.TheMMXtechnologysupportsparalleloperationsonbyte,word,anddoubleworddataelementswhencontainedinMMXregisters.Wraparound&SaturationArithmeticWraparoundArithmeticWithordinaryunsignedarithmetic,whenanoperationoverflows,theextrabitistruncatedthatis,thecarryoroverflowbitisignoredandonlytheleastsignificantbitsoftheresultarereturnedtothedestinationcontroltherangeofoperandstopreventout-of-rangeresultsSaturationArithmeticIfadditionresultsoverfloworsubtractionresultsunderflow,theresultissettothelargestorsmallestvaluerepresentable0or255DataRangeLimitsforSaturationMMXInstructionsTheMMXinstructionsetconsistsof57instructions,groupedintothefollowingcategories:DatatransferArithmeticComparisonConversionUnpackingLogicalShiftEmptyMMXstateinstruction(EMMS)ExampleFade-outandfade-ininvideoapplicationAlgorithm:Result-pixel=Apixel

fade+Bpixel

(1-fade)=(Apixel-Bpixel)fade+Bpixel

MMXCodespxormm7,mm7;zerooutmm7movqmm3,fad_val;loadfadevaluereplicated4timesmovdmm0,imageA;load4redpixelcomponentsfromimageAmovdmm1,imageB;load4redpixelcomponentsfromimageBpunpcklbwmm0,mm7;unpack4pixelsto16bitspunpckblwmm1,mm7;unpack4pixelsto16bitspsubwmm0,mm1;subtractimageBfromimageApmulhwmm0,mm3;multiplythesubtractresultbyfadevaluespadddwmm0,mm1;addresulttoimageBpackuswbmm0,mm7;pack16-bitresultsbacktobytesSpecification8-bitpixelcomponentsareconvertedto16-bitelementstoaccommodatetheMMX16-bitmultiplycapabilityIfimages’resolutionis640*480,andthedissolveusesall255possiblefadevaluesthen,totalnumberofinstructionsinMMXis535million,withoutMMX,is1.4billionNotesAssemblelanguageisneeded50cyclestimeisneededfromMMXtofloatingpointinstructionsDoyourbesttoavoidshuffleusageofMMXandFPinstructionsSSESSE—StreamSIMDExtensionsMMX28new128-bitXMMregistersSSEregistersUsedforPentiumIIIprocessorfamilyEnhancetheperformanceofIA-32processorsforadvanced2-Dand3-Dgraphics,motionvideo,imageprocessing,speechrecognition,audiosynthesis,telephony,andvideoconferencingSSEInstructionsTheSSEinstructionsaredividedintofourfunctionalgroupsPackedandscalarsingle-precisionfloating-pointinstructions.64-bitSIMDintegerin

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论