已阅读5页,还剩45页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第六组小组成员 AsFigureillustrates eachinstructioninaY86programcanreadandmodifysomepartoftheprocessorstate Thisisreferredtoastheprogrammer visiblestate wherethe programmer inthiscaseiseithersomeonewritingprogramsinassemblycodeoracompilergeneratingmachine levelcode WewillseeinourprocessorimplementationsthatwedonotneedtorepresentandorganizethisstateinexactlythemannerimpliedbytheISA aslongaswecanmakesurethatmachine levelprogramsappeartohaveaccesstotheprogrammer visiblestate Thereareeightprogramregisters eax ecx edx ebx esi edi esp and ebp Eachofthesestoresaword Register espisusedasastackpointerbythepush pop call andreturninstructions Otherwise theregistershavenofixedmeaningsorvalues 4 1 1Programmer VisibleState Therearethreesingle bitconditioncodes ZF SF andOF storinginformationabouttheeffectofthemostrecentarithmeticorlogicalinstruction Theprogramcounter PC holdstheaddressoftheinstructioncurrentlybeingexecuted 4 1 1Programmer VisibleState Thememoryisconceptuallyalargearrayofbytes holdingbothprogramanddata Y86programsreferencememorylocationsusingvirtualaddresses Acombinationofhardwareandoperatingsystemsoftwaretranslatestheseintotheactual orphysical addressesindicatingwherethevaluesareactuallystoredinmemory wecanthinkofthevirtualmemorysystemasprovidingY86programswithanimageofamonolithicbytearray 4 1 1Programmer VisibleState AfinalpartoftheprogramstateisastatuscodeStat indicatingtheoverallstateofprogramexecution Itwillindicateeithernormaloperation orthatsomesortofexceptionhasoccurred suchaswhenaninstructionattemptstoreadfromaninvalidmemoryaddress 4 1 1Programmer VisibleState 4 1 2Y86Instructions Figure4 2givesaconcisedescriptionoftheindividualinstructionsintheY86ISA Weusethisinstructionsetasatargetforourprocessorimplementations ThesetofY86instructionsincludesonly4 byteintegeroperations hasfeweraddressingmodes andincludesasmallersetofoperations Sinceweonlyuse4 bytedata wecanrefertotheseas words withoutanyambiguity Inthisfigure weshowtheassembly coderepresentationoftheinstructionsontheleftandthebyteencodingsontheright 4 1 2Y86Instructions Therearefourintegeroperationinstructions showninFigure4 2asOP1 Theseareadd1 sub1 and1 andxor1 Theyoperateonlyonregisterdata TheseinstructionssetthethreeconditioncodesZF SF andOF zero sign andoverflow 4 1 2Y86Instructions Thesevenjumpinstructions showninFigure4 2asjXX arejmp jle jl je jne jge andjg Branchesaretakenaccordingtothetypeofbranchandthesettingsoftheconditioncodes 4 1 2Y86Instructions Therearesixconditionalmoveinstructions showninFigure4 2ascmovXX cmov1e cmov1 cmove cmovne cmovge andcmovg Thesehavethesameformatastheregister registermoveinstructionrrmovl butthedestinationregisterisupdatedonlyiftheconditioncodessatisfytherequiredconstraints 4 1 2Y86Instructions Thecallinstructionpushesthereturnaddressonthestackandjumpstothedestinationaddress Theretinstructionreturnsfromsuchacall Thepush1andpop1instructionsimplementpushandpop justastheydoinIA32 Thehaltinstructionstopsinstructionexecution ForY86 executingthehaltinstructioncausestheprocessortostop withthestatuscodesettoHLT SeeSection4 1 4 4 1 3InstructionEncoding Figure4 2alsoshowsthebyte levelencodingoftheinstructions Eachinstructionrequiresbetween1and6bytes dependingonwhichfieldsarerequired Everyinstructionhasaninitialbyteidentifyingtheinstructiontype Thisbyteissplitintotwo4 bitparts thehigh order orcode andthelow order orfunction AsyoucanseeinFigure4 2 codevaluesrangefrom0to0 xB Thefunctionvaluesaresignificantonlyforthecaseswhereagroupofrelatedinstructionsshareacommoncode ThesearegiveninFigure4 3 showingthespecificencodingsoftheintegeroperation conditionalmove andbranchinstructions Observethatrrmovlhasthesameinstructioncodeastheconditionalmoves Itcanbeviewedasan unconditionalmove justasthejmpinstructionisanunconditionaljump bothhavingfunctioncode0 4 1 3InstructionEncoding Oneimportantpropertyofanyinstructionsetisthatthebyteencodingsmusthaveauniqueinterpretation Anarbitrarysequenceofbyteseitherencodesauniqueinstructionsequenceorisnotalegalbytesequence ThispropertyholdsforY86 becauseeveryinstructionhasauniquecombinationofcodeandfunctioninitsinitialbyte andgiventhisbyte wecandeterminethelengthandmeaningofanyadditionalbytes Thispropertyensuresthataprocessorcanexecuteanobject codeprogramwithoutanyambiguityaboutthemeaningofthecode Evenifthecodeisembeddedwithinotherbytesintheprogram wecanreadilydeterminetheinstructionsequenceaslongaswestartfromthefirstbyteinthesequence Ontheotherhand ifwedonotknowthestartingpositionofacodesequence wecannotreliablydeterminehowtosplitthesequenceintoindividualinstructions Thiscausesproblemsfordisassemblersandothertoolsthatattempttoextractmachine levelprogramsdirectlyfromobject codebytesequences 4 1 4Y86Exceptions Theprogrammer visiblestateforY86includesastatuscodeStatdescribingtheoverallstateoftheexecutingprogrammer Inamorecompletedesign theprocessorwouldtypicallyinvokeanexceptionhandler aproceduredesignatedtohandlethespecifictypeofexceptionencountered 4 1 5Y86Programmer intSum int Start intCount intsum 0 while Count sum Start Start Count returnsum theIA32codewasgeneratedbytheGCCcompiler TheY86codeisessentiallythesame exceptthatY86sometimesrequirestwoinstructionstoaccomplishwhatcanbedonewithasingleIA32instruction Ifwehadwrittentheprogrammerusingarrayindexing however theconversiontoY86codewouldbemoredifficult sinceY86doesnothavescaledaddressingmodes ThiscodewouldfollowmanyofconventionswehaveseenforIA32 includingtheuseofthestackandframepointers Forsimplicity itdoesnotfollowstheIA32conventionofhavingsomeregistersdesignatedascallee saveregister diffrence Y86coderequiremultipleinstructionstoperformwhatcanbedonewithasingleIA32instruction intSum int Start intCount 1Sum 2pushl ebp3movl esp ebp4movl8 ebp ecxecx Start5movl12 ebp edxedx Count6xorl edx edxsum 07testl edx edx8je L349 L35 10addl ecx eax11addl 4 ecxStart 12decl edxCount 13jnz L35Stopwhen014 L34 15movl ebp esp16popl ebp17ret intSum int Start intCount 1Sum 2pushl ebp3rrmovl esp ebp4mrmovl8 ebp ecxecx Start5mrmovl12 ebp edxedx Count6xorl12 ebp edxsum 07andl edx edxSetconditioncodes8je L349Loop 10mrmovl ecx esiget Start11addl ecx eaxaddtosum12irmovl 4 ebx13addl 4 ecxStart 14irmovl 1 ebx15addl ebx edxCount 16jneLoopStopwhen017End 18rrmovl ebp esp19popl ebp20ret 4 1 5Y86Programmer Thedirective pose0 line2 indicatesthattheassemblershouldbegingeneratingcodestartingataddress0 lines3and4 initializethestackandframepointers line47 labelStackisdeclared line46 indicateaddress0 x100usinga posdirectiveOurstackwillthereforestartatthisaddressandgrowtowardloweraddresses lines9to13 declareanarrayoffourwords havingvalues0 xd 0 xc0 oxb00and0 xa000 Thelabelarraydenotesthestartofthisarray andisalignedona4 byteboundary usingthe aligndirective lines15to24 a main procedurethatcallsthefunctionSumonthefour wordarrayandthenhalts ouronlytoolforcreatingY86codeisanassembler theprogrammermustpreformtasksweordinarilydelegatetothecompiler linker andrun timesystem wehaveimplementedaninstructionsetsimulatorwecallYIS thepurposeofwhichistomodeltheexcutionofaY86codeprogram withoutattemptingtomodelthebehaviorofanyspecificprocessorimplementation Thisformofsimulationisusefulfordebuggingprogramsbeforeactualhardwareisavailable andforcheckingtheresultofeithersimulatingthehardwareorrunningtheprogramonthehardwareitself MostY86instructionstransformtheprogramstateinastraightforwardmanner andsodefiningtheintendedeffectofeachinstructionisnotdifficult Twounusualinstructioncombinations however requirespecialattention Thepushlinstructionbothdecrementsthestackpointerby4andwritesaregistervaluetomemory Itisthereforenottotallyclearwhattheprocessorshoulddowhenexecutingtheinstructionpushl esp sincetheregisterbeingpushedisbeingchangedbythesameinstruction Twodifferentconventionsarepossible pushtheoriginalvalueof esppushthedecrementedvalueof esp 4 1 6SomeY86InstructionDetails Asimilarambiguityoccursfortheinstructionpopl esp Itcouldeitherset esptothevaluereadfrommemoryortotheincrementedstackpointer 1 text2 globlpushtest3pushtest 4pushl ebp5movl esp ebp6movl esp eaxCopystackpointer7pushl espPushstackpointer8popl edxPopitback9subl edx eaxSubtractnewfromoldstackpointer10leaveRestorestack framepointers11ret Inourexperiments wefindthatfunctionpushtestalwaysreturnszero PracticeProblem4 6 4 1 6SomeY86InstructionDetails PracticeProblem4 7 1 text2 globlpoptest3poptest 4pushl ebp5movl esp ebp6pushl 0 xabcdPushtestvalue7popl espPoptostackpointer8movl esp eaxSetpoppedvalueasreturnvalue9leaveRestorestackandframepointers10ret Inourexperiments Wefindthisfunctionalwaysreturns0 xabcd 4 1 6SomeY86InstructionDetails ForIA 32processorsfromtheIntel286on thePUSHESPinstructionpushesthevalueoftheESPregisterasitexistedbeforetheinstructionwasexecuted FortheIntelR8086processor thePUSHSPinstructionpushesthenewvalueoftheSPregister Whatthisnotestatesisthatdifferentmodelsofx86processorsdodifferentthingswheninstructedtopushthestackpointerregister Somepushtheoriginalvalue whileotherspushthedecrementedvalue Therearetwodrawbackstothisinconsistency 不一致 Itdecreasescodeportability Itcomplicates 使复杂 thedocumentation AsideGettingthedetailsright Inconsistenciesacrossx86models 4 1 6SomeY86InstructionDetails 4 2LogicDesignandtheHardwareControlLanguageHCL Inhardwaredesign electroniccircuitsareusedtocomputefunctionsonbitsandtostorebitsindifferentkindsofmemoryelements Mostcontemporarycircuittechnologyrepresentsdifferentbitvaluesashighorlowvoltages 电压 onsignalwires Incurrenttechnology logicvalue1isrepresentedbyahighvoltageofaround1 0volt whilelogicvalue0isrepresentedbyalowvoltageofaround0 0volts Threemajorcomponentsarerequiredtoimplementadigitalsystem combinationallogictocomputefunctionsonthebitsmemoryelementstostorebitsclocksignalstoregulatetheupdatingofthememoryelements Aside ModernLogicDesign Nowadays mostdesignsareexpressedinahardwaredescriptionlanguage HDL atextualnotationthatlookssimilartoaprogramminglanguagebutthatisusedtodescribehardwarestructuresratherthanprogrambehaviors ThemostcommonlyusedlanguagesareVerilog havingasyntaxsimilartoC andVHDL havingasyntaxsimilartotheAdaprogramminglanguage Theselanguageswereoriginallydesignedforexpressingsimulationmodelsofdigitalcircuits 4 2LogicDesignandtheHardwareControlLanguageHCL Logicgatesarethebasiccomputingelementsfordigitalcircuits TheygenerateanoutputequaltosomeBooleanfunctionofthebitvaluesattheirinputs Logicgatesarealwaysactive 4 2 1LogicGates Byassemblinganumberoflogicgatesintoanetwork wecanconstructcomputationalblocksknownascombinationalcircuits Theoutputsoftwoormorelogicgatescannotbeconnectedtogether Thenetworkmustbeacyclic 非循环的 4 2 2CombinationalCircuitsandHCLBooleanExpressions Tworestrictionsareplacedonhowthenetworksareconstructed Figure4 10 Combinationalcircuittotestforbitequality Theoutputwillequal1whenbothinputsare0 orbothare1 booleq a b a b WewritethefunctionofthisnetworkinHCLas 4 2 2CombinationalCircuitsandHCLBooleanExpressions Figure4 10 Single bitmultiplexorcircuit Theoutputwillequalinputaifthecontrolsignalsis1andwillequalinputbwhensis0 boolout s WewritethefunctionofthisnetworkinHCLas 4 2 2CombinationalCircuitsandHCLBooleanExpressions OurHCLexpressionsdemonstrateaclearparallelbetweencombinationallogiccircuitsandlogicalexpres sionsinC TheybothuseBooleanoperationstocomputefunctionsovertheirinputs Severaldifferencesbetweenthesetwowaysofexpressingcomputationareworthnoting Sinceacombinationalcircuitconsistsofaseriesoflogicgates ithasthepropertythattheoutputscontinuallyrespondtochangesintheinputs LogicalexpressionsinCallowargumentstobearbitraryintegers interpreting0asFALSEandany thingelseasTRUE Incontrast ourlogicgatesonlyoperateoverthebitvalues0and1 4 2 2CombinationalCircuitsandHCLBooleanExpressions a a func b c LogicalexpressionsinChavethepropertythattheymightonlybepartiallyevaluated 4 2 2CombinationalCircuitsandHCLBooleanExpressions thefunctionfuncwillnotbecalled becausetheexpression a a evaluatesto0 Incontrast combinationallogicdoesnothaveanypartialevaluationrules Thegatessimplyrespondtochanginginputs 4 2 2Word LevelCombinationalCircuitandHCLIntegerExpressions P389 394 Word LevelCombinationalCircuit Byassemblinglargenetworksoflogicgates wecanconstructcombinationalcircuitsthatcomputemuchmorecomplexfunctions Typically wedesigncircuitsthatoperateondatawords Combinationalcircuitstoperformword levelcomputationsareconstructedusinglogicgatestocomputetheindividualbitsoftheoutputword basedontheindividualbitsoftheinputword 字级测试相等电路 当字A的每一位与字B中相应的位均相等时 输出1 InHCL wewilldeclareanyword levelsignalasanint HCLallowswordstobecomparedforequality andsothefunctionalityofthecircuitshown inFigure4 11canbeexpressedatthewordlevelasboolEq A B thecircuitforaword levelmultiplexor Thiscircuitgeneratesa32 bitwordOutequaltooneofthetwoinputwords AorB dependingonthecontrolinputbits Thecircuitconsistsof32identicalsubcircuits eachhavingastructuresimilartothebit levelmultiplexorfromFigure4 11 Butit sratherthansimplyreplicatingthebit levelmultiplexor32times theword levelversionreducesthenumberofinvertersbygenerating sonceandreusingitateachbitposition MultiplexingfunctionsaredescribedinHCLusingcaseexpressions Acaseexpressionhasthefollowinggeneralform Allowthedifferentselectionexpressionstobemutuallyexclusive Logically theselectionexpressionsareevaluatedinsequence andthecaseforthe rstoneyielding1isselected intOut s A 1 B TheselectionexpressionscanbearbitraryBooleanexpressions andtherecanbeanarbitrarynumberofcases Thisallowscaseexpressionstodescribeblockswheretherearemanychoicesofinputsignalswithcomplexselectioncriteria Forexample considerthefollowingdiagramofafour waymultiplexor Asa nalexample supposewewantdesignalogiccircuitthat ndstheminimumvalueamongasetofwordsA B andC diagrammedasfollows WecanexpressthisusinganHCLcaseexpressionas Combinationallogiccircuitscanbedesignedtoperformmanydifferenttypesofoperationsonword leveldata Oneimportantcombinationalcircuit knownasanarithmetic logicunit ALU isdiagrammedatanabstractlevelinFigure4 13 Thiscircuithasthreeinputs twod
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 27版53高中同步新教材必修上册人教语文第二单元 芣苢/插秧歌
- 2026中国口腔种植体行业集采政策影响与本土品牌突围策略研究
- SolidWorks应用与实训教程 课件 魏峥 第1-5章 SoildWorks 设计基础-扫描和放样特征建模
- 2026中国智能城市建设与数字政府服务创新研究报告
- 2026圣文森特和格林纳丁斯服务业市场可发展趋势分析与投资评估
- 新版2026年吉林省长春市中考语文作文真题深度解读合集
- 2026运动护具色彩心理学应用与品牌视觉识别系统优化
- 2026能源材料行业市场竞争现状发展趋势投资机遇风险评估报告
- 结构化面试核心题目及对应回答要点
- 2026生物制药酶联免疫制剂出口现状分析及非洲市场开发投资规划
- 中医理疗公司忠诚顾客维护管理制度
- 硬包安装合同范本
- 2026年安徽省检察官逐级遴选笔试题目及答案
- 2026-2030直升机市场发展现状调查及供需格局分析预测报告
- (2026年)党务工作人员知识测试题库及答案
- Ozon平台开店流程指南
- 房地产开发项目融资分析报告模板
- 医保专网接入管理制度(3篇)
- 球房承包合同协议书
- CCER项目:三峡新能源江苏如东H6(400MW)海上风电场项目
- 2025浙江宁波朗辰新能源有限公司招聘3人笔试参考题库附带答案详解
评论
0/150
提交评论