Title: From Stonehenge to the Super Computer
1From Stonehenge to the Super Computer
- Computers manipulate stored information by
following given instructions. - In this chapter
- What is a program?
- How are programs stored?
- What is a stored-program computer?
- What are some examples of stored-program
computers? - How does the CPU keep track of programs as they
are being executed? - How are computers compared?
2The Stored-program Computer
- Program
- A collection of instructions for the computer to
perform one by one. - Machine Language
- The language of the computing machine.
- All instructions must be in the form of binary
numbers (binary code).
3The Stored-program Computer
- Stored-program Computer
- Also known as the von Neumann-type computer.
- Has memory - a place to keep both instructions
and the needed information needed for computation
by the computer.
4Programs and Algorithms
- Our first example of the computer The ROBOT
computer - The ROBOTs domain
- The room is empty.
- The room is rectangular.
- There may be one or more open doorways in the
walls. - The floor is paved with square tiles with lines
between them. The lines are easy to see. - The size of the room is unknown to us at any
given time. - The size of the room does not change during the
execution of a program. - Doorways will never be located in corners.
5Programs and Algorithms
ROBOT Characteristics Forward movement Moves
forward from square to square within its
domain. Changing direction Turns only 90 degrees
to the right. Arm movement Can raise and lower
its arms. Arm extension When its arms are raised,
they reach to the far edge of the next
square. Sensors The sensors at the ends of its
arms are used to locate walls. Intelligence NONE.
The ROBOT cannot see or think on its own. It only
executed instructions stored in memory.
6Programs and Algorithms
- ROBOT instructions have two parts
- Operation Code (Opcode) - Dictates the action to
be performed by the ROBOT. - Operand (Argument) - The address of a position in
memory. - Each part of a ROBOT instruction is called a
field.
ROBOT Instruction
Operation Code (3 BITS)
Operand (5 BITS)
7Programs and Algorithms
- ROBOT Programs
- Lists of instructions can be determined and
changed by the person who operates the ROBOT. - Program Refers to the list of instructions given
to the ROBOT. - A program must be placed into the ROBOTs memory
before any execution can take place. - ROBOTs Memory
- Located on the ROBOTs torso.
- 32 memory locations.
- Each memory location is a set of 8 toggle
switches. - On 1 Off 0
- Loading a program setting the switches.
8Programs and Algorithms
Opcode English Action taken by
command 000 STEP The ROBOT takes one STEP forward
if possible. 001 TURN The ROBOT pivots 90 degrees
to the right. 010 RAISE The ROBOT raises its arms
if possible. IF NOT POSSIBLE There MUST be a
wall directly in front of the ROBOT. The warning
light will come on. No other commands will be
recognized until the light is turned
off. 011 LOWER The ROBOT lowers its arms if they
are raised. 100 SENSE The ROBOT, with its arms
in raised position, can detect if it is one step
away from the wall it is facing. IF IT IS, the
warning light will turn on. Recognizes no other
commands until the light is turned
off. 101 GOTO The ROBOT takes the next command
out of normal order. The Operand, the last 5 bits
of the instruction, tells which memory location
is to be performed next. 110 LIGHT IF the light
is turned on, this command turns it off. The
ROBOT will again recognize instructions in the
program. 111 STOP The ROBOT shuts off its own
power.
9Programs and Algorithms
- Algorithm
- A step-by-step process used to solve a problem.
- The general solution to the problem.
- Usually implemented by a program.
- Problem Cause the ROBOT to walk to the wall it
is initially facing and then stop with its arms
lowered and facing against the wall. Assume the
ROBOT is not initially facing an open doorway. - Remember
- We have NO IDEA how big the room is!
- We CANT just tell it to STEP X-number of times!
- The algorithm has a general solution. (Solves the
problem in all situations.)
10Programs and Algorithms
- Programming the ROBOT - Taking the English
steps and writing them in the language the ROBOT
understands (Machine Language). - Machine Language - Written in binary code, the
program is in the form the computer understands.
English Version Machine Language Version RAIS
E 01000000 LOWER 01100000 STEP 00000000 GOTO
0 10100000 LIGHT 11000000 STOP 11100000
11Programs and Algorithms
- Loop - A sequence of instructions which is
repeated one or more times when a program is
executed. - Infinite loop - A set of instructions which
causes the program to repeat the same commands
over and over with no possible way of stopping.
12The Pencil Paper Computer
- Parts of a typical General-purpose Computer
CPU (Central Processing Unit) 1. Arithmetic
Unit (Computations performed) Accumulator
(Results of computations accumulated here) 2.
Control Unit Instruction Register (Instruction
placed here for analysis) Program Counter (Which
instruction will be performed next?) 3.
Instruction Decoding Unit (Decodes the
instruction)
Input Units
Output Units
Memory Devices
13The Pencil Paper Computer
- Parts of the Pencil Paper Computer (a
conceptual computer)
CPU (Central Processing Unit) 1. Arithmetic
Unit (Computations performed) Accumulator -14
bits long (largest number is 4095) 2. Control
Unit (Analyzes and performs instructions) Instruc
tion Register Program Counter 3. Instruction
Decoding Unit (Decodes the instruction)
Input Unit Pencil
Output Unit Paper
Memory Devices
14The Pencil Paper Computer
- The Pencil Paper Instruction Format
- Operation Code (Opcode) - Dictates action by
Pencil Paper Computer. - Operand (Argument) - The address of a position in
memory.
Pencil Paper Instruction
Operation Code (3 BITS)
Operand (5 BITS)
15The Pencil Paper Computer
- The Pencil Paper Instruction Set
- A unique set of commands to be used only when
programming the Pencil Paper Computer.
Opcode English Action taken by
command 001 ADD Add the contents of the
referenced memory location to the value in the
accumulator. 010 SUB Subtract the contents of the
referenced memory location from the value found
in the accumulator. 011 LOAD Load a copy of the
value of the referenced memory location into the
accumulator. 100 STORE Store a copy of the
contents of the accumulator into the referenced
memory location. 101 READ Read a value from the
keyboard and store it at the referenced memory
location. 110 PRINT Print the value found at the
referenced memory location. 111 PJUMP Jump to the
referenced memory location if the value of the
accumulator is a positive nonzero
number. 000 STOP This causes the computer to stop
execution of the program.
16The Pencil Paper Computer
- Process for writing Pencil Paper Computer
programs - 1. Read the problem.
- 2. Determine the algorithm.
- Break the problem down into steps.
- What will be needed as input?
- What will be needed to be computed?
- What is the desired output?
- 3. Write an outline of the steps.
- 4. Write the program.
- 5. Trace through the program.
17The Pencil Paper Computer
- 1. Problem Write a program that sums 2 numbers
read in from the user. - 2. Determine the algorithm.
- Input The 2 numbers read in.
- Computations The 2 numbers added together.
- Output The sum of the 2 numbers.
- 3. Outline
- Read in 2 numbers
- Add the 2 numbers
- Print the Sum
- 4. Write the program.
18The Pencil Paper Computer
- Problem Write a program that sums 2 numbers read
in from the user. - Program
- READ NUM1
- READ NUM2
- LOAD NUM1
- ADD NUM2
- STORE SUM
- PRINT SUM
- STOP
Memory
Num1
Num2
Sum
Accumulator
Output
19The Pencil Paper Computer
- Problem Write a program that prints the counting
numbers from 5 down to 1.
Memory
Count
One
ONE 1 COUNT 5 START PRINT COUNT LOAD COUNT SU
B ONE STORE COUNT PJUMP START STOP
Accumulator
Output
20The Pencil Paper Computer
Start Program at desired location.
- The fetch and execute cycle
Fetch an instruction from program memory at
current program counter location
Increment counter to next location in the program
memory.
Execute the instruction which was just fetched.
Is the Instruction the STOP Instruction?
YES
NO
Stop
21The Von Neumann Computer and Beyond
Fast Expensive Complex Large
- Computers are compared as to their
- Speed
- Cost
- Size
- Complexity
Super Computers
Mainframe Computers
Minicomputers
Microcomputers
Calculators
Pencil Paper Computer
Slow Cheap Simple Small
22The Von Neumann Computer and Beyond
Memory
Input Units
Output Units
CPU (Central Processing Unit)
Input Units Keyboard Floppy disk Hard
disk Mouse CD ROM
Output Units Screen Floppy drive Hard
disk Printer Speakers
23The Von Neumann Computer and Beyond
Memory
Input Units
Output Units
CPU (Central Processing Unit)
Input Units Several Keyboards Floppy
disk(s) Hard disk(s) Several Mice CD ROM(s)
Output Units Several Screens Floppy
drive(s) Hard disk(s) Printer(s) Speakers(s)
24The Von Neumann Computer and Beyond
Memory
Input Units
Output Units
CPU (Central Processing Unit)
Input Units Many Keyboard
(Hundreds?) Massive Hard disk
Output Units Many Screens (Hundreds?) Massive
Hard disk Printer(s)
25The Von Neumann Computer and Beyond
Memory
Input Units
Output Units
CPU (Central Processing Unit)
Input Units Many Keyboard
(Hundreds?) Massive Hard disk
Output Units Many Screens (Hundreds?) Massive
Hard disk Printer(s)
CPUs From many (from 4) To thousands (65,537)