What is Basic Block? List out the basic blocks and draw the flow graph for the following code:

1.

location= -1

2.

i=0

3.

i<100 goto 5

4.

goto 13

5.

t1=4*i

6.

t2=A[t1]

7.

if t2=x goto 9

8.

goto 10

9.

location=i

10.

t3=i+1

11.

i=t3

12.

goto 3

13.

Added 2 years ago
Active
Viewed 948
Ans

 

Basic Block: The idea of basic block is very useful in implementing the optimizing transformations on the intermediate code. A basic block is a sequence of inter mediate code statements in which the control enters at the beginning and leaves only at the end. Within a basic block control flows sequentially. Branching in flow of control can only happen in the last statement of a basic block.

 

Basic Block for the code:

 

#

Intermediate code

B0

location= -1

i=0

B1

i<100 goto B3

B2

goto B7  

B3

t1=4*i

t2=A[t1]

if t2=x goto B5

B4

goto B6

B5

location=i

B6

t3=i+1

i=t3

goto B1

B7

 

 

 

 

 

 

 

atOptions = { 'key': 'a900f2dbf175e78754c26c6231a4b673', 'format': 'iframe', 'height': 90, 'width': 728, 'params': {} };

Related Questions