1 / 16

N.C.C Final Presentation

N.C.C Final Presentation. ( Ncc is not a C Compiler). 4 조 ( 말년병장 ) 200324293 심민조 200324210 김호철. Index. 1. Development Environment 2. Language Support 3. LEX & YACC Define 4. Symbol Table Management

carson
Download Presentation

N.C.C Final Presentation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. N.C.C Final Presentation (Ncc is not a C Compiler) 4조 (말년병장) 200324293 심민조 200324210 김호철

  2. Index • 1. Development Environment • 2. Language Support • 3. LEX & YACC Define • 4. Symbol Table Management • 5. Intermediate Code • 6. Target Code • 7. Optimization • 8. Work Plan • 9. Demo • 10. Q&A

  3. Development Environment • Development Environment • Language : C, C++ • Compiler : gcc, g++ • Lexer : FLEX v2.5.4 • Yacc : BISON v1.25 • Assembler : MASM v6.15 • Linker : Microsoft Incremental Linker 6.00.8447 • O.S : Linux(ubuntu), Windows XP, Windows7 • Test Environment • O.S : Windows XP(SP3), Windows7

  4. Language Support • Language Supports • Function Call, Argument Passing • Return Value, Printf, IF condition • For loop, While loop, break, • Increment OP, Decrement OP, +,-,/,*,mod • Recursive Function Call • NestedFor, While, IF, Integer Variable • Void type, Single/Multiple Comment • Difference ! Small ,Easy ,Real Binary • Ncc supports WIN32 PE binary, asm architecture

  5. LEX & YACC Define • Make our Own Small C Language ! • - Mini C < NCC < ANSI C • Difference ! Small & Easy • Special Feature • - Printf can be used in grammer ! ( Not a function ) • - Genereate 3 Address IntermmediateCode • Error Handling • - Sementic Error ( Type Check, Function, Variable ) • - Syntax( {, }, ; )

  6. Symbol Table Management • One Function has One Symbol table • Function Call , Parameter • Global Variables are not considered • Only supports Local Variable, Parameter Variable • Data Structure • Vector : Function Table • Vector : Symbol Table

  7. Symbol Table Management Function Manage Table ---------------- FuncTab* List Literal Table Number Table Win32 Binary Function Table ---------------- funcname Symbol List Intercode List nParam Source Lexer Parser Code generate MASM assmbler Linker

  8. Intermediate Code • Using Triple Address • Condition Jump use Compare op like assembly • Optimization ? • Constant Number Allocate Optimize • IF Statement Optimize • What is difference with assembly code? • Stack Frame Management • Register Management • Abstraction Level

  9. Intermediate Code

  10. Target Code(Masm Code) • Printf Library ( not a stdlib ) • Available to use Crtlib ( vc ) int main(){ intI,j,k; for(i=2; i<10; i++) { for(j=1; j<10;j++) { k=i*j; printf(“%d*%d=%d\t”,I,j,k); } printf(“\n”); }

  11. Target Code(Total Process) int main(){ intI,j,k; for(i=2; i<10; i++) { for(j=1; j<10;j++) { k=i*j; printf(“%d*%d=%d\t”,I,j,k); } printf(“\n”); } }

  12. Target Code(Binary Code) MASM Assembler Linker Win32 Binary

  13. Optimization • 1. Constant Number Assign • a = 3*2+1*2  a=8 • 2. If condition Code Optimize • if( a < b) { • a++; • } •  • cmpa,b • jlif_inner_stmt • jgeif_exit • inner_stmt : • inc a • if_exit: • cmpa,b • jgeif_exit • inc a • if_exit:

  14. Work Plan

  15. DEMO • 1. For Loop • 2. Function Call & For Loop • 3. While & Comment • 4. Recursive - 1 ( Recursive Summation) • 5. Recursive - 2 ( Recursive Fibonacci Sequence) • 6. MultiFunction ( Prime Finder, Piramid) • 7. Error Detection • 8. Intermediate Code

  16. Q & A

More Related