70 likes | 233 Views
Welcome to CS 445 Compiler and Translator Design. Clinton Jeffery jeffery@uidaho.edu JEB 230. What’s a Compiler. Translates human equations to machine code Originally done by a human
E N D
Welcome to CS 445Compiler and Translator Design Clinton Jeffery jeffery@uidaho.edu JEB 230
What’s a Compiler • Translates human equations to machine code • Originally done by a human • Compared with colloquial English: to pull together the sequence of machine instructions needed to perform a given computing task
Why Study Compilers? • Experience with large-scale applications development. • A shining triumph of CS theory • A basic element of language R&D • Ideas and tools useful in many applications
Tools We Use • C and “make” • Lex and Yacc • Gdb • E-mail • Web • CVE
Kinds of Compilers • Native code • Virtual machine • JIT • Preprocessor, macro processor • Interpreter
Phases of a Compiler • Lexical analysis • Syntax Analysis • Semantic Analysis • Intermediate Code Generation • Optimization • Final Code Generation • Linking
Example • Compile: position = initial + rate * 60 • Intermediate: t1 = inttoreal(60) t2 = id3 * t1 t3 = id2 + t2 id1 = t3 • Final: MOVF id3, R2 MULF #60.0, R2 MOVF id2, R1 ADDF R2, R1 MOVF R1, id1