Skip to main content

Introduction To Compiler Design, What is Compiler, Preprocessor, Assembler, Interpreter, Advantages of Compiler, Loader and Link-Editor

Introduction To The Compiler Design


What is Compiler?

-A compiler is a special program that translates the source code of a programming language into 
machine code, bytecode, or another programming language. The source code is usually written in 
a high-level human-readable language, such as Java or C++.
The computer is an intelligent combination of software and hardware. Hardware is simply a piece 
of mechanical equipment and its functions are being compiled by the relevant software. The 
hardware considers instructions as electronic charge, which is equivalent to the binary language in 
software programming. The binary language has only 0s and 1s. To enlighten, the hardware code 
has to be written in binary format, which is just a series of 0s and 1s. Writing such code would be an 
inconvenient and complicated task for computer programmers, so we write programs in a high-level language, which is convenient for us to comprehend and memorize. These programs are then 
fed into a series of devices and operating system (OS) components to obtain the desired code that 
can be used by the machine. This is known as a language processing system.


Introduction To The Compiler Design
(Image Source - Google Images)


Preprocessor

-The preprocessor includes all header files and also evaluates whether a macro(A macro is a piece 
of code that is given a name. Whenever the name is used, it is replaced by the contents of the 
macro by an interpreter or compiler. The purpose of macros is either to automate the frequency 
used for sequences or to enable more powerful abstraction) is included. It takes source code as 
input and produces modified source code as output. The preprocessor is also known as a macro 
evaluator, processing is optional that is if any language that does not support #include and macros 
processing is not required.


Compiler

- Compiler is a translator program that translates a program written in (HLL) the
source program and translates it to an equivalent program in (MLL) the target program. An 
important part of a compiler is the error that is displayed to the programmer.
The execution of a program written in the HLL programming language basically consists of two 
parts. the source program must first be compiled into an object program. The result object 
program is then loaded into an executed memory.


Assembler

- Programmers found it difficult to write or read programs in machine language.
They begin to use a mnemonic (symbols) for each machine instruction, which they would later use 
translate into machine language.
Such a mnemonic machine language is now called assembly language.
Programs known as assemblers were written to automate the translation of assembly language into machine language.
The input to an assembly program is called a source program, and the output is a machine language 
translation (object program).


Interpreter

-An interpreter is a program that appears to execute a source program as if it 
were machine language


Languages such as BASIC, SNOBOL, and LISP can be translated using interpreters. JAVA also uses 
an interpreter. The process of interpretation can be carried out in the following phases.
  1. Lexical analysis
  2. Syntax analysis
  3. Semantic analysis
  4. Direct Execution


Advantages

- Modification of the user program can be easily performed and implemented as execution proceeds.
The object type denoting multiple can change dynamically.
Debugging a program and finding errors is a simplified task for a program used for interpretation.
The language interpreter makes it machine independent.

Disadvantages

-The Program execution is slower.
Memory consumption is more.



Loader and Link-Editor

- Once the assembler processes an object program, that program must be placed in memory and 
executed. The assembler could put the object program directly into memory and transfer control to it.
Thus causing the program to be executed in machine language. This would waste the kernel by leaving 
the assembler in memory while the user program was running. Also, the programmer would have to re-translate his program with each execution, thus wasting translation time. To overcome these problems 
of wasted translation time and memory. System programmers developed another component called a 
loader "A loader is a program that places programs in memory and prepares them for execution."
It would be more efficient if the subroutines could be translated into object form, and the loader 
could be "relocated" directly behind the user program. The task of adjusting programs so that 
they are not placed in arbitrary central locations is called relocation. Relocation chargers 
perform four functions.


Comments

Popular posts from this blog

Function Keys Shortcuts

Function Keys Shortcuts (F1 - F12) (Function Keys) F1 It is used to open the help window in almost all programs. Also used to enter BIOS or CMOS Some computers allow you to enter BIOS setup using different keys like F2, F10, Delete, Esc. Pressing Window + F1 will open the Microsoft Windows Help and Support Center. F2 In Microsoft Windows, it is used to rename an icon , file , or folder that the user selects. In Microsoft Excel, the F2 key allows you to edit the selected cell in the Excel sheet. In Microsoft Word, pressing Ctrl+F2 will open the print preview window and Alt+Ctrl+F2 will open the new file or document. In addition, it is also used to enter the CMOS setup. F3 It is mainly used to open a search function for many programs. At the MS-DOS or Windows command line, it gives users the option to repeat the last command entered. In Microsoft Word, if you press Shift + F3 , it allows you to change the selected text from uppercase to lowercase or a capital letter at the beginni...

Computer Fundamentals in Hindi

Computer Fundamentals in Hindi - कंप्यूटर फंडामेंटल्स हिंदी में - कंप्यूटर का परिचय कंप्यूटर शब्द अंग्रेजी के "Compute" शब्द से बना है, जिसका अर्थ है "गणना", करना होता है इसीलिए इसे गणक या संगणक भी कहा जाता है, इसका अबिस्कर Calculation करने के लिए हुआ था, पुराने समय में Computer का use केवल Calculation करने के लिए किया जाता था किन्तु आजकल इसका use डाक्‍यूमेन्‍ट बनाने, E-Mail, Listening And Viewing Audio And Video, Play Games, Database Preparation के साथ-साथ और कई कामों में किया जा रहा है, जैसे बैकों में, शैक्षणिक संस्‍थानों में, कार्यालयों में, घरों में, दुकानों में, Computer का उपयोग बहुतायत रूप से किया जा रहा है। Computer केवल वह करता है जो हम उसे करने का कहते हैं यानि केवल वह उन Command को फॉलो करता है जो पहले से Computer के अंदर डाले गए होते है, उसके अंदर सोचने समझने की क्षमता नहीं होती है, Computer को जो व्यक्ति चलता है उसे यूजर कहते है, और जो व्यक्ति Computer के लिए Program बनता है उसे Programmer  कहा जाता है। कंप्यूटर को ठीक प्रकार से कार्य करने के लिए सॉफ्टव...

Networking Interview Questions and Answers

Networking Interview Questions and Answers 1) What is a Network? Answer: The network is defined as a set of devices connected to each other through a physical transmission medium. For example, a computer network is a group of computers connected to each other to communicate and share information and resources such as hardware, data, and software. In a network, nodes are used to connect two or more networks. 2) What is a Node? Answer: Two or more computers are directly connected by fiber optics or any other cable. A node is a point where a connection is established. It is a network component used to send, receive, and forward electronic information. A device connected to a network is also called a Node. Let us consider that in a network there are 2 computers, 2 printers, and a server connected, then we can say that there are five nodes in the network. 3) What is Network Topology? Answer:  Network topology is a physical layout of the computer network and defines how computers,...