Lecture-05
Lecture-05
Kenesa B. ([email protected])
CHAPTER FIVE
PROGRAM CONTROL INSTRUCTIONS
Introduction
q What is a program control instruction?
§ Instructions are fetched from successive memory locations for processing
and executing.
§ The change in the content of the program counter can cause a break in the
instruction execution.
§ However, the program control instructions control the flow of program
execution and can branch to different program segments.
• Program control instructions modify or change the flow of a program.
§ It is the instruction that alters the sequence of the program's execution
• which means it changes the value of the program counter, due to which the execution of
the program changes.
Kenesa B. (Ambo University) Microprocessor and Assembly Language Programming 3
THE JUMP GROUP
q Jump (JMP) instruction allows the programmer to skip sections of a program and
branch to any part of the memory for the next instruction.
q Jump/branch are two types:
§ Unconditional Jump/branch
§ Conditional Jump/branch
q A conditional jump instruction allows decisions based upon numerical tests.
– results are held in the flag bits, then tested by conditional jump instructions
q LOOP and conditional LOOP are also forms of the jump instruction.
q Branch/jump is usually an indication of a short change relative to the current
program counter.
q Jump is usually an indication of a change in program counter that is not directly
related to the current program counter, and is often free of distance limits from
the current program counter.
Kenesa B. (Ambo University) Microprocessor and Assembly Language Programming 4
Unconditional Jump (JMP)
q In an unconditional jump, no status requirements are imposed for the jump to
occur.
– That is, as the instruction is executed, the jump always takes place to change the execution
sequence.
q Three types: short jump, near jump, far jump.
q Short jump is a 2-byte instruction that allows jumps or branches to memory
locations within +127 and –128 bytes.
– from the address following the jump
q 3-byte near jump allows a branch or jump within ±32K bytes from the instruction
in the current code segment.
q 5-byte far jump allows a jump to any memory location within the real memory
system.
• The short and near jumps are often called intrasegment jumps.
• Far jumps are called intersegment jumps.
Kenesa B. (Ambo University) Microprocessor and Assembly Language Programming 5
Unconditional Jump (JMP)
q Note that when the instruction JMP AA in
part- I is executed, program control is passed
to a point in part III, identified by the label AA.
q Execution resumes with the instruction
corresponding to AA.
q In this way, the instructions in part II of the
program are bypassed—that is, they are
jumped over.
q Some high-level languages have a GOTO
statement.
– This is an example of a high-level
language program construct that
performs an unconditional jump
operation.
Kenesa B. (Ambo University) Microprocessor and Assembly Language Programming 6
Unconditional Jump (JMP)
XOR BX,BX
START: ADD AX,1
The effect of a near return instruction on the stack and instruction pointer.