CC 2
CC 2
calculator” in the
1
History of compilers (cont’d)
2
History of compilers (cont’d)
3
History of compilers (cont’d)
4
History of compilers (cont’d)
5
History of compilers (cont’d)
6
Why study compilers?
7
Why study compilers? (cont’d)
8
Why study compilers? (cont’d)
9
Why study compilers? (cont’d)
10
Why study compilers? (cont’d)
11
Cousins Of The Compiler
12
Interpreters: Interpreters are programs that
read and execute source code directly, line by
line, without generating an intermediate
machine code or binary file. While compilers
translate the entire source code into machine
code, interpreters execute code directly.
Examples include the Python interpreter and
the JavaScript engine in web browsers.
13
Assemblers: Assemblers are tools that
convert assembly language code into machine
code. They are used for low-level programming
and are specific to a particular computer
architecture. Assemblers play a role in the
translation of assembly language instructions
into binary machine code.
14
Linkers: Linkers are programs that take object
files (generated by compilers) and combine
them into a single executable program. They
resolve references between different object
files and libraries, ensuring that functions and
variables are correctly linked together.
15
Loaders: Loaders are responsible for loading
executable programs into memory so they can
be executed by the operating system. They
handle tasks like memory allocation, relocation,
and initializing program data.
16
Preprocessors: Preprocessors are used in
conjunction with compilers to perform text
transformations on the source code before
compilation. They are commonly used to
include header files, perform macro
substitutions, and conditionally compile code.
The C preprocessor (cpp) is a well-known
example.
17
Just-In-Time (JIT) Compilers: JIT compilers
translate source code or intermediate code into
machine code at runtime, just before
execution. They are commonly used in virtual
machines and interpreted languages to
improve performance by compiling code on-
the-fly.
18
Dynamic Analysis Tools: Dynamic analysis
tools, such as profilers and debuggers, analyze
code as it runs. Profilers measure performance
characteristics, while debuggers help
developers find and fix bugs in running
programs.
19
Cross-Compilers: Cross-compilers are
compilers that generate code for a different
target platform or architecture than the one
they run on. They are often used in embedded
systems and cross-platform development.
20
Code Generators: Code generators produce
code or configuration files based on a high-
level specification. They are often used in code
generation tools and domain-specific language
(DSL) compilers.
21
PRE-PROCESSOR
22
Optimizers: Optimizers are tools or
components within compilers that perform
optimizations on the generated code to
improve its efficiency and performance.
23
PRE-PROCESSOR (cont’d)
24
PRE-PROCESSOR (cont’d)
25
PRE-PROCESSOR (cont’d)
26
2-ASSEMBLERS
Some compiler produce assembly code that is passed to an
Assembler for further processing. Other compiler perform the
Job of the assembler ,producing relocatable machine code
That can be passed directly to the loader /link –editor
27
Assembly Code
Assembly code is a mnemonic version of machine code ,in
Which names are used instead of binary code for operation
And names are also given to memory addresses. A typical
Sequence of assembly instruction might be :
28
Assembly Code (cont’d)
Move R1, a
Add R1, #2
Move b, R1
29
Assembly Code (cont’d)
b = a+2
30
Two –Pass Assembler
31
Two –Pass Assembler (cont’d)
IDENTIFIER ADDRESS
a 0
b 4
32
Two –Pass Assembler (cont’d)
33
Two –Pass Assembler (cont’d)
Second pass
In the second pass ,the assembler scans the
input Again.This time it translates each
operation code into the sequence of bits
representing a location into the address given
for the identifier in the symbol table. The output
of the 2nd pass is usually relocatable m/c code.
34
3-Loaders and Link Editor
35
Loaders and Link Editor(cont’d)
36
Modern Compilers
37
Modern Compilers(cont’d)
38
Source Language
Structure
of a
Compiler
?
Target Language
39
Source Language
Structure
of a Front End
Compiler
Back End
Target Language
40
Source Language
Lexical Analyzer
Back End
Target Language
41
Source Language
Lexical Analyzer
Target Language
42
THANKS
43