WACHEMO UNIVERSITY
DURAME CAMPUS
COMPILED BY SELAMU S.
COLLEGE OF ENGINEERING AND TECHNOLOGY
SCHOOL OF COMPUTING AND INFORMATICS
DEPARTMENT OF COMPUTER SCIENCE
INTRODUCTION TO MICROPROCESSOR
LECTURE_5
PROGRAM CONTROL INSTRUCTIONS
11/23/2024
Program Control Instructions
PROGRAM CONTROL INSTRUCTIONS
 The program control instructions direct the flow of a program and allow the flow to change.
 A change in flow often occurs after a decision made with the CMP or TEST instruction is
followed by a conditional jump instruction.
 The control transfer instructions transfer the flow of execution of the program to a new address
specified in the instruction directly or indirectly.
3
11/23/2024
Program Control Instructions
Cont...;
Program Control Instructions can be classified into two as:-
4
1) Unconditional Transfer Instructions
 There are instructions under this category.
2) Conditional Transfer instructions
 JA / JNBE
 JAE / JB/ JNC
 JB / JC / JNAE
 JGE / JNL
 JL / JNGE
 JLE / JNG
 JNE / JNZ
 JS
 JNS
 JP / JPE
 JO
 JNO
 JCXZ
 JMP
11/23/2024
Program Control Instructions
THE JUMP GROUP
Jump Instructions are used for changing the flow of execution of instructions in the processor.
If we want jump to any instruction in between the code, then this can be achieved by these
instructions.
There are two types of Jump instructions:-
1) Unconditional Jump Instructions
2) Conditional Jump Instructions
5
11/23/2024
Program Control Instructions
UNCONDITIONAL JUMP (JMP)
 This instruction will fetch the next instruction from the location specified in the instruction rather than
from the next location after the JMP instruction.
 If the destination is in the same code segment as the JMP instruction, then only the instruction pointer
will be changed to get the destination location. This is referred to as a near jump.
 If the destination for the jump instruction is in a segment with a name different from that of the segment
containing the JMP instruction, then both the instruction pointer and the code segment register content
will be changed to get the destination location. This referred to as a far jump.
 The JMP instruction does not affect any flag.
6
11/23/2024
Program Control Instructions
CONDITIONAL JUMPS & CONDITIONAL SETS
 Conditional jump instructions are always short jumps in the 8086 through the 80286 microprocessors.
 This limits the range of the jump to within +127 bytes and -128 bytes from the location following the
conditional jump.
 This allows these microprocessors to use a conditional jump to any location within the current code
segment.
 The conditional jump instructions test the following flag bits: sign (S), zero (Z), carry (C), parity (P),
and overflow (0).
 If the condition under test is true, a branch to the label associated with the jump instruction occurs.
 If the condition is false, the next sequential step in the program executes.
7
11/23/2024
Program Control Instructions 8
11/23/2024
Program Control Instructions
CONDITIONAL SET INSTRUCTIONS.
 In addition to the conditional jump instructions, the 8086 through the processors also contain
conditional set instructions.
 The conditions tested by conditional jumps are put to work with the conditional set instructions.
 The conditional set instructions set a byte to either 01H or clear a byte to 00H, depending on the
outcome of the condition under test.
9
11/23/2024
Program Control Instructions 10
11/23/2024
Program Control Instructions
CONTROLLING THE FLOW OF THE PROGRAM
 It is much easier to use the assembly language statements .IF, .ELSE, .ELSEIF, and .ENDIF to
control the flow of the program than it is to use the correct conditional jump statement.
 These statements always indicate a special assembly language command to (Microsoft Macro
Assembler) MASM.
 Note that the control flow assembly language statements beginning with a period are only
