Central Processing Unit:
Executing instructions
Tharindu Weerasinghe
In many personal computers, the Central Processing Unit (CPU), in
association with memory, can execute instructions in less than
one-millionth of a second, although they can execute only one
instruction at a time. Those speed demons known as supercomputers can
execute instructions in less than one-billionth of a second. Before an
instruction can be executed, program instructions and data must be
placed in the memory (RAM) from an input device or a secondary storage
device.
The process is further complicated by the fact that the data will
probably make a temporary stop in a register. Once the necessary data
and instruction are in memory, the central processing unit performs the
following four steps for each instruction:
1. The control unit fetches instruction from memory.
2. The control unit decodes (decides what it means) the instruction
and directs that the necessary data be moved from memory to the
arithmetic-logic unit ALU. Time taken to fulfil these first two steps
together is called 'instruction time' or 'I-time'.
3.The ALU executes the arithmetic or logical instruction. That is,
the ALU is given control and performs the actual operation on the data.
4.The ALU stores the result of this operation in memory (RAM) or in a
register. Steps 3 and 4 together are called 'execution time' or
'E-time'. The control unit eventually directs memory to release the
result to an output device or a secondary storage device. The
combination of 'I-time' and 'E-time' is called the 'machine cycle'.
Each central processing unit has an internal clock that produces
pulses at a fixed rate to synchronize all computer operations. A single
machine-cycle instruction may be made up of a substantial number of
sub-instructions, each of which must take at least one clock cycle.
Each type of central processing unit is designed to understand a
specific group of instructions called the 'instruction set'. Just as
there are many different languages that people understand, so each
different type of CPU has an instruction set it understands. Therefore,
one CPU - such as the one for a Compaq personal computer - cannot
understand the instruction set from another CPU - say, for a Macintosh.
It is one thing to have instructions and data somewhere in memory and
quite another for the control unit to be able to find them. How does it
do this? The location in memory for each instruction and each piece of
data is identified by an address. That is, each location has an address
number, like the mailboxes in front of an apartment building. And, like
the mailboxes, the address numbers of the locations remain the same, but
the contents (instructions and data) of the locations may change.
That is, new instructions or new data may be placed in the locations
when the old contents no longer need to be stored in memory. Unlike a
mailbox, a memory location can hold only a fixed amount of data; an
address can hold only a fixed number of bytes - often two bytes in a
modern computer.
A payroll program, for example, may give instructions to put the rate
of pay in location 3 and the number of hours worked in location 6. To
compute the employee's salary then, instructions tell the computer to
multiply the data in location 3 by the data in location 6 and move the
result to location 8.
The choice of locations is arbitrary - any locations that are not
already spoken for can be used. Programmers using programming languages,
however, do not have to worry about the actual address numbers, because
each data address is referred to by a name.
The name is called a symbolic address. |