You are on page 1of 11

Program Flow Control

Program Flow Control-01


• Instructions are always stored in successive
memory locations.
• Instructions are fetched from consecutive
memory locations and executed.
• Each time an instruction is fetched from
memory, the Program Counter(PC) is
incremented to get the address of next
instruction in sequence.
Program Flow Control-02
• On the other hand, a program control type of
instruction may change the address value in the
program counter and cause the flow of control to be
altered.
• In other words, Program control instructions specify
conditions for altering the content of Program
counter.
• It provides control over the flow of program
execution and capability for branching to different
program segment.
Program Flow Control-03
• Program control instrctions are listed in Table.
Program Flow Control-03
• The Branch and Jump instructions are used to mean the same
thing, but sometimes they are used to denote different address
modes.

• The Branch is usually a ONE-Address instruction example: BR


[address]
• When its executed, the branch instruction causes a transfer of the
value of address into the program counter.

• Since the program counter contains the address of the instruction


to be executed, the next instruction will come from location
[address].
Program Flow Control-04
• Branch and jump instructions may be
conditional or unconditional.
• An unconditional branch instruction causes a
branch to the specified address with out any
condition.
• The conditional branch instruction specifies a
condition such as branch if Positive or branch
if zero.
Program Flow Control-05
• if the condition is met, the program counter is loaded with
the branch address and the next instruction is taken from
this address. if the condition is not met, the program
counter is not changed and execution continue to next
address in sequence.

• The SKIP instruction does not need an address field and is


therefore a Zero-Address Instruction.
• A conditional skip instruction will skip the next instruction
if condition is met, and just incrementing the program
counter for next instruction address.
Program Flow Control-06
• The call and return instructions are used in pair in subroutines.
• The compare and test instructions do not change the program
sequence directly.
• The compare instruction performs a subtraction between two
operands, but the result of the operation is not retaind.
However, certain status bit conditions are set as a result of the
operation.
• Similarly, the TEST instruction performs the logical AND of two
perands and update certain Status bits.
• The status bits are: Carry Bit, Sign Bit, Zero Indication and
overflow condition.
Status Bit- CPU Diagram
Program Flow Control-07

You might also like