n.c.c final presentation
DESCRIPTION
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 - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/1.jpg)
N.C.C Final Presentation(Ncc is not a C Compiler)
4 조 ( 말년병장 )200324293 심민조200324210 김호철
![Page 2: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/2.jpg)
2
Index1. 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
![Page 3: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/3.jpg)
Development EnvironmentDevelopment 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, Win-dows7
Test Environment O.S : Windows XP(SP3), Windows7
3
![Page 4: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/4.jpg)
4
Language SupportLanguage Supports Function Call, Argument Passing Return Value, Printf, IF condition For loop, While loop, break, Increment OP, Decrement OP, +,-,/,*,mod Recursive Function Call Nested For, While, IF, Integer Variable Void type, Single/Multiple Comment
Difference ! Small ,Easy ,Real Binary Ncc supports WIN32 PE binary, asm architec-ture
![Page 5: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/5.jpg)
LEX & YACC DefineMake 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 Intermmediate Code
Error Handling - Sementic Error ( Type Check, Function, Variable ) - Syntax( {, }, ; )
5
![Page 6: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/6.jpg)
Symbol Table ManagementOne Function has One Symbol table- Function Call , Parameter
Global Variables are not consideredOnly supports Local Variable, Parameter Variable
Data Structure-Vector : Function Table -Vector : Symbol Table
6
![Page 7: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/7.jpg)
Symbol Table Management
7
LiteralTable
Number
Table
FunctionManage Table----------------
FuncTab* List
Source Lexer Parser
Codegenerat
e
MASMassmble
rLinker
FunctionTable
----------------funcname
Symbol ListIntercode
ListnParam
Win32 Binary
![Page 8: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/8.jpg)
8
Intermediate CodeUsing 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
![Page 9: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/9.jpg)
Intermediate Code
9
![Page 10: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/10.jpg)
Target Code(Masm Code)Printf Library ( not a stdlib )Available to use Crtlib ( vc )
int main(){int I,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”);}
10
![Page 11: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/11.jpg)
Target Code(Total Process) int main(){ int I,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
![Page 12: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/12.jpg)
Target Code(Binary Code)
12
MASMAssembler
Linker Win32Binary
![Page 13: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/13.jpg)
Optimization
13
1. Constant Number Assign a = 3*2+1*2 a=8
2. If condition Code Optimize if( a < b) { a++; }
cmp a,b jl if_inner_stmt jge if_exit inner_stmt : inc aif_exit:
cmp a,b jge if_exit inc aif_exit:
![Page 14: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/14.jpg)
14
Work Plan
![Page 15: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/15.jpg)
DEMO
1. For Loop2. Function Call & For Loop3. While & Comment4. Recursive - 1 ( Recursive Summation)5. Recursive - 2 ( Recursive Fibonacci Sequence)6. MultiFunction ( Prime Finder, Piramid)7. Error Detection8. Intermediate Code
15
![Page 16: N.C.C Final Presentation](https://reader036.vdocuments.pub/reader036/viewer/2022062305/568160fd550346895dd03acf/html5/thumbnails/16.jpg)
Q & A