Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
26Activity
0 of .
Results for:
No results containing your search query
P. 1
Intermediate Code Generation

Intermediate Code Generation

Ratings: (0)|Views: 1,938 |Likes:
Published by muler_tesfa

More info:

Published by: muler_tesfa on Jan 09, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PPT, PDF, TXT or read online from Scribd
See more
See less

12/01/2012

pdf

text

original

 
CS416 Compiler Design1
Intermediate Code Generation
Intermediate codes
are machine independent codes, but they are close tomachine 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 generationquadraples 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 machineIn fact, there are byte-code emulators to execute instructions in these intermediate languages.
 
CS416 Compiler Design2
Three-Address Code (Quadraples)
A quadraple is:
x
:=
y
op 
z
where x, y and z are names, constants or compiler-generatedtemporaries;
op
is any operator.But we may also the following notation for quadraples (much better notation because it looks like a machine code instruction)
op y,z,x
apply operator 
op
to
y
and
z
, and store the result in
x
.We use the term “three-address code” because each statement usuallycontains three addresses (two for operands, one for the result).
 
CS416 Compiler Design3
Three-Address Statements
 Binary Operator:
 
op y,z,result
or 
result := y op z
where
op
is a binary arithmetic or logical operator. This binary operator is applied to
y
and
z
, and the result of the operation is stored in
result
.Ex:
add a,b,cgt a,b,caddr a,b,caddi a,b,c
Unary Operator:
 
op y,,result
or 
result := op y
where
op
is a unary arithmetic or logical operator. This unary operator is applied to
y
,and the result of the operation is stored in
result
.Ex:
uminus a,,cnot a,,cinttoreal a,,c

Activity (26)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Sarah Jain liked this
Anbazhagan Anbu liked this
Ramesh Kumar liked this
Dasmath Marandi liked this
saiarvinth liked this
Kelvin Mathews liked this
Manoj Sherkhane liked this
rockyrebe liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->