available to MASM version 6.xx, and not to earlier versions of the assembler.
11
11/23/2024
Program Control Instructions
LOOP
 The LOOP instruction is a combination of a decrement CX and the JNZ conditional jump.
 LOOP (JUMP TO SPECIFIED LABEL IF CX * 0 AFTER AUTO DECREMENT)
 This instruction is used to repeat a series of instructions some number of times.
 The number of times the instruction sequence is to be repeated is loaded into CX.
 Each time the LOOP instruction executes, CX is automatically decremented by 1.
 If CX is not 0, execution will jump to a destination specified by a label in the instruction.
 If CX = 0 after the auto decrement, execution will simply go on to the next instruction after LOOP.
 The destination address for the jump must be in the range of -128 bytes to +127 bytes from the address
of the instruction after the LOOP instruction.
 This instruction does not affect any flag
12
11/23/2024
Program Control Instructions
LOOP (Cont…;)
 The LOOP instruction executes the group of instructions a number of times and it uses relative
addressing mode.
 The number of iterations will depend on the condition to be satisfied.
 The CX register will perform the LOOP operation on the instructions to be iterated.
 For every execution of LOOP instruction, the CX is automatically decremented by one without
affecting flags and performs a short jump to the target address. This loop will continue until the CX
becomes zero. When CX = 0, the execution of the loop will stop and the instructions after the LOOP
will start execution.
 For every execution of LOOP instruction, the CX is automatically decremented by one without
affecting flags and performs a short jump to the target address. This loop will continue until the CX
becomes zero. When CX = 0, the execution of the loop will stop and the instructions after the LOOP
will start execution.
13
11/23/2024
Program Control Instructions
CONDITIONAL LOOPS
 LOOP instruction also has conditional forms: LOOPE and LOOPNE
 LOOPE (loop while equal) instruction jumps if CX != 0 while an equal condition exists.
 Will exit loop if the condition is not equal or the CX register decrements to 0
 LOOPNE (loop while not equal) jumps if CX != 0 while a not-equal condition exists.
 Will exit loop if the condition is equal or the CX register decrements to 0
14
11/23/2024
Program Control Instructions
These instructions are used to execute the given instructions for number of times.
Following is the list of instructions under this group:-
LOOP:- Used to loop a group of instructions until the condition satisfies, i.e., CX = 0
LOOPE/LOOPZ:- Used to loop a group of instructions till it satisfies ZF = 1 & CX = 0
LOOPNE/LOOPNZ:- Used to loop a group of instructions till it satisfies ZF = 0 & CX = 0
15
11/23/2024
Program Control Instructions
This instruction is similar to LOOP except that it checks for both CX and ZF conditions to be satisfied
before the jump can take place.
Firstly the count register CX is loaded with a value of the number of times the instructions are to be
repeated.
For every iteration or every time the LOOPE/LOOPZ instruction executes, it decrements the CX register
by one without affecting flags and performs a short jump to the target address (i.e., to the address with
signed 8-bit relative displacement in the range of -128 bytes to +127 bytes from the instruction address
after LOOPE/LOOPZ instruction) until the condition CX ≠ 0 and ZF = 1 is maintained.
If CX equals 0, or if the zero flag gets cleared within the loop, the loop will terminate.
In other words, the two ways to exit the loop are CX = 0 or ZF = 0, then after the processor starts
executing the next instruction present after LOOPE/LOOPZ.
16
LOOPE/LOOPZ Instruction :
11/23/2024
Program Control Instructions
These instructions are the opposite of LOOPE/LOOPZ. It decrements the CX register by one without
affecting flags and performs a short jump to the target address if CX ≠ 0 and ZF = 0.
In other words, the number of iterations is loaded into the count register CX and after every time the
instruction LOOPE/LOOPZ executes the CX will be auto decremented by one.
Until the conditions, CX ≠ 0 and ZF = 0 satisfies, the execution performs a short jump to the target
address given in the instruction.
When either of the condition CX ≠ 0 or ZF = 0 fails to satisfies i.e., zero flag (ZF) is set or CX becomes
zero after auto decrement, the execution of the loop will exit, and the instruction after LOOPE/LOOPZ
in the program will be executed.
A group of instructions can be repeated a number of times (i.e., until CX = 0 and ZF ≠ 0) by using
LOOPE/LOOPZ.
17
LOOPNE/LOOPNZ Instruction :
11/23/2024
Program Control Instructions
REPEAT
A series of instructions is repeated until some condition occurs.
The .REPEAT statement defines the start of the loop.
 end is defined with the .UNTIL statement, which contains a condition
