• edited by
370 views
0 0 votes

In it’s solution how are they obtaining x with the given operation? Should we not have 1 more register to keep x separate?

Given program below uses 6 temporary variables
\[
\begin{array}{l}
\quad u, v, w, x, y, z \\
u=1 \\
v=10 \\
w=20 \\
x=u+v \\
y=w+x \\
z=w+y \\
v=w+y \\
y=v+z \\
z=5+y \\
\text { return } x+5
\end{array}
\]
Activate Windows

Assume that all operation take their operands from registers, what is the minimum number of register needed to execute this program withoutspilling? ings to activate Winds

Solution :
(c)
\[
\begin{array}{lll}
R_{1} \leftarrow u & \cdots \cdots \cdots & (u=1) \\
R_{2} \leftarrow v & \cdots \cdots \cdots & (v=10) \\
R_{3} \leftarrow w & \cdots \cdots \cdots & (w=20) \\
R_{1} \leftarrow R_{1}+R_{2} & \cdots \cdots \cdots & (x=u+v) \\
R_{1} \leftarrow R_{3}+R_{1} & \cdots \cdots \cdots & (y=w+x) \\
R_{2} \leftarrow R_{3}+R_{1} & \cdots \cdots \cdots & (z=w+y) \\
R_{3} \leftarrow R_{3}+R_{1} & \cdots \cdots \cdots & (v=w+y) \\
R_{1} \leftarrow R_{2}+R_{3} & \cdots \cdots \cdots & (y=v+z) \\
R_{3} \leftarrow 5+R_{1} & \cdots \cdots \cdots & (x=5+y) \\
\text { return }\left(R_{2}+R_{3}\right) & \cdots \cdots \cdots & \text { return }(x+5)
\end{array}
\]

Hence 3 register needed only.

Please log in or register to answer this question.

Position:
Show:

Related questions

1 1 vote
0 0 answers
189
189 views
0 0 votes
1 1 answer
1.3k
1.3k views
Souvik33 asked Nov 23, 2022
1,266 views
MSQ Consider the following sequence of micro-operations (μO) on a system used for instruction fetch:Where MAR is memory address register, PC is program counter, MBR is m...
0 0 votes
1 1 answer
471
471 views
Rohit Chakraborty asked Jan 15, 2024
471 views
Can you explain the procedure and if possible can you share some links to any youtube playlist from where I can study this particular subject(Functions).The number of ont...
0 0 votes
1 1 answer
693
693 views
Rohit Chakraborty asked Jan 6, 2024
693 views
Consider the following relational schemas, and an SQL query Q below:Sailors (Sid, Sname, rating, age)Boats (Bid, Bname, color)Reserves (Sid, Bid, day)SELECT S.sname FROM ...