in Compiler Design reshown by
254 views
0 votes
0 votes

Please Answer this question 

4. Discuss design issues in code generation. Generate target code for the following basic block.   

           t1 : = a + b

           t2 : = c + d

           t3 : = e - t2

           t4 : = t1 - t3

 


in Compiler Design reshown by
by
254 views

1 Answer

0 votes
0 votes

 

 ⦁ Issues in Code Generation are:

1. Input to code generator

2. Target program

3. Memory management

4. Instruction selection

5. Register allocation

6. Choice of evaluation

7. Approaches to code generation

 

 

Generate target code for the basic block:

Statement

L

Code Generated

Register descriptor

Address descriptor

 

 

 

All Register empty

 

 t1 : = a + b

R0

MOV a, R0
ADD b, R0

R0 contains t1

T1 in R0

 t2 : = c + d

R1

MOV c, R1
ADD d, R1

R1 contains t2

T2 in R2

t3 : = e - t2

R1

SUB e, R1

R1 contains t3

T3 in R1

t4 : = t1 - t3

R0

SUB  R0, R1

R0 contains t4

T4 in R0

 

 

MOV R0, Result

 

Result in R0 and memory

 

reshown by
by

Related questions