專業(yè)課課件編譯原理匯編語言3note_第1頁
專業(yè)課課件編譯原理匯編語言3note_第2頁
專業(yè)課課件編譯原理匯編語言3note_第3頁
專業(yè)課課件編譯原理匯編語言3note_第4頁
專業(yè)課課件編譯原理匯編語言3note_第5頁
已閱讀5頁,還剩44頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

2014/PartIII:Principlesof坤2

20142014/Chap. Chaokun2014/2014/Course4

Computer&20142014/5

Cloud1

2014/2014/

PigPigLatinisadataflowlanguageratherthanproceduralordeclarative.Usercodeandexistingbinariescanbeincludedalmostanywhere.Metadatanotrequired,usedwhenSupportfornestedOperatesonfilesin6Javacard 2014/OffCardVM 8 2014/4303程序開發(fā)工具的??9 2014/cl/E/E預處理到/Pcl/FAs/FAscl/c/ccl

libraryfile,Whatis2014/2014/Compilationistheprocesswherebyonecomputerlanguageistranslatedintoanother(usuallysimplerandmorelow-leveli.e.machineorientated)languageTraditionally,programsinahigh-levelcomputerlanguage(e.g.Pascal,C,Objective-C,Lisp)arecompiledintoassemblylanguage(essentiallymachinecode)Theprogramthatdoesthetranslationisknownas2014/2014/Simplystated,acompilerisaprogramthatreadsaprogramwritteninonelanguage—thesourcelanguage—andtranslateitintoanequivalentprograminanotherlanguage—thetargetlanguage.Asanimportantpartofthistranslationprocess,thecompilerreportstoitsuserthepresenceoferrorsinthesourcepilersource compilerprogram

