Premium Essay

Compiler Constructio

In:

Submitted By hinabashir
Words 847
Pages 4
Compiler Construction
What are Compilers
Compilers translate information from one representation to another. Thus, a tool that translates, say, Russian into English could be labeled as a compiler. In this course, however, information = program in a computer language. In this context, we will talk of compilers such as VC, VC++, GCC, JavaC FORTRAN, Pascal, VB. Application that convert, for example, a Word file to PDF or PDF to Postscript will be called “translators”. In this course we will study typical compilation: from programs written in high- level languages to low- level object code and machine code.

Issues in Compilation
The translation of code from some human readable form to machine code must be “correct”, i.e., the generated machine code must execute precisely the same computation as the source code. In general, there is no unique translation from source language to a destination language. No algorithm exists for an “ideal translation”. Translation is a complex process. The source language and generated code are very different. To manage this complex process, the translation is carried out in multiple passes.

The figure above shows the structure of a two-pass compiler. The front end maps legal source code into an intermediate representation (IR). The back end maps IR into target machine code. An immediate advantage of this scheme is that it admits multiple front ends and multiple passes.
The algorithms employed in the front end have polynomial time complexity while majority of those in the backend are NP-complete. This makes compiler writing a challenging task.
Let us look at the details of the front and back ends.

The front end recognizes legal and illegal programs presented to it. When it encounters errors, it attempts to report errors in a useful way. For legal programs, front

Similar Documents

Premium Essay

Networking

...* Software mainly directs and coordinates computer hardware. In its function, software directly provides instructions to the computer hardware and serves as input to another piece of software to facilitate computing. * Hardware in the computer refers to the physical component that makes a computer system. * Computer data storage often called storage or memory is a technology consisting of computer components and recording media used to retain digital data. * Computer don’t do anything without someone telling them what to do like the average teenager to make the computer do something useful you must give the instruction in either of the following two ways. Write a program, Buy a program. * Machine code is the only form of program instructions that the computer hardware can understand and execute directly. All other forms of computer language must be translated into machine code in order to be executed by the hardware. Machine code consists of many strings of binary digits that are easy for the computer to interpret, but tedious for human beings to interpret. Machine code is different for each type of computer. A program in machine code for an Intel x86-based PC will not run on an IBM mainframe computer, and vice versa. * Assembly language is a symbolic representation of machine code, which allows programmers to write programs in machine code without having to deal with the long binary strings. For example, the machine code for an instruction that adds two numbers...

Words: 736 - Pages: 3

Free Essay

Indiancyberpolice

.../R:36-706S:K2R21 /R:36-706S:K2R21 /R:36-706S:K2R21 /R:36-706S:K2R21 P/R:34-304S:K2R21 P/R:33-305S:K2R21 03-04 PM Lecture/G:AllC:CSE415 Lecture/G:AllC:CSE415 Lecture/G:AllC:CSE415 Lecture/G:AllC:EEP001 Practical/G:1C:CSE415 T/R:34-408S:K2R21 T/R:34T/R:34-408S:K2R21 T /R:34-708S:EE449 P/R:33-305S:K2R21 408S:K2R21 Lecture/G:AllC:EEP001 S/R:34-506S:EE408 04-05 PM Lecture/G:AllC:EEP001 S/R:34-506S:EE408 Lecture/G:AllC:EEP001 T /R:34-708S:EE449 Course Type CR-Core, DE-Department Elective, SP-Specialization,P-PD Classes OE-Open Elective, SE-Social Science, BL-Backlog My Course Course Code Type Course Title CSE440A CR CAPSTONE PROJECT-I 0 0 0 4 CSE415P CR COMPILER DESIGN 0 0 3 2 CSE415T CR COMPILER DESIGN 3 0 0 3 CSE539 CR ADVANCED COMPUTER ARCHITECTURE 4 0 0 4 CSE443 CR...

Words: 481 - Pages: 2

Free Essay

Assembly Language Program

