Execution of a Simple Program

You should know the procedure of execution of 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

Address

Contents

(Binary)

Contents

(Hex)

Operation

00100H

11100100

E4

Input from

00101H

00000111

07

Port 07H

00102H

00000100

04

ADD

00103H

00000110

06

06H

00104H

11100110

E6

Output to

00105H

00000101

05

Port 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 address of the first instruction to memory
  • CPU sends memory read signal to read from memory
  • Instruction byte is sent from memory to the CPU through the data bus.

2.

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

 3.

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

4.

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

5.

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

6.

  • CPU sends next address to get rest of instruction
  • CPU sends 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 result to the port (05H) through the data bus.
  • CPU sends 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 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 Reply

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