in Compiler Design
345 views
0 votes
0 votes

in Compiler Design
345 views

6 Comments

What is ans ? is it 2 or 4 ??
0
0
t1=10;

t1=2;

t2=3;

t2=t1+t2;

t1=t2+t3;

t3=t2+t1;

hence we need oly 3 regi.....
0
0
without spilling means don't need to save it in memory back so

t1 = b

t2 = c

t1 =t1+ t2

t2=t1+t2

t3 =d

t2= t1 +t3

so i think 3 should be the answer

@Gupta731 what is the answer given???
0
0

2 is given as the answer. Check the solution. Please Explain. 

 

0
0
ohh...2 is also possible.....the explanation seems right to me
0
0
yeah !! here we go,

don't by hard at it i just explain this according to me

WE need minimum no of register that will perform same operation and give us output same as d.

 R1= c and R2 = b  
R1 = R2 + R1    (means we add c and d and store in R1)

                                      now R1 is consider as "a"

R2 = R1 + R2  (R1 is already "a" and store "d" in R2 , add "a" and "d")

                                 match this to question then result  R2 is  "b" so                                                      consider R2 as "b"

finally R1 = R1 + R2  (means a+b )

    and return R2.

I know i am not good at explaination but i did my best ... Correct me if i wrong.
0
0

Please log in or register to answer this question.