500 views

2 Answers

2 votes
2 votes
If you'll use a good compiler then it'll find that both expressions can be evaluated as compile time since operands are constants. So there is not any need of executing any expression at runtime.

But if constant propagation optimization is restricted, then it can be evaluated with the help of two registers.

d= a+b;

R1 <- R1 + R2  //before execution   R1 : contains value of a, R2 : contains value of b,

c= e+d;

R1 <- R1 + R2 //before execution R1 contains value of variable d and R2 contains variable e, result will be in register R1
0 votes
0 votes
Answer is 1

MOV a R1 // move "a" to R1

ADD b R1 // Add "b" with R1

ADD c R1 // Add "c" with R1

Now value of e is in R1.

Related questions

8 votes
8 votes
1 answer
1
Kapil asked Nov 2, 2016
3,060 views
How to draw register allocation interference graph ?Can anyone explain this along with " What is a live variable "?Explain with the example given below ?a = 1 b = 10 c = ...
1 votes
1 votes
1 answer
2
. asked Apr 2, 2017
1,606 views
What will be the output of the following C program? If you think it will give a runtime error, you need to mention it. In either case,your answer must include proper just...
0 votes
0 votes
2 answers
3
Mak Indus asked Nov 10, 2018
288 views
Given an array of distinct integers A[1, 2,…n]. Find the tightest upper bound to check the existence of any index i for which A[i]= i.(a) O (1) ...
0 votes
0 votes
0 answers
4
nbhatt asked Jan 12, 2023
458 views