View
216
Download
1
Category
Preview:
Citation preview
Introduction to Computers Bina © 1998 Liran & Ofir
Programming in
C
Introduction to Computers Bina © 1998 Liran & Ofir
Introduction to ComputersIntroduction to ComputersIntroduction to ComputersIntroduction to Computers
Programming in Programming in
CC
sophir@techst02.technion.ac.il
Introduction to Computers Bina © 1998 Liran & Ofir
Central Processing Unit
Basic Model of ComputersBasic Model of ComputersBasic Model of ComputersBasic Model of Computers
Control Processing Unit (CPU)Control Processing Unit (CPU)
Executes ProgramsExecutes Programs
Program = Program = A Sequence of MachineA Sequence of Machine InstructionsInstructions
Introduction to Computers Bina © 1998 Liran & Ofir
Central Processing Unit
Basic Model of ComputersBasic Model of ComputersBasic Model of ComputersBasic Model of Computers
Control Unit Control Unit (CU)Control Unit (CU)
Determines which instructionDetermines which instruction must be executed next.must be executed next.
Retrieves the needed data fromRetrieves the needed data from the memorythe memory
Coordinates the execution Coordinates the execution of the instructionof the instruction
Introduction to Computers Bina © 1998 Liran & Ofir
Central Processing Unit
Control Unit
Basic Model of ComputersBasic Model of ComputersBasic Model of ComputersBasic Model of Computers
ArithmeticLogic Unit
Arithmetic Logic Unit (ALU)Arithmetic Logic Unit (ALU)
Performs Simple operations:Performs Simple operations:
Add,Add,
Subtract,Subtract,
Multiply,Multiply,
......
Introduction to Computers Bina © 1998 Liran & Ofir
Central Processing Unit
Basic Model of ComputersBasic Model of ComputersBasic Model of ComputersBasic Model of Computers
Control Unit
ArithmeticLogic Unit
Registers
RegistersRegisters
Fast memory used to holdFast memory used to hold the intermediate result ofthe intermediate result of operationsoperations
Introduction to Computers Bina © 1998 Liran & Ofir
Central Processing Unit
Basic Model of ComputersBasic Model of ComputersBasic Model of ComputersBasic Model of Computers
Memory
Control Unit
ArithmeticLogic Unit
Registers
Memory (RAM)Memory (RAM) holds data andholds data and instructionsinstructions
Random AccessRandom Access
volatilevolatile
Introduction to Computers Bina © 1998 Liran & Ofir
Central Processing Unit
Memory
Basic Model of ComputersBasic Model of ComputersBasic Model of ComputersBasic Model of Computers
Disk
Control Unit
ArithmeticLogic Unit
Registers
DiskDisk holds data andholds data and programsprograms
nonvolatilenonvolatile
Introduction to Computers Bina © 1998 Liran & Ofir
Central Processing Unit
Memory
Basic Model of ComputersBasic Model of ComputersBasic Model of ComputersBasic Model of Computers
Disk
Control Unit
ArithmeticLogic Unit
Registers
And other peripheralsAnd other peripherals
Display
Printer
. . .
Introduction to Computers Bina © 1998 Liran & Ofir
Central Processing Unit
Memory
Basic Model of ComputersBasic Model of ComputersBasic Model of ComputersBasic Model of Computers BusBus
Data passage wayData passage way between parts ofbetween parts of the computer the computer
DisplayDisk
Control Unit
ArithmeticLogic Unit
RegistersPrinter
. . .
Introduction to Computers Bina © 1998 Liran & Ofir
CPUCPUCPUCPU
Repeatedly does the following:Repeatedly does the following:
Gets the next instruction from the memoryGets the next instruction from the memory
Gets the data required to execute the instruction Gets the data required to execute the instruction
from the memoryfrom the memory
Performs the instructionPerforms the instruction
Stores the result in the memoryStores the result in the memory
Introduction to Computers Bina © 1998 Liran & Ofir
Machine InstructionsMachine InstructionsMachine InstructionsMachine Instructions
Add the content of memory location 6 to Add the content of memory location 6 to the content of memory location 7 and store the content of memory location 7 and store the result in memory location 8.the result in memory location 8.
Load 6Load 6
Add 7Add 7
Store 8Store 8
EndEnd
Introduction to Computers Bina © 1998 Liran & Ofir
Machine InstructionsMachine InstructionsMachine InstructionsMachine Instructions
CPU
Memory
1
67
32
8
45
51
Load 6Add 7Store 8End
Introduction to Computers Bina © 1998 Liran & Ofir
Machine InstructionsMachine InstructionsMachine InstructionsMachine Instructions
CPU
Memory
1
67
32
8
45
51
Load 6 Load 6Add 7Store 8End
Introduction to Computers Bina © 1998 Liran & Ofir
Machine InstructionsMachine InstructionsMachine InstructionsMachine Instructions
CPU
Memory
1
67
32
8
45
51
Load 6 Load 6Add 7Store 8End
1
Introduction to Computers Bina © 1998 Liran & Ofir
Machine InstructionsMachine InstructionsMachine InstructionsMachine Instructions
CPU
Memory
1
67
32
8
45
51
Load 6Add 7Store 8End
1
Add 7
Introduction to Computers Bina © 1998 Liran & Ofir
Machine InstructionsMachine InstructionsMachine InstructionsMachine Instructions
CPU
Memory
1
67
32
8
45
51
Load 6Add 7Store 8End
1 5
Add 7
Introduction to Computers Bina © 1998 Liran & Ofir
Machine InstructionsMachine InstructionsMachine InstructionsMachine Instructions
CPU
Memory
+
1
67
32
8
45
51
Load 6Add 7Store 8End
1 5
Add 7
Introduction to Computers Bina © 1998 Liran & Ofir
Machine InstructionsMachine InstructionsMachine InstructionsMachine Instructions
CPU
Memory
+
1
67
32
8
45
51
Add 7 Load 6Add 7Store 8End
1 5
6
Introduction to Computers Bina © 1998 Liran & Ofir
Machine InstructionsMachine InstructionsMachine InstructionsMachine Instructions
CPU
Memory
+
1
67
32
8
45
51
Load 6Add 7Store 8End
1 5
6
Store 8
Introduction to Computers Bina © 1998 Liran & Ofir
Machine InstructionsMachine InstructionsMachine InstructionsMachine Instructions
CPU
Memory
+
1
67
32
8
45
51
6
Store 8 Load 6Add 7Store 8End
1 5
6
Introduction to Computers Bina © 1998 Liran & Ofir
MemoryMemoryMemoryMemory
A Sequence of Memory CellsA Sequence of Memory Cells
(Words)(Words)Memory
Word
Introduction to Computers Bina © 1998 Liran & Ofir
WordWordWordWord
A Sequence of 4 A Sequence of 4 BytesBytes
Word
Byte 0 Byte 3Byte 2Byte 1
Introduction to Computers Bina © 1998 Liran & Ofir
Byte 0 Byte 3Byte 2Byte 1
ByteByteByteByte
A Sequence of 8 A Sequence of 8 BitsBits
Word
Introduction to Computers Bina © 1998 Liran & Ofir
BitBitBitBit
A switch capable of being in one of two A switch capable of being in one of two states:states:
0 1 2 3 4 5 6 7 28 2930 31
Word
On state: Represents 1On state: Represents 1
Off state: Represents 0Off state: Represents 0
0 0 . . .1 1 1 10 0 0 1 1 1
Introduction to Computers Bina © 1998 Liran & Ofir
Decimal NumbersDecimal NumbersDecimal NumbersDecimal Numbers
Each digit is:Each digit is:
0, 1, 2, 3, 4, 5, 6, 7, 8, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9
453 => 3x10453 => 3x1000 + 5x10 + 5x1011 + 4x10 + 4x1022
Introduction to Computers Bina © 1998 Liran & Ofir
Binary NumbersBinary NumbersBinary NumbersBinary Numbers
Each digit is:Each digit is:
0, 10, 1
101 => 1x2101 => 1x200 + 0x2 + 0x211 + 1x2 + 1x222 => 5 => 5
Introduction to Computers Bina © 1998 Liran & Ofir
Ex - Decimal NumbersEx - Decimal NumbersEx - Decimal NumbersEx - Decimal Numbers
Each digit is:Each digit is:
0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,A ,B ,C ,D ,E ,F0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,A ,B ,C ,D ,E ,F 1E3 => 3x161E3 => 3x1600 + 14x16 + 14x1611 + 1x16 + 1x1622 => 343 => 343
Recommended