THE CENTRAL PROCESSING UNIT – EXECUTION OF PROGRAMS

THE CENTRAL PROCESSING UNIT – EXECUTION OF PROGRAMS

The central processing unit consists of three main parts:

1 The control unit. This fetches program instructions from the main store and causes them to be carried out.

2 The arithmetic and logic unit. This does calculations and comparisons.

3 The main store. This holds the program and the data being used.

In modern microcomputers the control unit and the arithmetic and logic unit are in the same chip. This chip is called a microprocessor, Sometimes it contains some of the main store as well.

Programs

A program is an ordered set of instructions which a computer carries out. The program is stored in the main store while it is being executed. To carry out a task, the control unit fetches and executes the instructions in the correct sequence.

Machine code refers to the set of codes which the computer has built in to it. It can decode and execute these without any translation.

A programmer can write programs in a number of programming languages. A computer cannot execute these programs directly as they are not in machine code. They have to be either interpreted or else translated into machine code before they can be executed .

The Fetch-Execute Cycle

The fetch-execute cycle (Fig 1) is a timed sequence by which the control unit ‘fetches’ instructions from the main store. They are fetched one at a time and then decoded and executed.

THE CENTRAL PROCESSING UNIT - EXECUTION OF PROGRAMS

Fig 1 Simplified flowchart of the fetch -execute cycle

Note: No stop has been shown in the diagram. Usually a computer does not stop fetching and executing instructions while it is switched on, although it does transfer from one program to another.

Example

When a typical microcomputer has finished executing a program which has been ‘RUN’, control is transferred to another program which flashes the cursor on the screen and checks the keyboard to see if a key has been pressed.

Note: In some processors (e.g. many microprocessors) an instruction may take up more than one storage location. Fetching the instruction will then take two or three operations .

 

Leave a comment

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