The Principle of Compilation and Assembler
The Principle of Compilation and Assembler
MAHI AYA
HOW COMPUTER WORKS
HOW COMPUTER WORKS
SUMMARY
HOW COMPUTER WORKS
5
3 7
1 ARITHMETIC LOGIC
UNIT (ALU) STORAGE AND
INPUT MEMORY DATA MANAGEMENT
2 6
4 8
PROCESSING OUTPUT
CONTROL UNIT CONTROL AND
COMMUNICATION
INPUT
The process begins when you provide input to the computer, which
can come from various sources such as:
The ALU is a part of the CPU that performs arithmetic and logical operations
OUTPUT
Once the CPU processes the data, the results are sent to an output device.
printer
monitor speakers
STORAGE AND DATA
MANAGEMENT
Data that needs to be retained is stored on long-term storage devices.Data
can be organized into files and directories for easy retrieval
CONTROL AND COMMUNICATION
2 6
4 8
PROCESSING OUTPUT
CONTROL UNIT CONTROL AND
COMMUNICATION
WHAT IS THE COMPILER
Assembly
Language
High-Level
Programming Machine Language
Languages
COMPUTER
LANGUAGES
High-Level
Programming
Languages
High-level programming
languages are designed for human
readability and ease of use.
EXAMPLE
High-Level
Programming Machine Language
Languages
COMPUTER
LANGUAGES
COMPILER
The purpose of a compiler is to convert human-readable source code into a format that a
computer can understand and execute.
source code
lexical analysis
syntax analysis
semantic analysis
ERROR
SYMBOL TABLE
PROCESSING
MANAGEMENT
intermediate code
generation
code optimisation
target code
back end
lexical analysis
lexical analysis
token
a,b,c =,+,-
Identifiers operators
int,printf (),{},;
keywords special symbols
lexical analysis
specifications of token
Alphabets
lexical analysis
specifications of token
String
lexical analysis
specifications of token
Special symbols
lexical analysis
LEXEMES TOKENS
lexical analysis
printf Printf
EXAMPLE
a = b + c * 10
a = b + c * 10
a = b + c * 10
a = b + c * 10
<id,symbol a>
a,b,c int,printf
<op,’=’>
Identifiers keywords
<id,symbol b>
<op,’+’>
<id,symbol c> =,+,- (),{},;
<op,’*’> operators special symbols
<const,value 10>
syntax analysis
syntax analysis
x=a+b*c
x=a+b*c
semantic analysis
semantic analysis
Semantic Errors:
Type mismatch
Undeclared variables
A statement involving no more than three references(two for operands and one
for result) is known as a three address statement.
THREE-ADDRESS CODE
x=a+b*c
code optimisation
code optimisation
Its purpose is to modify the code to run faster and consume fewer resources ,It
deletes any unnecessary lines.
EXAMPLE
code optimisation
code generation
code generation
x=a+b*c lexical analysis
syntax analysis
COMPILER
semantic analysis
intermediate code
generation
code optimisation
code generation
Benefits of Using a Compiler
Portability: Compiled code can be executed on any computer that has the same
processor architecture.
Error Detection: Compilers can detect many types of errors in the source code
Assembly
Language
High-Level
Programming Machine Language
Languages
COMPUTER
LANGUAGES
WHAT IS THE ASSEMBLER
assembler
It is system software whitch translate programs written in assembly
language into a machine language.
Assembly Machine
Assembler
Language language
Assembly Language
ASSEMBLER
Single-pass Multipass
assembler assembler
Types of assembler
Single-pass assembler
Multipass assembler
pass1: fine all labeles,instructions and calculating corresponding adresses
pass2: convert all the instructions into machine langage format.
symbol table:
store all the informations of assembly
langage data ,variables,instructions
,adresses etc…
How assembler works
DIFFERENCES BETWEEN COMPILER AND ASSEMBLER
WHY COMPUTER UNDERSTAND BINARY DATA
PROCESSING
The central processing unit (CPU) is the brain of the computer. It interprets and
executes instructions. It fetches data and instructions from memory, performs
calculations,
SO,WHAT IS TRANSISTOR!
WHAT IS TRANSISTOR!
off on
“0” “1”
SUMMARY
ASMA BERRADJA
MAHI AYA