SlideShare a Scribd company logo
1 of 24
CODE
GENERATION
UNIT-5
Learning Objectives
 To understand the issues in generating code
Keyword : code generation
Introduction
Definition:
In computing, code generation is the process by which a
compiler's code generator converts some intermediate representation
of source code into a form (e.g., machine code) that can be readily
executed by a machine. Sophisticated compilers typically perform
multiple passes over various intermediate forms.
Cont.….
 So far we discussed front-end completely
 Where we discussed lexical phase ,syntax phase, semantic phase
completely
 After doing that we did intermediate code generator where we
have converted code into three address code
 All the (Front-end, code optimizer, code generator ) are access the
symbol table
Cont.…
 Code produced by complier must be correct
 Source to target program transformation is semantic preserving
 Code produced by compiler should be of high quality
 Effective use of target machine resources
 The code which is generated is in optimal state
Issues in the design of Code
Generator
 Input to the code generator
 Target Program
 Memory Management
 Instruction selection
 Register allocation
Input to the code generator:
 Intermediate representation of the source program
 Linear – Postfix
 Tables – Quadruples,Triples,Indirect triples
 No-Linear – AST,DAG
 In addition we also need a symbol table information give it to the
code generator
Target Program:
 The Back-end code generator of a complier may different forms of
code, depending on the requirements.
 Absolute machine code – Executable
 Relocatable machine code – Object files
 Assembly language
 Byte code forms for interpreters like JVM
 Implementing code generation requires thorough understanding of
the target machine architecture and its instruction set
 Our machine:
 Byte – addressable(word = 4 bytes)
 Has n general purpose registers R0,R1,……,Rn-1
 Two – address instructions of the form
 OP SOURCE , DESTINATION
Target machine :
Op-Code&Address modes
 Op – code , for example
 MOV (move content of source to destination)
 ADD (add content of source to destination)
 SUB (subtract content of source from destination)
 It has 6 address modes, They are
Instruction selection : Cost
 Machine is a simple , non-super-scalar processor with fixed
instruction costs
 Realistic machine have deep pipelines, I –cache, D –cache etc.
 Define the cost of instruction
 1+cost(source node)+cost(destination node)
Instruction selection :
Addressing modes
 Suppose we translate “ a:b+c” into
MOV b,R0
ADD c,R0
MOV R0,a
 Assuming address of a , b and c are stored in R0,R1 and R2
MOV *R1,*R2
ADD *R2,*R0
 Assuming R1 and R2 contain values of b and c
ADD R2,R1
MOV R1,a
Need for Global code optimization:
 Suppose we translate three – address code ” x:=y+z” to:
MOV y,R0
ADD z,R0
MOV R0,x
This is for single instruction…..
Cont…..
 For double instructions:
EX: a:=b+c
d:=a+e
to:
MOV a,R0
ADD b,R0
MOV R0,a Redundant as R0 is used.
MOV a,R0
ADD e,R0
MOV R0,d
Register Allocation and Assignment:
 Efficient utilization of the limited set of register s is important to
generate good code
 Registers are assigned by
 Register allocation to select the set of variables that will reside in
registers at a point in the code
 Register assignment to pick the specific register that a variable will
reside in particular point of time
Choice of Evaluation Order:
a+b-(c+d)*e t1:=a+b MOV a,R0
t2:=c+d ADD b,R0
t3:=e*t2 MOV R0,t1
t4:=t1-t3 MOV c,R1
ADD d,R1
MOV e,R0
MUL R1,R0
MOV t1,R1
SUB R0,R1
MOV R1,t4
Reordered Instructions and code:
t2: = c+d MOV c,R0
t3: = e*t2 ADD d,R0
t1: = a+b MOV e,R1
t4: = t1-t3 MUL R0,R1
MOV a ,R0
ADD b,R0
SUB R1,R0
MOV R0,t4
Cont.….
 When instruction are independent , their evolution order can be
changed to utilize registers and save on instruction set
 This is also possible with code generator
ANY QUIERIES
DARSHAN SAI REDDY.U
15121A15B2

More Related Content

What's hot

Lexical analyzer generator lex
Lexical analyzer generator lexLexical analyzer generator lex
Lexical analyzer generator lexAnusuya123
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & RecoveryAkhil Kaushik
 
Register allocation and assignment
Register allocation and assignmentRegister allocation and assignment
Register allocation and assignmentKarthi Keyan
 