An .UNTILCXZ instruction uses the LOOP instruction to check CX for a repeat loop.
 .UNTILCXZ uses the CX register as a counter to repeat a loop a fixed number of times
18
REPEAT-UNTIL Loops
11/23/2024
Program Control Instructions
PROCEDURES
A procedure is a group of instructions that usually performs one task.
Subroutine, method, or function is an important part of any system’s architecture
A procedure is a reusable section of the software stored in memory once, used as often as
necessary.
Saves memory space and makes it easier to develop software
Disadvantage of procedure is time it takes the computer to link to, and return from it.
19
 CALL links to the procedure; the RET (return) instruction returns from the procedure
 RET instruction removes an address from the stack so the program returns to the instruction
following the CALL.
11/23/2024
Program Control Instructions
CALL
 Transfers the flow of the program to the procedure.
 CALL instruction differs from the jump instruction because a CALL saves a return address on
the stack.
 The return address returns control to the instruction that immediately follows the CALL in a
program when a RET instruction executes.
CALL pushes the address of the instruction following the CALL (return address) on the stack.
 The stack stores the return address when a procedure is called during a program
20
11/23/2024
Program Control Instructions
RET
 RET instruction removes an address from the stack so the program returns to the instruction
following the CALL.
 It returns the control from procedure to calling program.
 Every CALL instruction should have a RET.
 The address of the instruction following the CALL (return address) on the stack.
 The return address returns control to the instruction that immediately follows the CALL in a
program when a RET instruction.
21
11/23/2024
Program Control Instructions
INTRODUCTION TO INTERRUPTS
Interrupt is the method of creating a temporary halt during program execution and allows
peripheral devices to access the microprocessor.
An interrupt is either a hardware-generated CALL (externally derived from a hardware
signal) or a software-generated CALL (internally derived from the execution of an instruction
or by some other internal event).
At times, an internal interrupt is called an exception.
Either type interrupts the program by calling an interrupt service procedure (ISP) or interrupt
handler.
An interrupt is a condition that halts the microprocessor temporarily to work on a different task
and then returns to its previous task.
22
11/23/2024
Program Control Instructions
INTERRUPT VECTORS
 An interrupt vector table (IVT) is a data structure that associates a list of interrupt
handlers with a list of interrupt requests in a table of interrupt vectors.
 Each entry of the interrupt vector table, called an interrupt vector, is the address of an interrupt
handler.
23
INTERRUPT INSTRUCTIONS
 These instructions are used to call the interrupt during program execution.
1) INT:- used to interrupt the program during execution and calling service specified.
2) INTO:- used to interrupt the program during execution if OF = 1
3) IRET:- used to return from interrupt service to the main program
11/23/2024
Program Control Instructions
INTERRUPT CONTROL
 Two instructions control the INTR pin.
 The set interrupt flag instruction (STI) places 1 in the I flag bit.
 which enables the INTR pin.
 The clear interrupt flag instruction (CLI) places a 0 into the I flag bit.
 which disables the INTR pin.
 In software interrupt service procedure, hardware interrupts are enabled as one of the first steps.
 accomplished by the STI instruction
 Interrupts are enabled early because just about all of the I/O devices in the personal computer are
interrupt-processed.
 if interrupts are disabled too long, severe system problems result.
24
11/23/2024
Program Control Instructions
MACHINE CONTROL AND MISCELLANEOUS INSTRUCTIONS
 Microprocessors are electronic devices that process digital information using instructions stored in
memory.
 Machine control instructions are a type of instruction that control machine functions such as Halt,
