closed by
1,605 views
3 votes
3 votes
closed as a duplicate of: GATE CSE 1991 | Question: 01,xi
The arithmetic expression $: (a + b) \ast c - d / e \ast \ast f$ is to be evaluated on a two-address machine, where each operands, the number of registers required to evaluate this expression is ______. The number of memory access of operand is __________.
closed by

2 Answers

4 votes
4 votes

 (a + b) * c - d / e * * f 

R1=a.  for a R1 memory is referred for the first time here

R2=b.   for a R2 memory is referred for the first time here

R1=R1+R2         they are added and stored in R1 for that memory is referred.

R2=c

R1=R1*R2

R2=f

R3=e.     for a R3 memory is referred for the first time here

R3=R3**R2.      they are added and stored in R3 for that memory is referred.

R1=R1/R3.         they are added and stored in R1 for that memory is referred.

So total 3 registers are required.

No of memory access of operands is how many times memory is referred.

Which is 6 as highlighted entries.

0 votes
0 votes
** is used for exponentiation.
So, in total 3 registers are required and 6 memory operations in total to fetch all operands.

Related questions

51 votes
51 votes
4 answers
4
Kathleen asked Sep 12, 2014
11,619 views
The maximum number of possible edges in an undirected graph with $n$ vertices and $k$ components is ______.