Peterson Critical Section Problem Solution
Peterson Critical Section Problem SolutionPeterson Critical Section Problem Solution
Peterson Critical Section Problem SolutionBipul Chandra Kar
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environmentIffat Anjum
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languagesSOMNATHMORE2
 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assemblerBansari Shah
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignKuppusamy P
 
Three Address code
Three Address code Three Address code
Three Address code Pooja Dixit
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocksJothi Lakshmi
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy methodhodcsencet
 

What's hot (20)

Lexical analyzer generator lex
Lexical analyzer generator lexLexical analyzer generator lex
Lexical analyzer generator lex
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole Optimization
 
Error Detection & Recovery
Error Detection & RecoveryError Detection & Recovery
Error Detection & Recovery
 
Register allocation and assignment
Register allocation and assignmentRegister allocation and assignment
Register allocation and assignment
 
Ontology engineering
Ontology engineering Ontology engineering
Ontology engineering
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Distributed database
Distributed databaseDistributed database
Distributed database
 
Peterson Critical Section Problem Solution
Peterson Critical Section Problem SolutionPeterson Critical Section Problem Solution
Peterson Critical Section Problem Solution
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
 
Run time storage
Run time storageRun time storage
Run time storage
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Decision properties of reular languages
Decision properties of reular languagesDecision properties of reular languages
Decision properties of reular languages
 
Single pass assembler
Single pass assemblerSingle pass assembler
Single pass assembler
 
Intermediate code generation in Compiler Design
Intermediate code generation in Compiler DesignIntermediate code generation in Compiler Design
Intermediate code generation in Compiler Design
 
Three Address code
Three Address code Three Address code
Three Address code
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocks
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
 
loaders and linkers
 loaders and linkers loaders and linkers
loaders and linkers
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
 

Similar to Issues in the design of Code Generator

Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compilerIffat Anjum
 
Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02Tirumala Rao
 
Introduction to computer architecture .pptx
Introduction to computer architecture .pptxIntroduction to computer architecture .pptx
Introduction to computer architecture .pptxFatma Sayed Ibrahim
 
C from hello world to 010101
C from hello world to 010101C from hello world to 010101
C from hello world to 010101Bellaj Badr
 
intro to assembly language.pptx
intro to assembly language.pptxintro to assembly language.pptx
intro to assembly language.pptxEdFeranil
 
Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computerKamal Acharya
 
Pros and cons of c as a compiler language
  Pros and cons of c as a compiler language  Pros and cons of c as a compiler language
Pros and cons of c as a compiler languageAshok Raj
 
Programming basic computer
Programming basic computerProgramming basic computer
Programming basic computerMartial Kouadio
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generationIffat Anjum
 
Source-to-Source Compiler
Source-to-Source CompilerSource-to-Source Compiler
Source-to-Source CompilerMintoo Jakhmola
 
Chapter 11 - Intermediate Code Generation.pdf
Chapter 11 - Intermediate Code Generation.pdfChapter 11 - Intermediate Code Generation.pdf
Chapter 11 - Intermediate Code Generation.pdfRAnwarpasha
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compilerAbha Damani
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Shehrevar Davierwala
 

Similar to Issues in the design of Code Generator (20)

Ch9a
Ch9aCh9a
Ch9a
 
Bp150522
Bp150522Bp150522
Bp150522
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compilerLecture 01 introduction to compiler
Lecture 01 introduction to compiler
 
Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02Dineshmaterial1 091225091539-phpapp02
Dineshmaterial1 091225091539-phpapp02
 
Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
 
Introduction to computer architecture .pptx
Introduction to computer architecture .pptxIntroduction to computer architecture .pptx
Introduction to computer architecture .pptx
 
C from hello world to 010101
C from hello world to 010101C from hello world to 010101
C from hello world to 010101
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 
Phases of compiler
Phases of compilerPhases of compiler
Phases of compiler
 
intro to assembly language.pptx
intro to assembly language.pptxintro to assembly language.pptx
intro to assembly language.pptx
 
Wk1to4
Wk1to4Wk1to4
Wk1to4
 
Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
 
Pros and cons of c as a compiler language
  Pros and cons of c as a compiler language  Pros and cons of c as a compiler language
Pros and cons of c as a compiler language
 
Programming basic computer
Programming basic computerProgramming basic computer
Programming basic computer
 
Lecture 16 17 code-generation
Lecture 16 17 code-generationLecture 16 17 code-generation
Lecture 16 17 code-generation
 
Source-to-Source Compiler
Source-to-Source CompilerSource-to-Source Compiler
Source-to-Source Compiler
 
