Intermediate Code Generation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
projectsofme
Active In SP
**

Posts: 1,124
Joined: Jun 2010
#1
26-11-2010, 03:37 PM



.ppt   Intermediate Code Generation.PPT (Size: 108.5 KB / Downloads: 139)
Presented by:Dewan Tanvir Ahmed
Intermediate Code Generation



Intermediate Code Generation
Translating source program into an “intermediate language.”
Simple
CPU Independent,
…yet, close in spirit to machine language.

Or, depending on the application other intermediate languages may be used, but in general, we opt for simple, well structured intermediate forms.

(and this completes the “Front-End” of Compilation).

Benefits
Retargeting is facilitated
Machine independent Code Optimization can be applied.


Intermediate codes are machine independent codes, but they are close to machine instructions.

The given program in a source language is converted to an equivalent program in an intermediate language by the intermediate code generator.

Intermediate language can be many different languages, and the designer of the compiler decides this intermediate language.
syntax trees can be used as an intermediate language.

postfix notation can be used as an intermediate language.

three-address code (Quadraples) can be used as an intermediate language
we will use quadraples to discuss intermediate code generation
quadraples are close to machine instructions, but they are not actual machine instructions.

some programming languages have well defined intermediate languages.
java – java virtual machine
prolog – warren abstract machine
In fact, there are byte-code emulators to execute instructions in these intermediate languages.

Syntax Dir. Definition for Assignment Statements

PRODUCTION Semantic Rule
S  id := E { S.nptr = mknode (‘assign’, mkleaf(id, id.entry), E.nptr) }


E  E1 + E2 {E.nptr = mknode(‘+’, E1.nptr,E2.nptr) }

E  E1 * E2 {E.nptr = mknode(‘*’, E1.nptr,E2.nptr) }

E  - E1 {E.nptr = mknode(‘uminus’,E1.nptr) }

E  ( E1 ) {E.nptr = E1.nptr }

E  id {E.nptr = mkleaf(id, id.entry) }


Three Address Code


Statements of general form x:=y op z

No built-up arithmetic expressions are allowed.

As a result, x:=y + z * w should be represented as t1:=z * w t2:=y + t1 x:=t2

Observe that given the syntax-tree or the dag of the graphical representation we can easily derive a three address code for assignments as above.

In fact three-address code is a linearization of the tree.

Three-address code is useful: related to machine-language/ simple/ optimizable.


Types of Three-Address Statements.


Assignment Statement: x:=y op z
Assignment Statement: x:=op z
Copy Statement: x:=z
Unconditional Jump: goto L
Conditional Jump: if x relop y goto L
Stack Operations: Push/pop
More Advanced:
Procedure:
param x1 param x2 … param xn call p,n

Index Assignments:
x:=y[i]
x[i]:=y

Address and Pointer Assignments:
x:=&y
x:=*y
*x:=y
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page

Quick Reply
Message
Type your reply to this message here.


Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  Image Morphing Matlab code NISHA. 0 434 22-10-2014, 04:16 PM
Last Post: NISHA.
  BAR CODE TECHNOLOGY AND ITS APPLICATION TO LIBRARY SERVICES ppt study tips 0 492 23-08-2013, 04:33 PM
Last Post: study tips
  IEEE 802.11ac-Wi-Fi for the Mobile and Video Generation Report study tips 0 353 03-08-2013, 12:46 PM
Last Post: study tips
  SOURCE CODE GENERATORS, MAINTENANCE AND REVERSE ENGINEERING study tips 0 280 19-07-2013, 03:45 PM
Last Post: study tips
  Code Division Multiple Access for Wireless Communications pdf study tips 0 332 26-06-2013, 01:05 PM
Last Post: study tips
  TAKEOVER: A New Vertical Handover Concept for Next-Generation Heterogeneous pdf study tips 0 396 19-06-2013, 01:02 PM
Last Post: study tips
  An Intermediate Google SketchUp Tutorial - Part 3 study tips 0 346 18-06-2013, 11:38 AM
Last Post: study tips
  Wireless Sensor Network Simulator v1.0 ( Source Code ) study tips 0 311 10-06-2013, 03:17 PM
Last Post: study tips
  Algorithms for Huffman Compression/Decompression ( Source Code ) study tips 0 382 10-06-2013, 02:18 PM
Last Post: study tips
  NETWORK BANKING $OFTWARE (Source Code) study tips 0 411 08-06-2013, 04:56 PM
Last Post: study tips