in Compiler Design closed by
740 views
1 vote
1 vote
closed as a duplicate of: Program Flow Graph

someone please share detailed rules for this along with solution- would be of great help.

and we usually dont take start and end state- arent they extra here? coz count comes different

 

in Compiler Design closed by
740 views

1 comment

Yes start and end states need to be counted. Do you have any specific doubt? Given solution looks correct to me
1
1

1 Answer

3 votes
3 votes

In order to form control flow graph we must form basic blocks of instructions and assign edges in between them to show the flow of program as per condition met.Some rules to form basic blocks:

1.start and end blocks are added to show beginning and ending of data flow .

2. first statement is always a beginning of new block.

3. goto expression(conditional/ unconditional branching) pointing to any statement, form a new basic block starting with respective target statement no.

4. statement that follows immediately a conditional/ unconditional expression reflects beginning of new block.

The solutions must have 8 ans as per these rules. Please find below image for solution:

 

Related questions