Stored program architecture

Replica in the Small-Scale
Experimental Machine (SSEM), the world's first stored-program computer , at the
Museum of Science and Industry in Manchester, England
This section applies to most common RAM machine -based computers.
In most cases, computer instructions are simple: add one number to another,
move some data from one location to an alternative, send a message to some
external device, etc. These instructions are read from the computer's memory
and are generally carried out (executed ) in the order they were given.
However, there are usually specialized instructions to tell the computer to
jump ahead or backwards to some other put in place the program and to carry on
executing from there. These are called "jump" instructions (or
branches ). Furthermore, jump instructions may be made to happen conditionally
so that different sequences of instructions may be used depending on the result
of some previous calculation or some external celebration. Many computers
directly support subroutines by providing a type of jump that
"remembers" the location it jumped from and another instruction to
return to the instruction following that jump instruction.
Program execution might be likened to reading a book. While a person will
normally read each word and range in sequence, they may at times jump back to
an earlier place in the text or skip sections that are not of interest.
Similarly, a computer may sometimes go back and repeat the instructions in some
section of the program over and over again until some internal condition is
satisfied. This is called the flow of control within the program and it is what
allows the computer to perform tasks repeatedly without human intervention.
Comparatively, a person using a pocket calculator can perform a basic
arithmetic operation such as adding two numbers with just a few button engages.
But to add together all of the numbers from 1 to 1, 000 would take thousands of
button presses and a lot of time, with a near certainty of making a mistake. On
the other hand, a computer may be programmed to do this with just a few simple
recommendations. The following example is written in the MIPS assembly language
:
begin:
addi $8, $0, 0 # initialize sum to 0
addi $9, $0, 1 # set first number to add = 1
loop:
slti $10, $9, 1000 # check if the number is less than 1000
beq $10, $0, finish # if odd number is in excess of n then exit
add $8, $8, $9 # update sum
addi $9, $9, 1 # get next number
j loop # repeat the summing process
finish:
add $2, $8, $0 # put sum in output register
Once told to run this program, the computer will perform the repetitive
addition activity without further human intervention. It will almost never make
a mistake and a modern PC can complete the task in a fraction of a second.
No comments:
Post a Comment