For a discussion on program flow, refer to this webpage: click here
|
The control constructs "if", "if-else", ("switch") "while-loop", "for-loop" and "do-while-loop" is handled in assembler code by (only) 2 kinds of assembler instructions:
|
So you may wonder how can just 2 assember instructions ((1) compare and (2) conditional/unconditional branch) be enough to implement "if", "if-else", ("switch") "while-loop", "for-loop" and "do-while-loop" etc.
The answer is: these high level programming language constructs ("if", "if-else", ("switch") "while-loop", "for-loop" and "do-while-loop") only changes the flow of program control in a computer program.
The mechanism to change the flow of program control is very simple
By using the same mechanism, we can change the program execution order in any way that we want.
|
I have to stress that the highlight of the discussions of the "if", "if-else", ("switch") "while-loop", "for-loop" and "do-while-loop" statement is:
|
We will use flow charts to help us visualize the program flow corresponding to each type of high level language statements
After constructing the flow chart of the statement, we will write assembler instructions to implement the program flow.