• edited by
309 views
1 1 vote

Consider the following $3$-address code sequence. This code is divided into basic blocks. How many basic blocks are there? (Answer as an integer)

 

1: a = 1
2: b = 2
3: if a > b goto 7
4: c = a + b
5: d = c *2
6: goto 8
7: c = a - b
8: a = c + 1
9: print a

 

1 Answer

2 2 votes
  • Rule 1: First instruction is leader: 1
     
  • Rule 2: Jump targets: goto $7 \rightarrow 7$ is leader, goto $8 \rightarrow 8$ is leader
     
  • Rule 3: Instructions after jumps: after instruction 3 (conditional jump) $\rightarrow \mathbf{4}$ is leader, after instruction 6 (unconditional jump) -7 is leader (already counted)

Leaders: 1, 4, 7, 8

No of basic blocks = no. of leaders = 4

Answer:
Position:
Show:

Related questions

2 2 votes
1 1 answer
307
307 views
GO Classes asked Nov 27, 2025
307 views
Consider the following $3$-address code sequence. This code is divided into basic blocks. How many basic blocks are there? (Answer as an integer) 1: i = 0 2: sum = 0 3: t...
1 1 vote
1 1 answer
1.7k
1.7k views
GO Classes asked Nov 27, 2025
1,713 views
Consider the following sequence of $3$-address code. This code is divided into basic blocks. How many basic blocks are there? (Answer as an integer)$$\begin{aligned}& \ve...
6 6 votes
2 2 answers
443
443 views
GO Classes asked Nov 27, 2025
443 views
The minimum number of arithmetic operations required to evaluate the polynomial$$P(X)=2 X^6-3 X^5+4 X^4-X^3+5 X^2+6 X-7$$for a given value of $X$, using only one temporar...
5 5 votes
2 2 answers
453
453 views
GO Classes asked Nov 27, 2025
453 views
The minimum number of arithmetic operations (additions and multiplications) required to evaluate the polynomial$$P(X)=X^5+3 X^4+2 X^3+7 X^2+8 X+9$$for a given value of $X...