Execution of a Simple Program


You should know the procedure of the execution of the program. Here is the execution of a simple program. Let us suppose that the only three instructions of a sample program are:

  1. Input a value from a keyboard connected to a port at addresses 07H.
  2. Add 6 to the value read in
  3. Output the result to a display connected to a port at address 05H.

Let us assume that the CPU fetches instructions and data from memory one byte at a time.  We further assume that the binary codes for the instructions are stored in memory locations starting at address 001 00H.

The binary codes that would be required to execute this program on Intel 8086 processor would be as follows.

Memory AddressContents (Binary)Contents (Hex)Operation
00100H11100100E4Input from
00101H0000011107Port 07H
00102H0000010004ADD
00103H000001100606H
00104H11100110E6Output to
00105H0000010105Port 05H

The CPU of a microcomputer fetches an instruction from memory decodes the instruction to determine the actions to be taken and execute the instruction by carrying out the actions.

Execution of a simple program

The sequence of actions for the execution of the three instructions of the programs is given below.

1.

  • CPU sends the address of the first instruction to the memory
  • CPU sends memory read signal to read from memory
  • The instruction byte is sent from memory to the CPU through the data bus.

2.

  • CPU addresses the next memory location to get the rest of the instruction
  • CPU sends memory read control signal to read from memory
  • The port address byte is sent from memory to CPU through the data bus.
  • CPU sends the port address on the address bus
  • CPU sends read signal to enable part 07H
  • Data from the port is sent to the CPU through a data bus.

3.

  • CPU sends the address of the next instruction to the memory
  • CPU sends memory read signal to read from memory
  • Instruction byte form memory is sent to CPU through a data bus.

4.

  • CPU sends the next address to memory to get the rest of the instruction
  • CPU sends read control signal to read from memory
  • Number 06H from memory is sent to the CPU through the data bus.

5.

  • CPU sends the address of the next instruction to memory.
  • CPU sends memory read signal to enable memory.
  • Instruction byte from memory is sent to the CPU through a data bus.

6.

  • CPU sends the next address to get the rest of the instruction
  • CPU sends a memory control signal to enable memory.
  • The port address byte 05H is sent to CPU from memory through the data bus.
  • CPU sends ports address (05H) to the address bus.
  • CPU sends results to the port (05H) through the data bus.
  • CPU sends a write signal to enable the port 05H

All the steps described above may seem like a great deal of weak. But even a simple computer can execute such steps in a few microseconds.

In the process of execution of the program, a CPU fetches each instruction in sequence decodes the instruction, and executes it.

Execution of a simple program
Fetch Execute Cycle

You may like also


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top