computer systems 2009-2010 week 6: the computer system alma whitfield
TRANSCRIPT
Computer Systems
2009-2010
Week 6: The Computer System
Alma Whitfield
2
What we shall do today The computer as a processor (Chptr 2, 3)
Input devices Processing Instructions Outputting
Computer components (Chptr 4) The BUS system Memory Secondary Storage
Computer system simulator (Chptr 14) Threebit
3
What is a computer ? Device that is told stuff INPUT Device that does stuff PROCESS Device that produces stuff OUTPUT Stuff ?
words pictures sounds numbers mouse movements joystick movements
4
Computer as processor Supermarket checkout
Stuff coming in
Stuff coming out
Stuff getting
processed
5
INPUT = WOOL
HUMAN BEING WITH KNITTING NEEDLES
OUTPUT = SOCKS
Human beings as processors Knitting
Stuff coming in
Stuff getting
processed
Stuff coming out
6
INPUT=WOOL
HUMAN BEING WITHKNITTING NEEDLES
OUTPUT=SOCKS KNITTING PATTERN
Processors need instructions knit 2, purl 1
Instructions
7
Another example Baking a cake
INPUT=INGREDIENTS
HUMAN BEING WITH KITCHEN
OUTPUT=CAKE RECIPE
Instructions
8
Aircraft controlled by computer
9
Airbus A320 First “fly-by-wire” commercial
airliner introduced 1988 Virtually all commercial airlines now
use fly-by-wire
10
Computers as processors Aircraft computer
Stuff getting
processed
Stuff coming in
Stuff coming out
11
Computers need instructions
Human with
kitchen
Recipe
Compare with
Hardware
Software
Programs
12
Early computers: Harvard Mark I
1944 55 feet long 8 feet high 5-tons Used by the US Navy for gunnery calculations In operation until 1959
PeopleComputer
13
Computer layout: old style
Everything plugged into processor Processor became known as
Central Processing Unit (CPU)
STORAGE DEVICE TO HOLD INSTRUCTIONS
PROCESSORINPUT
DEVICEOUTPUT DEVICE
INPUT OUTPUT
e.g. Keyboard e.g. Monitor
14
KEYBOARD CPU STORAGE DEVICE
MONITOR
INPUTOUTPUT
HARD DISC
Computer layout: new style
Bus(Bundle of wires)
Stuff coming in
Stuff coming out
Stuff getting processed
15
A desktop computer system: with fancy words
Input device
Output device
Processor inside system
box
16
Input devices mouse
• scanner
• keyboard
17
Output devices printer
• speakers
18
Storage devices This is where we store instructions
STORAGE DEVICE TO HOLD INSTRUCTIONS
PROCESSORINPUT
DEVICEOUTPUT DEVICE
INPUT OUTPUT
e.g. Keyboard e.g. Monitor
19
Storage device problems CPU can perform millions of
instructions per second Storage device needs to keep up
the supply of instructions Modern computers need to store
thousands of programs
20
Solution Use two kinds of storage device:
smaller, faster, expensive part
larger, slower, cheaper part
Main memory - very fast (purely electronic), expensive.
RAM
Secondary storage – slower, (electro-mechanical), cheaper.
e.g. hard disc, CD
21
Solution Keep the programs on the
secondary storage Copy a program into main memory
when we want the CPU to run it
22
Typical devices attached to the bus CD Drive Hard Disc Drive Floppy Disc Drive CPU RAM (Main memory) Monitor Keyboard Mouse
Can you classify them?
(a) input device
(b) output device
(c) storage device
(d) processor
23
Inside the system boxPower supply
Fan on top of CPU
Main memory
DVD and CD Drives
Hard disc
Slots for cardse.g.
Network card
Graphics card
Floppy disc drive
Motherboard(contains the
bus)
24
CD Drive Compact Disc
CD is a plastic disc coated with special optical material
also known as CD-ROM (Read Only Memory)
Data is read from it using a laser light inside a CD Drive
Replaced now by DVD which has more storage capacity
25
Hard disc drive
taking the lid off hard aluminium discs
coated with magnetizable material
26
Floppy disc drive Floppy disc is a cheap version of
the hard disc Made of plastic Low capacity Read by a floppy disc drive Very slow Rapidly becoming obsolete
27
CPU
Central processing unit carries out the instructions e.g. Intel Pentium e.g. AMD Pentium clone
Note gold plated legs
28
CPU
CPU installed with fan removed
29
CPU
CPU Socket on the
motherboard
30
RAM (Main memory)
Where programs are stored while they are running
Main memory card in slot on motherboard
31
RAM (Main memory) A main memory card
Note the gold plated connectors that will slot into
the computer’s bus on the motherboard
32
What have we learned so far this week Computer systems consist of devices
attached to a bus Devices include:
processor storage devices input and output devices
Computers execute sets of instructions stored in programs
Programs are copied from Secondary Storage to RAM before execution of instructions
33
KEYBOARD CPU STORAGE DEVICE
MONITOR
INPUTOUTPUT
HARD DISC
Computer layout
Bus(Bundle of wires)
Stuff coming in
Stuff coming out
Stuff getting processed
34
Computer system simulator
35
KEYBOARD CPU STORAGE DEVICE
MONITOR
INPUTOUTPUT
HARD DISC
36
3-bit Simulator Demo A program is a collection of
instructions Instructions are stored in main
memory (RAM) Instructions are fetched into CPU
(Central Processing Unit) Instructions are executed by CPU
possibly resulting in new data being placed in main memory or moved elsewhere
37
3-bit Instruction fetching and executing
done repeatedly This is known as the fetch-execute
cycle
38
A computer instruction Instructions are represented at patterns of
0s and 1s 0s and 1s are binary digits binary digit abbreviated to bit
In 3-bit each instruction consists of 8 bits In a standard PC, instructions consists of 32 bits In a higher end machine, instructions can
consist of 64 bits In all cases an instruction has two parts:
operation code (usually abbreviated to op-code)
operand
39
A computer instruction op-code
what the instruction will do e.g. add, multiply, move like a verb in English grammar
operand what the instruction will do it to e.g a number like a noun in English grammar
40
A computer instruction in 3-bit
0 1 0 0 1 1 0 1
41
A computer instruction in 3-bit
0 1 0 0 1 1 0 1
8 bits
42
A computer instruction in 3-bit
0 1 0 0 1 1 0 1
8 bits
op-code
43
A computer instruction in 3-bit
op-code is 3 bits long – hence the name 3-bit for the simulator
operand is 5 bits long
0 1 0 0 1 1 0 1
8 bits
op-code
operand
44
8 available 3 bit op codesMnemonic
Brief meaning
000 STP halt
001 LDD load accumulator direct
010 LDI load accumulator immediate
011 STD store accumulator direct
100 ADD add to accumulator
101 SUB subtract from accumulator
110 JMP jump to next instruction
111 JEZ jump to next instruction if contents of accumulator is zero
45
8 available 3 bit op codes Instructions carry out very simple
operations such as adding, storing Simplicity is not just a feature of 3-
bit – true for all kinds of computer system
A program such as a word processor may have millions of them combined to do useful things
46
Lets look at the more obvious ones first! ADD – Will add the contents of the
memory address specified to whatever is in the ACCUMULATOR
SUB - Will subtract the contents of the memory address specified from the ACCUMULATOR
STP – Will stop the execution of the instructions
47
The CPU Every CPU has at least 3 registers
Instruction register
(IR)
Accumulator
(AC)
Program counter
(PC)
48
The CPU Every CPU has at least 3 registers
Instruction register
(IR)
Stores the current instruction when it is fetched from the main memory
Stored here so that the CPU can identify it and carry out the appropriate actions
49
The CPU Every CPU has at least 3 registers
Accumulator
(AC)Stores data values fetched from main memory that may be:
• added to
• subtracted from
• moved elsewhere in main memory
50
The CPU Every CPU has at least 3 registers
Program counter
(PC)
Contains of the address of the next instruction to be fetched from main memory when current instruction has completed its execution
51
3-bit CPU Controls IR - clear the Instruction Register AC - set the Accumulator to 0 PC - set the Program Counter to 0 Run - start the fetch execute cycle Step - fetch and execute the next
instruction (whose address is in the PC)
Stop – stop fetching and executing instructions after current instruction has completed
52
Main Memory Program instructions are stored in
main memory during program execution
Main memory was loaded from hard disk when the program was invoked
Instructions are fetched one at a time from main memory into the CPU to be executed
53
3-bit Main Memory Our simulator has 32 Memory Locations
operands have 5 bits. These can be used to represent 32 different patterns of 0 and 1. Each different pattern can be used as an address to uniquely identify a memory location
Each location can store 8 bits i.e. one instruction 8 bits is also known as 1 byte
There is also enough memory in each location to store the ASCII code for a character
ASCII is an 8 bit code used to represent alphabetical characters, digits and other items
e.g. 65 is ASCII code for ‘A’ Real Memory has billions of locations.
54
3-bit Main Memory Notice that some
of the memory locations have red lines coming from them.
This is to signify that that section of the memory has been reserved for use with the Video Card
55
Back to the Instructions ADD – Will add the contents of the
memory address specified to the accumulator
SUB - Will subtract the contents of the memory address specified from the accumulator
It is very important to realise now that when you specify ADD x. The x refers to a memory location’s address. Not a value!
56
For Example Question –
What will the AC become once the program has finished executing?
Address 16 holds value 10.
Address 10 holds value 2
57
For example Demo
ADD 16 causes contents of location 16 (which is 14) to be placed in the Accumulator
ADD 10 causes contents of location 10 (which is 5) to be added to contents of the Accumulator giving 19
58
Lets take a look at the other instructions LDD x
Copies contents of location x into the AC – loading the accumulator
STD x Copies the contents of the AC to
location x – storing the accumulator
59
LDD Given the
program in memory, what will the accumulator’s contents be after the program has executed?
Answer 25
60
STD Given the
following program.
What will happen?
61
LDI LDI is similar to LDD with one key
difference.
LDI 27 will load 27 into theaccumulator
LDD 27 will load contents of address
27 into the accumulator