Download presentation
Presentation is loading. Please wait.
1
Computer Hardware What goes on inside?
3
Deeper
5
Not that deep
6
A simple Computer Central Processing Unit CPU Performs all calculations and decisions Add, Subtract, … >, <, == decide what to do next
7
A simple Computer Central Processing Unit CPU Memory Stores most information Memory is a large array of integers
8
Memory - array of integers How does it store text? How does it store images? How does it store audio? How does it store a program?
9
A simple Computer Central Processing Unit CPU Memory Address Wires that pass the index of the location in memory that the CPU wants to get or change
10
A simple Computer Central Processing Unit CPU Memory Address Wires that pass the index of the location in memory that the CPU wants to get or change 0 1 0 0 1 0
11
A simple Computer Central Processing Unit CPU Memory Address Number of wires = number of bits Number of bits = range of possible indexes = total possible memory 0 1 0 0 1 0
12
A simple Computer Central Processing Unit CPU Memory Address Twice as much memory adds how many more address wires? 1 more 0 1 0 0 1 0
13
A simple Computer Central Processing Unit CPU Memory Address Data Wires that pass numbers from CPU to Memory or from Memory to CPU
14
A simple Computer Central Processing Unit CPU Memory RAM Address Data RAM - Random Access Memory is the main memory of a computer. The size of RAM is the length of the array
15
How to represent a program in memory Program is a series of simple instructions –Each instruction is an integer CPU –Goes to a location in memory –Gets an instruction –Does what the instruction says –Moves to the next instruction Does this millions of times per second
16
A simple fake computer CPU
17
Program Counter - address (index) of the next instruction
18
Registers private memory for the CPU
19
Every instruction has a number OpCodes 0 - Halt 1 - Load 2 - Store 3 - Add 4 - Subtract 5 - Divide 6 - Multiply 7 - Is Greater Than 0? 8 - Goto 9 - Branch If Greater Than 0!
20
Instruction Format: Digit 1 OpCode Digit 2 Register Digit 3-4 Memory Address OpCodes 0 - Halt 1 - Load 2 - Store 3 - Add 4 - Subtract 5 - Divide 6 - Multiply 7 - Is Greater Than 0? 8 - Goto 9 - Branch If Greater Than 0!
21
Instruction Format: Digit 1 OpCode Digit 2 Register Digit 3-4 Memory Address OpCodes 0 - Halt 1 - Load 2 - Store 3 - Add 4 - Subtract 5 - Divide 6 - Multiply 7 - Is Greater Than 0? 8 - Goto 9 - Branch If Greater Than 0! 3 1 10
22
Instruction Format: Digit 1 OpCode Digit 2 Register Digit 3-4 Memory Address OpCodes 0 - Halt 1 - Load 2 - Store 3 - Add 4 - Subtract 5 - Divide 6 - Multiply 7 - Is Greater Than 0? 8 - Goto 9 - Branch If Greater Than 0! 3 1 10
23
Reg[1]=Reg[1]+Mem[10] Instruction Format: Digit 1 OpCode Digit 2 Register Digit 3-4 Memory Address OpCodes 0 - Halt 1 - Load 2 - Store 3 - Add 4 - Subtract 5 - Divide 6 - Multiply 7 - Is Greater Than 0? 8 - Goto 9 - Branch If Greater Than 0! 3 1 10
24
? Instruction Format: Digit 1 OpCode Digit 2 Register Digit 3-4 Memory Address OpCodes 0 - Halt 1 - Load 2 - Store 3 - Add 4 - Subtract 5 - Divide 6 - Multiply 7 - Is Greater Than 0? 8 - Goto 9 - Branch If Greater Than 0! 4 2 30
25
Reg[2]=Reg[2]-Mem[30] Instruction Format: Digit 1 OpCode Digit 2 Register Digit 3-4 Memory Address OpCodes 0 - Halt 1 - Load 2 - Store 3 - Add 4 - Subtract 5 - Divide 6 - Multiply 7 - Is Greater Than 0? 8 - Goto 9 - Branch If Greater Than 0! 4 2 30
26
A simple program 1 0 07 Load location 7 into register 0 Reg[0]=Mem[7] PC = PC+1
27
A simple program 1 2 08 Load location 8 into register 2 Reg[2]=Mem[8] PC = PC+1
28
A simple program 3 0 07 Add location 7 to register 0 Reg[0]=Reg[0]+Mem[7] PC = PC+1
29
A simple program 8 2 00 GOTO the address stored in register 2 PC = Reg[2]
30
A simple program 3 0 07 Add location 7 to register 0 Reg[0]=Reg[0]+Mem[7] PC=PC+1
31
A simple program 8 2 00 GOTO the address stored in register 2 PC = Reg[2]
32
A simple program 3 0 07 Add location 7 to register 0 Reg[0]=Reg[0]+Mem[7] PC=PC+1
33
Clock speed of a processor Number of instructions per second that can be performed 100 MHz = 100 Million times per second 1.5 GHz = 1.5 Billion instructions per second
34
So what is a program? A file of bytes Operating system copies the file into memory –When select the program from Start menu –When you double click on the program Operating system sets PC to address of first byte of the program in memory Program begins to run
35
Programs and Data Program (instructions) Data What is the difference? If the PC points to it then it is an instruction
36
Review CPU - Central Processing Unit –Does calculating and deciding Memory - RAM –Stores data and programs –Array of integers –Size of RAM = the length of this array
37
Review Program –List of instructions –Each instruction is an integer that the CPU decodes –Program counter (PC) is the address of the next instruction Copy program from file into memory –Set PC to start of the program
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.