Flow of execution of a computer program:
Computer instructions are stored in contiguous locations in RAM memory
Flow of execution of a computer program:
Flow of execution of a computer program:
Flow of execution of a computer program:
Flow of execution of a computer program:
In-order program flow illustrated using Java statements
r = 5.0; // Statement 1
area = 3.14 * r * r; // Statement 2
|
After executing the (current) statement 1 in the program, the CPU will execute the (next) statement 2 that physically follows the (current) statement 1 in the program
Flow of execution of a computer program:
Out-of-order program flow illustrated using Java statements
if ( 4 > 3 )
{
answer = "Greater"; // Statement 1
}
else
{
answer = "Less"; // Statement 2
}
a = b + c; // Statement 3
|
The statement 2 answer = "Less" is physically follows the statement answer = "Greater"
But if the if-statement takes the then-branch:
|
Out-of-order program flow illustrated using Java statements
while ( 4 > 3 )
{
x = x + 1 ; // Statement 1
y = y + 1 ; // Statement 2
}
z = z + 1; // Statement 3
|
The statement 3 z = z + 1 is physically follows the statement 2 y = y + 1
But while-statement execution:
|
The Instruction Register (IR):
The Instruction Register (IR):
The Instruction Register (IR):
The Instruction Register (IR):
The Program Counter (PC):
In the above figure: the next instruction that the CPU will execute is found in memory location 44
We will discuss the usage of the PC in a later webpage
The Processor Status Register (PSR):
Example: the ARM processor's PSR:
In assembler programming, we only need to use these 4 "flags:
A flag (bit) is set (= 1) if the corresponding condition is true, otherwise it is reset (= 0).
How the values of the flags reflects a comparison between the 2 values:
I will remind you of these flags when we learn about "conditional branching" later