Interrupt, or do nothing.
 These instructions alter the different type of operations executed in the processor.
 Machine control instructions have specific features that affect the microprocessor’s operations.
 Machine control instructions can have limitations that affect the performance and reliability of
microprocessors.
25
11/23/2024
Program Control Instructions
Flag Control Instructions
 The 8086 microprocessor has a set of flags that either monitors the state of executing instructions or
controls options available in its operation.
 The instruction set includes a group of instructions that. when executed, directly affect the state of the
flags.
26
11/23/2024
Program Control Instructions
HLT INSTRUCTION
27
The HLT instruction causes the 8086 to stop fetching and executing instructions.
The 8086 will enter a halt state.
The different ways to get the processor out of the halt state are with an interrupt signal on the
INTR pin, an interrupt signal on the NMI pin, or a reset signal on the RESET input.
The HLT instruction halts any further execution of instructions by the microprocessor.
The HLT instruction can cause the microprocessor to enter a wait state indefinitely, which can
impact the system’s responsiveness.
11/23/2024
Program Control Instructions
WAIT (WAIT FOR SIGNAL OR INTERRUPT SIGNAL)
When this instruction is executed, the 8086 enters an idle condition in which it is doing no
processing.
The 8086 will stay in this idle state until the 8086 TEST input pin is made low or until an
interrupt signal is received on the INTR or the NMI interrupt input pins.
If a valid interrupt occurs while the 8086 is in this idle state, the 8086 will return to the idle
state after the interrupt service procedure executes.
WAIT does not affect any flag.
The WAIT instruction is used to synchronize the 8086 with external hardware such as the 8087
Math coprocessor.
28
11/23/2024
Program Control Instructions
NOP (PERFORM NO OPERATION)
 At the time of execution of NOP instruction, no operation is performed except fetch and
decode.
 It takes three clock cycles to execute the instruction.
 This instruction simply uses up three clock cycles and increments the instruction pointer to
point to the next instruction
 NOP does not affect any flag.
 This instruction is used to fill in time delays or delete and insert instructions in the programs
while trouble shooting.
The NOP instruction does not affect the microprocessor’s state.
29
11/23/2024
Program Control Instructions 30