...UET Peshawar Abbottabad Campud 13 Micro Processor Assignment # 02 Submitted by Usama Sheikh (46) Usman Ali Khan (38) Atiq-ur-Rehman(14) Wahab Akbar(20) Submitted to Engr. Munazza Razzaq Q1: Write a program the counts no of zeros in a 16bit word. Program Code:- .MODEL SMALL .STACK 64 .DATA HWRD DW 9E46 ORG 0600 ZERO DB ? .CODE MAIN PROC FAR MOV AX,@DATA MOV DX,AX SUB BL,BL MOV DL,16 MOV AX,HWRD BACK: ROL AX,1 JC NEXT INC BL NEXT: DEC DL JNZ BACK MOV ZERO,BL MOV AH,4CH INT 21H MAIN ENDP END MAIN Q2: write a program that finds the smallest no among list of following no’s, 12,100,01,8,0 Program Code:- .MODEL SMALL .STACK 64 .DATA NUMBERS DB 12,100,01,8,0 ORG 008 SMALLEST DB ? .CODE MAIN PROC FAR MOV AX,@DATA MOV DS,AX MOV CX,5 MOV BX,OFFSET NUMBERS MOV AL,[BX] BACK: CMP AL,[BX] JC NEXT MOV AL,[BX] NEXT: INC BX LOOP BACK MOV SMALLEST,AL MOV AH,4CH INT 21H MAIN ENDP END MAIN Q3: write a program to copy following hex no’s from 0200 memory location to 0400 location in reverse order. 12H,25H,35H,45H Program Code:- .MODEL SMALL .STACK 64 .DATA ORG 0200H hex_nos DB 12H,25H,35H,45H ORG 0400H COPY-data DB 4 DUP(?) .CODE MAIN PROC FAR MOV AX,@DATA MOV DS,AX MOV SI,OFFSET hex_nos INC SI INC SI INC SI MOV DI,OFFSET COPY-data MOV CX,04H AGAIN: MOV AL,[SI] MOV [DI],AL DEC SI INC DI DEC CX JNZ AGAIN MOV AH,4CH INT 21H MAIN ENDP END...

Words: 281 - Pages: 2

Premium Essay

Case Study

...they found that AMD chips did not run the programs as fast as they had to appeared. Bruce Sewell said “Some software programs ran slowly on AMD’s processors. This tends to happen not because AMD’s processors were inherently slow but Intel had changes the programs sold by software companies so that their program would not work well on computers that using AMD’s computer chip. All software companies use “compiler” to convert their programs into a form that will run on particular kinds of computer chips and compiler is provided by the companies that make the chips AMD is alleging that Intel is sabotaged the performances of its CPU by crafting a routine for its compiler to build programs. Intel had designed its compiler purposely to degrade performance when a program is run on an AMD platform. Intel designed the compiler to compile code along several alternate code paths to achieve this. FTC said “Intel has changed its compilers so that program compiled with Intel’s compiler run fine on Intel’s processors. But, it would be run slowly and poorly on AMD’s processors. Intel’s compiler secretly inserted bugs into the program that slowed it when it when run on an...

Words: 551 - Pages: 3

Free Essay

The Following Questions

...Tutorial : 1 1. Introduction Q1. Answer in short. 1. What is system programming 2. State difference between system programming and application programming. 3. State difference between compiler and interpreter. 4. State advantages and disadvantages of interpreter as compare to compiler. 5. Which are the components of smac0 simulator? 6. Write down the instruction set of smac0 Q2. Write note on – 1. Editor 2. Assembler 3. Compiler 4. Interpreter 5. Preprocessor 6. Linker and loader 7. Debugger. 8. Operating system 9. Device drivers 10. Instruction format with instruction code Q3. Select the proper option 1. ---- is a not the system software. a. Editor b. compiler c. Linker d. Accounting software 2. ----- is the system software which does some processing on source program before compilation. a. Linker b. Loader c. Assembler d. Preprocessor 3. Using ---- user can watch the values of variables during step by step execution of program a. Compiler b. Editor c. Preprocessor d. Debugger 4. ----- is a process to execute program from specific memory area allocated to it. a. Linking b. Loading c. Translation d. Relocation 5. ----- is the system software which combines different object programs to create executable program a. Linker b. Loader c. Translator d. Editor Q.4 State true or false 1. System software...

Words: 1377 - Pages: 6

