Fall 1998 Computers and Society
Tuesdays 6 - 9:40 PM in 113 Rackham: GST 2710, Section 990 and AGS 3360, Section 983
Mondays 5:30 - 9:10 PM at NWAC: GST 2710, Section 984
Course web site: http://www.cll.wayne.edu/isp/drbowen/casf98/
Last updated: 6/13/01
Link back to course Welcome...

Paper and Pencil Computer: a Detailed Example

Background:
During the semester, we have been going step by step into how computers work. The path so far has been:

  1. Structure of a computer - the major parts
  2. Binary numbers - how computers do arithmetic
  3. Doing arithmetic with switches - how electrical circuits can do arithmetic
  4. Logic gates - arithmetic circuits, and steering numbers to different circuits

Now, for the fifth and last step along this particular path; putting it all into action. We will use a common example called The Paper and Pencil Computer. This example is as simple a computer as can be, and still work like a computer. While it is drastically simplified, it still illustrates the basic way that all computers work. First, the architecture, or what the parts are and how they are connected. In our diagram of a computer, this one has only four components:

  1. Inputs - only a keyboard
  2. CPU - a really simple one, but we will look at it in detail
  3. Outputs - only a monitor
  4. Primary storage - 32 bytes of RAM (not 32MB!)
  5. Secondary storage - well, something had to go. No secondary storage.

So, here it is:

ppcarchb.gif (5103 bytes)

The 32 bytes of memory are shown as eight rows of 4. They are numbered 0 through 31, starting at the upper left and going row by row. That number is the address of the memory location. Each byte also has its contents, which is the one byte or 8-bit number stored there.

Remember, both the instructions (program) and the data are stored in RAM while the program is being executed. without a disk drive, there is a problem in getting the program and data into the memory locations, but we will ignore that. In the examples and problems here, the contents of the memory location will be given as part of the example / problem statement. How do they get there? Somebody else's problem.

This document describes the parts in more detail and how they work together. Other documents will give examples.

The CPU:
The Central Processing Unit has two parts; the Control Unit and the the Arithmetic and Logic Unit

First, the Control unit. It follows the same cycle, time after time, but very quickly. Here is the basic cycle:

ppcmstr.gif (4664 bytes)

This is the master cycle that the computer follows. The desired location that the program starts at will be given as part of the example / problem statement. When the Control Unit fetches an instruction, it gets the value from memory and places it in the Instruction Register (IR). The memory fetch gets one byte, so the IR is one byte. Here is how it is used:

ppcir.gif (2162 bytes)

Each instruction has an Operation Code, which says what instruction the computer will actually execute, and an address in the 32-byte RAM, the Referenced Memory Location or RML.

There is another number contained in the Program Counter (PC). When the Control unit goes to fetch an instruction, it fetches it from the memory address in the PC.

So the Control Unit has three numbers that it keeps track of:

Next, the Arithmetic and Logic Unit, or ALU. This has the logic gates that do the arithmetic. It contains the Accumulator (AC). This is location in which the CPU does all of its arithmetic.

Instruction Set:
A CPU's Instruction Set is the collection of all of the instructions it can execute or carry out. Each CPU has it's own instruction set. Here is the instruction set for the Paper and Pencil Computer.

Mnemonic Operation Code What the instruction does
ADD 001 Add the contents of the Referenced Memory Location (RML) to the current value in the accumulator (AC).
SUB 010 Subtract the contents of the Referenced Memory Location (RML) from the current value in the accumulator (AC).
LOAD 011 Load a copy of the contents of the Referenced Memory Location (RML) into the Accumulator (AC). This replaces the previous value in the AC, but leaves the contents of the RML unchanged.
STORE 100 Store a copy of the contents of the Accumulator in the Referenced Memory Location (RML). This replaces the previous value in the RML, but leaves the contents of the AC unchanged.
READ 101 Read a value from the Keyboard and store the value in the Referenced Memory Location (RML). This replaces the previous value in the RML.
DISPLAY 110 Display the contents of the Referenced Memory Location (RML) on the monitor screen. This leaves the contents of the RML unchanged.
JUMPIF 111 If the contents of the Accumulator (AC) are greater than zero, load the address of the Referenced Memory Location (RML) into the Program Counter (PC). This forces the program to jump to the RML on the next instruction. The contents of the AC are unchanged.
STOP 000 Halt the execution of the program. This is the end.