B138编译程序概论课件.ppt
- 【下载声明】
1. 本站全部试题类文档,若标题没写含答案,则无答案;标题注明含答案的文档,主观题也可能无答案。请谨慎下单,一旦售出,不予退换。
2. 本站全部PPT文档均不含视频和音频,PPT中出现的音频或视频标识(或文字)仅表示流程,实际无音频或视频文件。请谨慎下单,一旦售出,不予退换。
3. 本页资料《B138编译程序概论课件.ppt》由用户(晟晟文业)主动上传,其收益全归该用户。163文库仅提供信息存储空间,仅对该用户上传内容的表现方式做保护处理,对上传内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(点击联系客服),我们立即给予删除!
4. 请根据预览情况,自愿下载本文。本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
5. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007及以上版本和PDF阅读器,压缩文件请下载最新的WinRAR软件解压。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- B138 编译程序 概论 课件
- 资源描述:
-
1、 1 1.1 1.2 1.3 1.4 (syntax)(semantics)(),COBOLCOmmon Business Oriented Language1960,(CODASYL)1968 1974 ANSI COBOL FORTRANFORmula TRANslation1960,J.Backus 1977 FORTRAN77 ALGOLALGOrithmic LanguageALGOL68-1968 IFIP WG2.1 Pascal1970,N.Wirth -,C1974 D.Ritchie UNIX 1988 ANSI C C+Ada1980 :reliability,simpl
2、icity,modularity,efficiency:package,generic features,multi-taskingreal-time application C+1983 B.Stroustrup OOPL:class,inheritance,polymorphismJava1996 Sun MicroSystems James Gosling OOPL,Exception processing()&Multithread Internet&Distributed Environment 5th :Independent Platform of OS&H/WC#2000 Mi
3、crosoft John Gough.NET Platform OOPL(Object-Oriented Prog.Lang.).NET Framework,JIT(Just In-Time Compilation)high Expressiveness&Simplicity C+VB,JAVA VB user interface,C+,JAVA component S/W Compiler A compiler is a computer program which translates programs written in a particular high-level programm
4、ing language into executable code for a specific target computerSource programSource programObjectprogramObjectprogramError messageLinkageEditorExecutableprogramExecutableprogramCompilerLibrarySource programwith macroSource programRelocatable machine codeAbsolute machine codeLibraryPreprocessorCompi
5、lerassemblerLinkage EditorObject program(as assembly code)(Cross-Compiler)(PreProcessor)(Assembler)(Interpreter)(Compiler)Cross-Compiler C program in WorkstationObject Code for PC CompileCrossCompile-:assembler ,Compiler :Operational System Interpreter:Developing or Educational System InterpreterInt
6、erpreterSource Program Macro substitution#define PI 3.141592Conditional compilation-#IF SUB100.Inclusion of files-#include PreprocessorPreprocessorPreprocessorTranslatorSource ProgramTarget Programs SourceProgramFront-EndFront-EndobjectProgramBack-EndBack-EndFront-End language dependent partBack-End
7、 machine dependent partI.C.:Intermediate CodeO.C.:Optimized Code Lexical AnalyzerSyntax AnalyzerSemantic AnalyzerImmediate Code GenerationCode OptimizationCode GenerationSymbolTableErrorHandlerSource ProgramObject ProgramFrontEndBackEnd1.Lexical Analyzer(Scanner).ex)if(a 10).Token :if (a 10 ).Token
8、Number:32 7 4 25 5 8 2.Syntax Analyzer(Parser):Syntax checking,syntax Tree generation.:incorrect-error message correct -program structure(tree)ex)if(a 10)a=1;if =a 10 a 13.Intermediate Code Generator ex)if(a 10)a=1.0;/a semantic error!ex)a=b+1;Tree:=a +b 1 Ucode:lod R1 b ldc R1 add store R1 a 4.Code
9、 OptimizerOptional phase()code code .Meaning of optimizationmajor part:improve running timeminor part:reduce code size ex)LDC R1,1 LDC R1,1 (x)Criteria for optimizationpreserve the program meaningsspeed up on averagebe worth the effortLocal optimizationlocal inspection inefficient code efficient cod
10、e .1.Constant folding 2.Eliminating redundant load,store instructions 3.Algebraic simplification 4.Strength reductionGlobal optimizationflow analysis technique 1.Common subexpression 2.Moving loop invariants 3.Removing unreachable codes5.Target Code Generator machine instruction.Code generator tasks
11、1.instruction selection&generation2.register management3.storage allocation4.code optimization(Machine-dependent optimization)6.Error Recovery Error recovery -error Error repair -error Error HandlingError detectionError recoveryError reportingError repairErrorSyntax ErrorSemantic ErrorRun-time Error
展开阅读全文