Unit1 cd
Unit1 cdUnit1 cd
Unit1 cd
 
Chapter 11 - Intermediate Code Generation.pdf
Chapter 11 - Intermediate Code Generation.pdfChapter 11 - Intermediate Code Generation.pdf
Chapter 11 - Intermediate Code Generation.pdf
 
Introduction to compiler
Introduction to compilerIntroduction to compiler
Introduction to compiler
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 

Issues in the design of Code Generator

  • 2. Learning Objectives  To understand the issues in generating code Keyword : code generation
  • 3. Introduction Definition: In computing, code generation is the process by which a compiler's code generator converts some intermediate representation of source code into a form (e.g., machine code) that can be readily executed by a machine. Sophisticated compilers typically perform multiple passes over various intermediate forms.
  • 4.
  • 5. Cont.….  So far we discussed front-end completely  Where we discussed lexical phase ,syntax phase, semantic phase completely  After doing that we did intermediate code generator where we have converted code into three address code  All the (Front-end, code optimizer, code generator ) are access the symbol table
  • 6. Cont.…  Code produced by complier must be correct  Source to target program transformation is semantic preserving  Code produced by compiler should be of high quality  Effective use of target machine resources  The code which is generated is in optimal state
  • 7. Issues in the design of Code Generator  Input to the code generator  Target Program  Memory Management  Instruction selection  Register allocation
  • 8. Input to the code generator:  Intermediate representation of the source program  Linear – Postfix  Tables – Quadruples,Triples,Indirect triples  No-Linear – AST,DAG  In addition we also need a symbol table information give it to the code generator
  • 9. Target Program:  The Back-end code generator of a complier may different forms of code, depending on the requirements.  Absolute machine code – Executable  Relocatable machine code – Object files  Assembly language  Byte code forms for interpreters like JVM
  • 10.  Implementing code generation requires thorough understanding of the target machine architecture and its instruction set  Our machine:  Byte – addressable(word = 4 bytes)  Has n general purpose registers R0,R1,……,Rn-1  Two – address instructions of the form  OP SOURCE , DESTINATION
  • 11. Target machine : Op-Code&Address modes  Op – code , for example  MOV (move content of source to destination)  ADD (add content of source to destination)  SUB (subtract content of source from destination)  It has 6 address modes, They are
  • 12.
  • 13. Instruction selection : Cost  Machine is a simple , non-super-scalar processor with fixed instruction costs  Realistic machine have deep pipelines, I –cache, D –cache etc.  Define the cost of instruction  1+cost(source node)+cost(destination node)
  • 14.
  • 15.
  • 16. Instruction selection : Addressing modes  Suppose we translate “ a:b+c” into MOV b,R0 ADD c,R0 MOV R0,a  Assuming address of a , b and c are stored in R0,R1 and R2 MOV *R1,*R2 ADD *R2,*R0  Assuming R1 and R2 contain values of b and c ADD R2,R1 MOV R1,a
  • 17. Need for Global code optimization:  Suppose we translate three – address code ” x:=y+z” to: MOV y,R0 ADD z,R0 MOV R0,x This is for single instruction…..
  • 18. Cont…..  For double instructions: EX: a:=b+c d:=a+e to: MOV a,R0 ADD b,R0 MOV R0,a Redundant as R0 is used. MOV a,R0 ADD e,R0 MOV R0,d
  • 19. Register Allocation and Assignment:  Efficient utilization of the limited set of register s is important to generate good code  Registers are assigned by  Register allocation to select the set of variables that will reside in registers at a point in the code  Register assignment to pick the specific register that a variable will reside in particular point of time
  • 20.
  • 21. Choice of Evaluation Order: a+b-(c+d)*e t1:=a+b MOV a,R0 t2:=c+d ADD b,R0 t3:=e*t2 MOV R0,t1 t4:=t1-t3 MOV c,R1 ADD d,R1 MOV e,R0 MUL R1,R0 MOV t1,R1 SUB R0,R1 MOV R1,t4
  • 22. Reordered Instructions and code: t2: = c+d MOV c,R0 t3: = e*t2 ADD d,R0 t1: = a+b MOV e,R1 t4: = t1-t3 MUL R0,R1 MOV a ,R0 ADD b,R0 SUB R1,R0 MOV R0,t4
  • 23. Cont.….  When instruction are independent , their evolution order can be changed to utilize registers and save on instruction set  This is also possible with code generator
  • 24. ANY QUIERIES DARSHAN SAI REDDY.U 15121A15B2