Free Essay

Masm

...CMLab Graphics A Tutorial of Writing MASM with VC++ 2005 Express Presented by Ken-Yi Lee Assembly Language 2007 CMLab Graphics Assembly Language 2007 MASM Microsoft Macro Assembler - MASM 8.0 included with Visual C++ 2005 - You can download MASM 8.0 and install it with Visual C++ 2005 Express by yourself 2 CMLab Graphics Assembly Language 2007 What do you need ? helloworld.asm helloworld.obj Editor Assembler (ml.exe) Linker (link.exe) helloworld.exe Debugger 3 Include Files Where Which Object File Libraries Where Which CMLab Graphics Assembly Language 2007 Visual C++ 2005 Express with MASM 8.0 Visual C++ 2005 Express - Editor, Linker, and Debugger • Custom build rules needed] • Set library paths and library dependencies [if • Select “console” as your subsystem MASM 8.0 - Assembler • Set include paths [if needed] 4 CMLab Graphics Assembly Language 2007 Visual C++ 2005 Express with MASM 8.0 (contd.) Download and Install Visual C++ 2005 Express - http://0rz.tw/253mH Download and Install MASM 8.0 - http://0rz.tw/8d1Xn • You should install VC 2005 Express first 5 CMLab Graphics Hello MASM ! A simple example to set up the environment CMLab Graphics Assembly Language 2007 HelloMASM - My Settings: • Project Name: HelloMASM • Solution Name: HelloMASM • Source code filename: hellomasm.asm • Additional library dependencies: Irvine32.lib user32.lib • Used...

Words: 496 - Pages: 2

Free Essay

Famous Thinkers

...Famous Thinkers: Steven Spielberg & Grace Hopper Famous thinkers can come from all walks of life and can be from our generation and others. Reaching goals can be done in many ways. The similarity famous thinkers is that they are all share creative minds and are all creative thinkers. Creative ideas are the foundation of creative process (Goodman & Fritchie, 2011). Famous thinkers base their ideas on searching for solutions to problem, need, or the way others think or view specific issues. When I think of famous thinkers a vast number of people come to mind. Two thinkers that genuinely stand out to me are Steven Spielberg & Grace Hopper. My article will provide more details on the influence and accomplishments of these great thinkers. Steven Spielberg Steven Spielberg had an early start on his career, even as a child he was an amateur filmmaker. Spielberg became an Academy Award-winning director and one of the youngest television directors. His opportunities became endless after the television film, Duel in 1972, which landed him a chance to direct for the cinema. Steven Spielberg has brought unique contributions to society. Ten ways he has done this is 1. Helping to create the idea of the movie “blockbuster.” 2. Bringing back our sense of wonder 3. Helping to make robot uprising the new zombie apocalypse 4. Bringing back the Saturday morning serial 5. Co-founding a successful new studio, and helping bring back animated films 6. Preserving and shaping...

Words: 1117 - Pages: 5

Free Essay

Linux Vsc

...Contents Introduction 2 The Python Programming Language 2 History of Python 2 Features 4 Advantages and Disadvantages 5 Python vs. C 5 Summary 11 Bibliography 12 Introduction After comparing several programming languages, I have found many books and websites expressing how fast and efficient Python is. Further, many research papers describe the advantages of adding Python to computer sciences classes. For this reason I decided to study this language and compare it to one that I am familiar with, like the C language. This paper contains the history of Python, from its creation until now. It shows the features that make Python so popular, and the differences between Python and other languages. Most importantly, it explains the four pillars that are the foundation of the Python programming language, which are to provide quality, increase productivity, portability, and integration. Through this paper illustrate the advantages and disadvantages of Python, by showing that, although an interpretative language such as Python will never be as fast as a compiled language like C, it will be more efficient and useful in a variety of cases. The Python Programming Language History of Python Python (Software, 2011) is a relatively recent, object-oriented, interpreted scripting language created by Guido van Rossum at Stichting Mathematisch Centrum (CVI) in the Netherlands. According to Mark Pilgrim, Python is a successor of the ABC...

Words: 1762 - Pages: 8

Premium Essay

Java Programming Execution Phases

...Handout 3 Advanced Programing in Java Umair Javed CS-391 Java Program Development and Execution Steps Java program normally go through five phases. These are 1. 2. 3. 4. 5. Edit, Compile, Load, Verify and Execute We look over all the above mentioned phases in a bit detail. First consider the following figure that summarizes the all phases of a java program. Phase 1 Editor Disk Program is created in the editor and stored on disk. Compiler creates bytecodes and stores them on disk. Phase 2 Compiler Disk Primary Memory Phase 3 Class Loader Class loader puts bytecodes in memory. Disk Primary Memory Phase 4 Bytecode Verifier Bytecode verifier confirms that all bytecodes are valid and do not violate Java’s security restrictions. Phase 5 Primary Memory Interpreter Interpreter reads bytecodes and translates them into a language that the computer can understand, possibly storing data values as the program executes. Umair© 2005, All Rights Reserved -1- TA: Munawar Nadeem Handout 3 Advanced Programing in Java Umair Javed CS-391 Phase 1: Edit Phase 1 consists of editing a file. This is accomplished with an editor program. The programmer types a java program using the editor like notepad, and make corrections if necessary. When the programmer specifies that the file in the editor should be saved, the program is stored on a secondary storage device such as a disk. Java program file name ends with a .java extension...

Words: 696 - Pages: 3

Premium Essay

Pic Note

...PIC 10A Lecture 1: Hello World! The Very Basics What is a computer? • Seriously? What is a computer program? • Series of commands that the computer interprets and executes. • For a program to accomplish a task the commands must be put together in a meaningful way. What are the ingredients of a program that does something? • The program must be written in a programming language that the computer can understand. There are several languages: Pascal, Fortran, Basic, C, C++, Java etc. • The program must follow the rules of the language. The programmer must know the words and the grammar. • The instructions must be written in the correct sequence. • The totallity of instructions must accomplish the intended task. • Often the program must be translated into a machine readable language. • The program must be run on a correct platform. What is studying C++ like? • It is much like learning a foreign language. • You learn new words and grammar. The commands are much like words, and grammar is the interaction of the commands. • This class is not about memorizing every single phrase. • Think of the things you learn as tools. As you learn more of the language, you will be able to build more complex programs. • Programming is a creative activity! How is a C++ program written? • It is written using the normal English alphabet and a few extra symbols such as parenthesis ( ) and semicolons ; . • You can write a C++ program on any text editor! • It...

Words: 478 - Pages: 2

Free Essay

Competency Matrix

...tradeoffs of the basic data structures, Arrays vs LinkedLists, Able to explain how hashtables can be implemented and can handle collisions, Priority queues and ways to implement them etc. Knowledge of advanced data structures like B-trees, binomial and fibonacci heaps, AVL/Red Black trees, Splay Trees, Skip Lists, tries etc. algorithms Unable to find the average of numbers in an array (It’s hard to believe but I’ve interviewed such candidates) Basic sorting, searching and data structure traversal and retrieval algorithms Tree, Graph, simple greedy and divide and conquer algorithms, is able to understand the relevance of the levels of this matrix. systems programming Doesn’t know what a compiler, linker or interpreter is Basic understanding of compilers, linker and interpreters. Understands Understands kernel mode vs. user mode, multi-threading, synchronization primitives and how they’re implemented, able to read what assembly code is and how things work at the hardware level. Some assembly code. Understands how networks work, understanding of network protocols and socket level programming. knowledge of virtual memory and paging. Able to recognize and code dynamic programming solutions, good knowledge of graph algorithms, good knowledge of numerical computation algorithms, able to identify NP problems etc. Understands the entire programming stack, hardware (CPU + Memory + Cache + Interrupts + microcode), binary code, assembly, static and dynamic ...

Words: 1812 - Pages: 8

Premium Essay

Week 1 Homework

...number does a bit that is turned on represent? What number does a bit that is turned off represent? A. The number a bit that is turned on represents the number 1. The number a bit that is turned off represents the number 0. 3. What would you call a device that works with binary data? A. The device that works with binary data is called Digital device. 4. What are the words that make up a high-level programming language called? A. The word that make up a high-level programming language are called Keywords or reserved words. 5. What are the short words that are used in assembly language called? A. The short words that are used in assembly language is called Mnemonics. 6. What is the difference between a compiler and an interpreter? A. A complier is a program that translates a high-level language program into a separate machine language. An interpreter is a program that both translate and executes the instructions in a high-level language program. 7. What type of software controls the internal operations of the computer’s hardware? A. The Operating systems is the software that controls the internal operations of the computer’s...

Words: 253 - Pages: 2

Free Essay

Cs 50

...Week 1.1 (Monday) ENGLISH ORIGINAL TEXT УКРАЇНСЬКИЙ ПЕРЕКЛАД DAVID J. MALAN: So this is CS50. And this was CS50's own Colton Ogden, for more of who's music you can download at soundcloud.com/cs50. So today we focus all the more on the art of programming. And we take where we left off last week, focusing on Scratch, which was this graphical programming language. And take things down to a lower level, using a more traditional programming language known as C. But along the way, realizing that the same ideas we talked about last Friday will recur not only in this language C, but in most every other that we look at this semester. So we called this thing here what last time? This is representative of a statement. So we called this a statement. And it does something. It's an instruction that a computer or Scratch might execute. And henceforth, let's also start calling something like this a function, for reasons we shall soon see. Meanwhile, we saw things like this. And these are generally known as what construct? AUDIENCE: Loop. DAVID J. MALAN: So a loop. So pretty straightforward. It literally does what it says. And in Scratch, if you want to cram more puzzle pieces in there, the piece will grow to fit it. And we'll see in C that we can do the same thing. Another type of loop, though, in Scratch might be forever, or there's any number of other approaches. But let's take a more generalist look, with a face that's likely quite familiar, at loops more generally. MARK ZUCKERBERG:...

Words: 17436 - Pages: 70

Premium Essay

C Paper

...Steve Ingwer ET2560 Phil Keck Friday Evenings WHY C IS STILL USED The main thing that my research has uncovered is the performance and reliability Of C programming. Many have also spoken of the ease of use that C provides, Which as of yet I have not found to be true but I am still learning and these people were all experienced users. They have also brought to point the great insight into programming that C offers and the ability it affords you to learn another language. ( A computer language) C also gives the user a feeling of empowerment and control being that close to the “Bare Metal” of the programming process. Many programs written today are C derivitives such as Java ( considered a cousin to C). C is still widely used and can be used in standalone executables. It also compiles for every platform and every processor architecture. A major reason why C is still in use is the fact that they keep extending and rewriting C so it stays fresh and up to date. There is also a lot of existing software that is C and C++ and converting it to another programming method would be costly and take a great effort. C also starts from scratch and has foundational concepts that today’s concepts stand on. Major parts of Windows, Unix and Linux are still written in C. In order to understand some of today’s other computer languages, Such as the afore mentioned cousin to C, Java, one must first learn C in order to learn the other languages more easily. Many of today’s Device...

Words: 544 - Pages: 3

Free Essay

Term Paper

...TERM PAPER COMPILER DESIGN Translator For Simple Expression Submitted to:Harshpreet Sir Submitted by:Kapish Mahajan Registration no. 11207646 Section : K2202 Roll no. A-19 Syntax Directed Translation 1. Syntax Directed Definitions There are two notations for associating semantic actions with productions: syntax-directed definitions and translation schemes. The Syntax-Directed Definitions are a mechanism for specifying translations for the programming language constructs. A syntax-directed definition specifies the translation of a construct in terms of the attributes associated with its syntactic components. A syntax-directed definition uses a context-free grammar to specify the structure of the input: with each grammar symbol it associates a set of attributes; and with each production a set of semantic rules for computing the values of the attributes associated with the symbols in it. A Translation Scheme is like a syntax-directed translation except that the order of evaluation of the semantic rules is explicitly shown. A translation scheme is a context-free grammar in which program fragments called semantic actions are embedded within the right sides of the productions. Translation schemes show the order in which the semantic rules has to be evaluated, so they show implementation details. With both syntax-directed definitions and translation schemes the input token stream is parsed...

Words: 696 - Pages: 3