LECTURE_5 Program Control Instructions.pptx

  • 1.
    WACHEMO UNIVERSITY DURAME CAMPUS COMPILEDBY SELAMU S. COLLEGE OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTING AND INFORMATICS DEPARTMENT OF COMPUTER SCIENCE INTRODUCTION TO MICROPROCESSOR
  • 2.
  • 3.
    11/23/2024 Program Control Instructions PROGRAMCONTROL INSTRUCTIONS  The program control instructions direct the flow of a program and allow the flow to change.  A change in flow often occurs after a decision made with the CMP or TEST instruction is followed by a conditional jump instruction.  The control transfer instructions transfer the flow of execution of the program to a new address specified in the instruction directly or indirectly. 3
  • 4.
    11/23/2024 Program Control Instructions Cont...; ProgramControl Instructions can be classified into two as:- 4 1) Unconditional Transfer Instructions  There are instructions under this category. 2) Conditional Transfer instructions  JA / JNBE  JAE / JB/ JNC  JB / JC / JNAE  JGE / JNL  JL / JNGE  JLE / JNG  JNE / JNZ  JS  JNS  JP / JPE  JO  JNO  JCXZ  JMP
  • 5.
    11/23/2024 Program Control Instructions THEJUMP GROUP Jump Instructions are used for changing the flow of execution of instructions in the processor. If we want jump to any instruction in between the code, then this can be achieved by these instructions. There are two types of Jump instructions:- 1) Unconditional Jump Instructions 2) Conditional Jump Instructions 5
  • 6.
    11/23/2024 Program Control Instructions UNCONDITIONALJUMP (JMP)  This instruction will fetch the next instruction from the location specified in the instruction rather than from the next location after the JMP instruction.  If the destination is in the same code segment as the JMP instruction, then only the instruction pointer will be changed to get the destination location. This is referred to as a near jump.  If the destination for the jump instruction is in a segment with a name different from that of the segment containing the JMP instruction, then both the instruction pointer and the code segment register content will be changed to get the destination location. This referred to as a far jump.  The JMP instruction does not affect any flag. 6
  • 7.
    11/23/2024 Program Control Instructions CONDITIONALJUMPS & CONDITIONAL SETS  Conditional jump instructions are always short jumps in the 8086 through the 80286 microprocessors.  This limits the range of the jump to within +127 bytes and -128 bytes from the location following the conditional jump.  This allows these microprocessors to use a conditional jump to any location within the current code segment.  The conditional jump instructions test the following flag bits: sign (S), zero (Z), carry (C), parity (P), and overflow (0).  If the condition under test is true, a branch to the label associated with the jump instruction occurs.  If the condition is false, the next sequential step in the program executes. 7
  • 8.
  • 9.
    11/23/2024 Program Control Instructions CONDITIONALSET INSTRUCTIONS.  In addition to the conditional jump instructions, the 8086 through the processors also contain conditional set instructions.  The conditions tested by conditional jumps are put to work with the conditional set instructions.  The conditional set instructions set a byte to either 01H or clear a byte to 00H, depending on the outcome of the condition under test. 9
  • 10.
  • 11.
    11/23/2024 Program Control Instructions CONTROLLINGTHE FLOW OF THE PROGRAM  It is much easier to use the assembly language statements .IF, .ELSE, .ELSEIF, and .ENDIF to control the flow of the program than it is to use the correct conditional jump statement.  These statements always indicate a special assembly language command to (Microsoft Macro Assembler) MASM.  Note that the control flow assembly language statements beginning with a period are only available to MASM version 6.xx, and not to earlier versions of the assembler. 11
  • 12.
    11/23/2024 Program Control Instructions LOOP The LOOP instruction is a combination of a decrement CX and the JNZ conditional jump.  LOOP (JUMP TO SPECIFIED LABEL IF CX * 0 AFTER AUTO DECREMENT)  This instruction is used to repeat a series of instructions some number of times.  The number of times the instruction sequence is to be repeated is loaded into CX.  Each time the LOOP instruction executes, CX is automatically decremented by 1.  If CX is not 0, execution will jump to a destination specified by a label in the instruction.  If CX = 0 after the auto decrement, execution will simply go on to the next instruction after LOOP.  The destination address for the jump must be in the range of -128 bytes to +127 bytes from the address of the instruction after the LOOP instruction.  This instruction does not affect any flag 12
  • 13.
    11/23/2024 Program Control Instructions LOOP(Cont…;)  The LOOP instruction executes the group of instructions a number of times and it uses relative addressing mode.  The number of iterations will depend on the condition to be satisfied.  The CX register will perform the LOOP operation on the instructions to be iterated.  For every execution of LOOP instruction, the CX is automatically decremented by one without affecting flags and performs a short jump to the target address. This loop will continue until the CX becomes zero. When CX = 0, the execution of the loop will stop and the instructions after the LOOP will start execution.  For every execution of LOOP instruction, the CX is automatically decremented by one without affecting flags and performs a short jump to the target address. This loop will continue until the CX becomes zero. When CX = 0, the execution of the loop will stop and the instructions after the LOOP will start execution. 13
  • 14.
    11/23/2024 Program Control Instructions CONDITIONALLOOPS  LOOP instruction also has conditional forms: LOOPE and LOOPNE  LOOPE (loop while equal) instruction jumps if CX != 0 while an equal condition exists.  Will exit loop if the condition is not equal or the CX register decrements to 0  LOOPNE (loop while not equal) jumps if CX != 0 while a not-equal condition exists.  Will exit loop if the condition is equal or the CX register decrements to 0 14
  • 15.
    11/23/2024 Program Control Instructions Theseinstructions are used to execute the given instructions for number of times. Following is the list of instructions under this group:- LOOP:- Used to loop a group of instructions until the condition satisfies, i.e., CX = 0 LOOPE/LOOPZ:- Used to loop a group of instructions till it satisfies ZF = 1 & CX = 0 LOOPNE/LOOPNZ:- Used to loop a group of instructions till it satisfies ZF = 0 & CX = 0 15
  • 16.
    11/23/2024 Program Control Instructions Thisinstruction is similar to LOOP except that it checks for both CX and ZF conditions to be satisfied before the jump can take place. Firstly the count register CX is loaded with a value of the number of times the instructions are to be repeated. For every iteration or every time the LOOPE/LOOPZ instruction executes, it decrements the CX register by one without affecting flags and performs a short jump to the target address (i.e., to the address with signed 8-bit relative displacement in the range of -128 bytes to +127 bytes from the instruction address after LOOPE/LOOPZ instruction) until the condition CX ≠ 0 and ZF = 1 is maintained. If CX equals 0, or if the zero flag gets cleared within the loop, the loop will terminate. In other words, the two ways to exit the loop are CX = 0 or ZF = 0, then after the processor starts executing the next instruction present after LOOPE/LOOPZ. 16 LOOPE/LOOPZ Instruction :
  • 17.
    11/23/2024 Program Control Instructions Theseinstructions are the opposite of LOOPE/LOOPZ. It decrements the CX register by one without affecting flags and performs a short jump to the target address if CX ≠ 0 and ZF = 0. In other words, the number of iterations is loaded into the count register CX and after every time the instruction LOOPE/LOOPZ executes the CX will be auto decremented by one. Until the conditions, CX ≠ 0 and ZF = 0 satisfies, the execution performs a short jump to the target address given in the instruction. When either of the condition CX ≠ 0 or ZF = 0 fails to satisfies i.e., zero flag (ZF) is set or CX becomes zero after auto decrement, the execution of the loop will exit, and the instruction after LOOPE/LOOPZ in the program will be executed. A group of instructions can be repeated a number of times (i.e., until CX = 0 and ZF ≠ 0) by using LOOPE/LOOPZ. 17 LOOPNE/LOOPNZ Instruction :
  • 18.
    11/23/2024 Program Control Instructions REPEAT Aseries of instructions is repeated until some condition occurs. The .REPEAT statement defines the start of the loop.  end is defined with the .UNTIL statement, which contains a condition An .UNTILCXZ instruction uses the LOOP instruction to check CX for a repeat loop.  .UNTILCXZ uses the CX register as a counter to repeat a loop a fixed number of times 18 REPEAT-UNTIL Loops
  • 19.
    11/23/2024 Program Control Instructions PROCEDURES Aprocedure is a group of instructions that usually performs one task. Subroutine, method, or function is an important part of any system’s architecture A procedure is a reusable section of the software stored in memory once, used as often as necessary. Saves memory space and makes it easier to develop software Disadvantage of procedure is time it takes the computer to link to, and return from it. 19  CALL links to the procedure; the RET (return) instruction returns from the procedure  RET instruction removes an address from the stack so the program returns to the instruction following the CALL.
  • 20.
    11/23/2024 Program Control Instructions CALL Transfers the flow of the program to the procedure.  CALL instruction differs from the jump instruction because a CALL saves a return address on the stack.  The return address returns control to the instruction that immediately follows the CALL in a program when a RET instruction executes. CALL pushes the address of the instruction following the CALL (return address) on the stack.  The stack stores the return address when a procedure is called during a program 20
  • 21.
    11/23/2024 Program Control Instructions RET RET instruction removes an address from the stack so the program returns to the instruction following the CALL.  It returns the control from procedure to calling program.  Every CALL instruction should have a RET.  The address of the instruction following the CALL (return address) on the stack.  The return address returns control to the instruction that immediately follows the CALL in a program when a RET instruction. 21
  • 22.
    11/23/2024 Program Control Instructions INTRODUCTIONTO INTERRUPTS Interrupt is the method of creating a temporary halt during program execution and allows peripheral devices to access the microprocessor. An interrupt is either a hardware-generated CALL (externally derived from a hardware signal) or a software-generated CALL (internally derived from the execution of an instruction or by some other internal event). At times, an internal interrupt is called an exception. Either type interrupts the program by calling an interrupt service procedure (ISP) or interrupt handler. An interrupt is a condition that halts the microprocessor temporarily to work on a different task and then returns to its previous task. 22
  • 23.
    11/23/2024 Program Control Instructions INTERRUPTVECTORS  An interrupt vector table (IVT) is a data structure that associates a list of interrupt handlers with a list of interrupt requests in a table of interrupt vectors.  Each entry of the interrupt vector table, called an interrupt vector, is the address of an interrupt handler. 23 INTERRUPT INSTRUCTIONS  These instructions are used to call the interrupt during program execution. 1) INT:- used to interrupt the program during execution and calling service specified. 2) INTO:- used to interrupt the program during execution if OF = 1 3) IRET:- used to return from interrupt service to the main program
  • 24.
    11/23/2024 Program Control Instructions INTERRUPTCONTROL  Two instructions control the INTR pin.  The set interrupt flag instruction (STI) places 1 in the I flag bit.  which enables the INTR pin.  The clear interrupt flag instruction (CLI) places a 0 into the I flag bit.  which disables the INTR pin.  In software interrupt service procedure, hardware interrupts are enabled as one of the first steps.  accomplished by the STI instruction  Interrupts are enabled early because just about all of the I/O devices in the personal computer are interrupt-processed.  if interrupts are disabled too long, severe system problems result. 24
  • 25.
    11/23/2024 Program Control Instructions MACHINECONTROL AND MISCELLANEOUS INSTRUCTIONS  Microprocessors are electronic devices that process digital information using instructions stored in memory.  Machine control instructions are a type of instruction that control machine functions such as Halt, Interrupt, or do nothing.  These instructions alter the different type of operations executed in the processor.  Machine control instructions have specific features that affect the microprocessor’s operations.  Machine control instructions can have limitations that affect the performance and reliability of microprocessors. 25
  • 26.
    11/23/2024 Program Control Instructions FlagControl Instructions  The 8086 microprocessor has a set of flags that either monitors the state of executing instructions or controls options available in its operation.  The instruction set includes a group of instructions that. when executed, directly affect the state of the flags. 26
  • 27.
    11/23/2024 Program Control Instructions HLTINSTRUCTION 27 The HLT instruction causes the 8086 to stop fetching and executing instructions. The 8086 will enter a halt state. The different ways to get the processor out of the halt state are with an interrupt signal on the INTR pin, an interrupt signal on the NMI pin, or a reset signal on the RESET input. The HLT instruction halts any further execution of instructions by the microprocessor. The HLT instruction can cause the microprocessor to enter a wait state indefinitely, which can impact the system’s responsiveness.
  • 28.
    11/23/2024 Program Control Instructions WAIT(WAIT FOR SIGNAL OR INTERRUPT SIGNAL) When this instruction is executed, the 8086 enters an idle condition in which it is doing no processing. The 8086 will stay in this idle state until the 8086 TEST input pin is made low or until an interrupt signal is received on the INTR or the NMI interrupt input pins. If a valid interrupt occurs while the 8086 is in this idle state, the 8086 will return to the idle state after the interrupt service procedure executes. WAIT does not affect any flag. The WAIT instruction is used to synchronize the 8086 with external hardware such as the 8087 Math coprocessor. 28
  • 29.
    11/23/2024 Program Control Instructions NOP(PERFORM NO OPERATION)  At the time of execution of NOP instruction, no operation is performed except fetch and decode.  It takes three clock cycles to execute the instruction.  This instruction simply uses up three clock cycles and increments the instruction pointer to point to the next instruction  NOP does not affect any flag.  This instruction is used to fill in time delays or delete and insert instructions in the programs while trouble shooting. The NOP instruction does not affect the microprocessor’s state. 29
  • 30.