targetprogramerrormessage2014/2014/Preprocessorsproduceinputtocompilers.mayperformthefollowingMacroFile“Rational”Language2014/2014/SomecompilersproduceassemblycodethatpassedtoanassemblerforfurtherOthercompilersperformthejoboftheassembler,producingrelocatablemachinecodethatcanbepasseddirectlytotheloader/link-editor.TherelationshipbetweenassemblyandAssemblycodeismnemonicversionofmachinenamesareusedinsteadofbinarycodesfornamesarealsogiventomemoryLoadersandLink-2014/2014/Usually,aprogramcalledaloaderperformsthefunctionsofloadingandlink-Thelinkerresolvesexternalmemoryaddresses,wherethecodeinonefilemayrefertoalocationinanotherfile.TheloaderthenputstogetheralloftheobjectfilesintomemoryforWhyis 2014/WhyLearnit puterOS DBS(sql,WEB(wsdl,SEProgrammer(javac,ScientistWhyresearchPOPLcc, WhyStudy2014/2014/theorymeetsEssentialsoftwareInfluenceshardwareTools(mostly“optimization”)forenhancingsoftwarereliabilityandsecuritymemoryPig…Textbooksforthis 2014/AlfredV.Aho,MonicaS.Lam,RaviSethi,JeffreyD.UllmanAddison-Wesley,2006(77,AlfredV.Aho,MonicaS.Lam,RaviJeffreyD.機械工 ,ISBN 2014/4303AdvancedCompilerDesignandStevenMorganKaufmanPublishers,ISBN1-55860-320-TheDefinitiveANTLRThePragmaticProgrammers,ISBN-10: LexandYacc(2ndJohnRLevine,TonyMason,DougBrownO'Reilly&Associates,October1992ISBN:1-56592-0007… Course 2014/Checking10Programmingproject Finalexamclosed-bookandclosed-Programming2014/2014/Fortran,objective-orientedprogrammingfunctionalprogrammingLisp,logicalprogrammingotherHowarelanguages 2014/Variousstrategiesdependonhowmuchpre-processingisdonebeforeaprogramcanberun,andhowCPU-specifictheprogramis.Interpretersrunaprogram“asis”withlittleornopre-processing,butnochangesneedtobemadetorunonadifferent Compilerstaketimetodoextensivepre-processing,butwillrunaprogramgenerally2-to20-times 2014/Somenewerlanguagesuseacombinationofcompilerandinterpretertogetmanyofthebenefitsofeach.ExamplesareJavaand ’s.NET,whichcompileintoavirtualassemblylanguage(whilebeingoptimized),whichcanthenbeinterpretedonanycomputer.Otherlanguages(suchasBasicorLisp)havebothcompilersandinterpreterswrittenforthem.Recently,“Just-in-Time”compilers morecommon-compilecodeonlywhenitsBuddiesof 2014/高級語言之間的轉換工具由于計算機硬件的不斷更新?lián)Q效率提供了良好條件,然而一些已有的非常成軟件如比如:schemetoc的翻譯器COBOL到JavaCompilationand2014/2014/有些語言基本通過解釋程序:有些環(huán)境同時提供編譯程序和解釋系統(tǒng)CompilerandSourceprogram:…b:= a:=b+2 …

20142014/IntIntStbLdbaddSt(直接對源程序中的語句進行分析,執(zhí)行其隱含的操作。2014/2014/代碼程序,這個二進制代碼程序在機器上運行以生成行的程序,然后這個程序便會以機器的速度運行 2014/行并且生成結果,它特別適合程序員交互方式的著名的解釋程序有Basic,Lisp語言解釋程序,UNIX命令語言解釋程序(s),數(shù)據(jù)庫查詢語言SQL解釋程序以及bytecode解釋程序.2014/2014/ 與編譯程序的不

Historyofcompiler2014/2014/1953IBMdevelopsthe701EDPM(ElectronicDataProcessingMachine),thefirstgeneralpurposecomputer,builtasa“defensecalculator”intheKoreanWarNohigh-levellanguageswereavailable,soalldoneinassemblyHistoryofcompilers 2014/Asexpensiveastheseearlycomputerswere,mostofthemoneycompaniesspentwasforsoftwaredevelopment,duetothecomplexitiesofassembly.In1953,JohnBackuscameupwiththeideaof“speedcoding”,anddevelopedthefirstinterpreter.Unfortunay,thiswas10-20timesslowerthanprogramswritteninassembly.Hewassurehecoulddo

JohnHistoryofcompilers2014/2014/In1954,Backusandhisteamreleasedaresearchpapertitled“PreliminaryReport,SpecificationsfortheIBMMathematicalFORmulaTRANslatingSystem,TheinitialreleaseofFORTRANIwasin1956,totaling25,000linesofassemblycode.Compiledprogramsranalmostasfastashandwrittenassembly!Projectsthathadtakentwoweekstowritenowtookonly2hours.By1958morethanhalfofallsoftwarewaswritteninFORTRAN.Howtomakea2014/2014/TheA-S 2014/ ysis-SynthesisModelofbreaksupthesourceprogramintoconstituentcreatesanintermediaterepresentationofthesourceconstructsthedesiredtargetprogramfromtherequiresthemostspecialized Data→SymbolSyntax2014/2014/Operations→AhierarchicaltheoperationsimpliedbythesourceprogramtheoperationsareSyntaxaspecialkindofstorestheoperationsimpliedbythesourceeachnoderepresentsanthechildrenofanoderepresenttheargumentsofAsyntaxtreetheassignmentstatementposition:=initial+rate

+ 2014/2014/Anessentialfunctionofaistorecordtheidentifiersusedinthesourcecollectinformationaboutvariousattributesofidentifier.Theseattributesmayprovideinformationthestorageallocatedforanitsitsscope作用域whereintheprogramitisinthecaseofprocedurenames,suchthingsasthenumberandtypesofitsarguments,themethodofpassingeachargument(e.g.,byreference),andthetypereturned,ifany.2014/2014/Asymboltable(符號表isadatacontainingarecordforeachwithfieldsfortheattributesoftheThedatastructureallowstofindtherecordforeachidentifierquicklytostoreorretrievedatafromthatrecord 2014/Whenanidentifierinthesourceprogramisbythe theidentifierisenteredintothesymbolHowever,theattributesofanidentifiercannotnormallybedeterminedduringlexical Forexample,inaPascaldeclarationvarposition,initial,rate:realthetyperealisnotknownwhenposition,initial,rateareseenbythe ErrorDetectionand 2014/EachphasecanencounterHowever,afterdetectinganaphasemustsomehowdealwiththatsothatcompilationcanallowingfurthererrorsinthesourceprogramtobeAcompilerthatstopswhenitfindsthefirsterrorisnothelpfulasitcouldThesyntaxandsemantic ysisphasesusuallyhandlealargefractionoftheerrorsdetectablebytheThelexicalphasecandetecterrorswherethecharactersremainingintheinputdonotformanytokenofthelanguage. 2014/Errorswherethetokenstreamviolatesthestructurerules(syntax)ofthelanguagearedeterminedbythesyntaxysisphase.Duringsemanticysisthetriestodetectconstructsthathavetherightsyntacticstructurebutnomeaningtobeoperationinvolved,e.g.,ifwetrytoaddtwoidentifiers,oneofwhichisnameofanarray,andtheotherthenameofa 2014/Manymanyprogramminglanguages(eg,FORTRAN,C++,manyprogrammingparadigms(eg,object-manycomputerarchitectures(eg,MIPS,SPARC, ,manyoperatingsystems(eg,Linux,Solaris, 2014/Supposeyouwanttowritecompilersfrommsourcelanguagestoncomputer tforms.Ana?vesolutionrequiresn*mprograms:butwecandoitwithn+m

IR:IntermediateFE:Front-BE:Back- ThePhases 2014/tokensyntaxcodeoptimizercodeoptimizercodecodecodecodeFrontandBack 2014/Often,thephasesarecollectedintoafrontendandabackend.Thefrontendconsistsofthosephasesorpartsofphases,thatdependprimarilyonthesourcelanguageandarelar

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論