Terminology: program flow

Flow of execution of a computer program:

Computer instructions are stored in contiguous locations in RAM memory

Terminology: program flow

Flow of execution of a computer program:

Terminology: program flow

Flow of execution of a computer program:

Terminology: program flow

Flow of execution of a computer program:

Terminology: program flow - in-order program flow

Flow of execution of a computer program:

Terminology: program flow - in-order program flow

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

Terminology: program flow - out-of-order program flow

Flow of execution of a computer program:

Terminology: program flow - out-of-order program flow

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:

  • After executing the (current) statement 1 in the program, the CPU will execute the (next) statement a = b + c (statement 3) that does not physically follows the (current) statement 1 in the program

Terminology: program flow - out-of-order program flow

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:

  • After executing the (current) statement 2 in the program, the CPU will execute the (next) statement x = x + 1 (statement 1) that does not physically follows the (current) statement 2 in the program

The use of special purpose registers in a CPU
 
 

The use of special purpose registers in a CPU

The Instruction Register (IR):

The use of special purpose registers in a CPU

The Instruction Register (IR):

 

The use of special purpose registers in a CPU

The Instruction Register (IR):

 

The use of special purpose registers in a CPU

The Instruction Register (IR):

 

The use of special purpose registers in a CPU

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 use of special purpose registers in a CPU

The Processor Status Register (PSR):

The use of special purpose registers in a CPU

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 CPU uses the PSR register

How the CPU uses the PSR register

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