View
222
Download
0
Category
Tags:
Preview:
Citation preview
Data ManipulationData Manipulation
CSC 2001CSC 2001
OverviewOverview
Computer ArchitectureMachine Language
Computer ArchitectureMachine Language
DisclaimerDisclaimer
There is A LOT more detail to computer architecture & machine language than what I’ll go over today.
That detail is of great interest, but beyond the scope of this class.
Basically, this is a simplified, high-level view. We can explore more outside of class if you are interested.
There is A LOT more detail to computer architecture & machine language than what I’ll go over today.
That detail is of great interest, but beyond the scope of this class.
Basically, this is a simplified, high-level view. We can explore more outside of class if you are interested.
General approachGeneral approach
Build up a basic understanding of architecture and begin to look at how it gets used to manipulate data.
Build up a basic understanding of architecture and begin to look at how it gets used to manipulate data.
Computer ArchitectureComputer Architecture
Inputdevice Output
device
Auxiliarystoragedevice
Central Processing Unit
Control Unit
Arithmetic/logicunit
Memory unit
Computer ArchitectureComputer Architecture
Central Processing Unit
Control Unit
Arithmetic/logicunit
Memory unit
Bus
Central Processing Unit (CPU)
Central Processing Unit (CPU)
Central Processing Unit
Control Unit
Arithmetic/logicunit
• Pentium (Intel)• PowerPC (Motorola & IBM)• SPARC
CPUCPU
CPUCPU
~55 milliontransistors
Control UnitControl Unit
Central Processing Unit
Control Unit
Arithmetic/logicunit
Memory unit
Bus
Control UnitControl Unit
Control Unit
Circuits for coordinatingthe machine’s activities
Arithmetic/Logic UnitArithmetic/Logic Unit
Central Processing Unit
Control Unit
Arithmetic/logicunit
Memory unit
Bus
Arithmetic/Logic UnitArithmetic/Logic Unit
Arithmetic/logicunit
Circuits for performingdata manipulation.
MemoryMemory
Main memoryRegistersCache memory
Main memoryRegistersCache memory
RegistersRegisters
The CPU circuitry has to have a place to hold data that it is working with.
Very fast accessUse:
Control unit transfers data from memory to registers.
Informs the ALU where the data is.Activates the ALUTells it which register to store the result in
The CPU circuitry has to have a place to hold data that it is working with.
Very fast accessUse:
Control unit transfers data from memory to registers.
Informs the ALU where the data is.Activates the ALUTells it which register to store the result in
Example: Adding two numbers
Example: Adding two numbers
Load a register with one value from main memory (control unit/main memory/bus)
Load another register with a value from main memory (control unit/main memory/bus)
Tell the ALU to add two specific registers and where to store the result (control unit/ALU)
Do the addition and store the result (ALU)
Copy the result to main memory (control unit/main memory/bus)
Load a register with one value from main memory (control unit/main memory/bus)
Load another register with a value from main memory (control unit/main memory/bus)
Tell the ALU to add two specific registers and where to store the result (control unit/ALU)
Do the addition and store the result (ALU)
Copy the result to main memory (control unit/main memory/bus)
Cache memoryCache memory
Purpose:Store pertinent part of main memory
on CPU itself for faster access.Level 1 (L1/primary):
typically small, but on CPULevel 2 (L2/secondary/backside):
small compared to main memory, larger than L1 cache, not on CPU
Purpose:Store pertinent part of main memory
on CPU itself for faster access.Level 1 (L1/primary):
typically small, but on CPULevel 2 (L2/secondary/backside):
small compared to main memory, larger than L1 cache, not on CPU
BusBus
Central Processing Unit
Control Unit
Arithmetic/logicunit
Memory unit
Bus
BusBus
Central Processing Unit
Memory unit
Bus
Physically transfersdata between CPUand main memory
Early programmingEarly programming
Hardwiring (rewiring) the control unit.
Hardwiring (rewiring) the control unit.
BreakthroughBreakthrough
Program can be encoded and stored like data.
Generalize control unit to read and execute instructions.
A computer’s set of instructions and the encoding system comprise a machine language.
Program can be encoded and stored like data.
Generalize control unit to read and execute instructions.
A computer’s set of instructions and the encoding system comprise a machine language.
Machine LanguageMachine Language
Instruction set:CPU dependentUsually relatively smallTwo philosophies:
Reduced Instruction Set Computer (RISC)minimal set of instructions; efficient and fastexample?
Complex Instruction Set Computer (CISC) larger set; easy to program (at the machine level);
one CISC instruction = several RISC instructionsexample?
Instruction set:CPU dependentUsually relatively smallTwo philosophies:
Reduced Instruction Set Computer (RISC)minimal set of instructions; efficient and fastexample?
Complex Instruction Set Computer (CISC) larger set; easy to program (at the machine level);
one CISC instruction = several RISC instructionsexample?
Instruction categoriesInstruction categories
Data transferArithmetic/logicControl
Data transferArithmetic/logicControl
Data transferData transfer
Movement of dataLOAD or STORE
Movement of dataLOAD or STORE
Arithmetic/logicArithmetic/logic
AND, OR, XOR, SHIFT, ROTATEAND, OR, XOR, SHIFT, ROTATE
ControlControl
directs the execution of programJUMP to another part of the
program
directs the execution of programJUMP to another part of the
program
ExampleExample
Appendix CReview machine architectureReview syntax of languageReview semantics of language
ExampleFigure 2.2/Figure 2.7
Appendix CReview machine architectureReview syntax of languageReview semantics of language
ExampleFigure 2.2/Figure 2.7
Another exampleAnother example
Store the ASCII letter A in memory location 56.
Store the ASCII letter B in memory location 112.
Swap the bit patterns in memory locations 56 and 112
Halt
Store the ASCII letter A in memory location 56.
Store the ASCII letter B in memory location 112.
Swap the bit patterns in memory locations 56 and 112
Halt
First stepsFirst steps
ASCII A?01000001 (Hex: 0100 0001 = 41)
ASCII B?01000010 (Hex: 0100 0010 = 42)
Hex 56?38 (3*16 + 8 = 48 + 8 = 56)
Hex 112?70 (7*16 + 0 = 112)
ASCII A?01000001 (Hex: 0100 0001 = 41)
ASCII B?01000010 (Hex: 0100 0010 = 42)
Hex 56?38 (3*16 + 8 = 48 + 8 = 56)
Hex 112?70 (7*16 + 0 = 112)
ProgramProgram
Store the ASCII letter A in memory location 56.21413138
Store the ASCII letter B in memory location 112.21423170
Store the ASCII letter A in memory location 56.21413138
Store the ASCII letter B in memory location 112.21423170
Program (continued)Program (continued)
Swap the bit patterns in memory locations 56 and 1121138127031703238
HaltC000
Swap the bit patterns in memory locations 56 and 1121138127031703238
HaltC000
Final programFinal program
21413138214231701138127031703238C000
21413138214231701138127031703238C000
Simple program completelystorable as data.
Practice problemsPractice problems
If you find this difficult, do some of the practice problems on page 82 (answers start on page 518).
Do enough to either convince yourself you understand or find the places you are having problems!!
If you find this difficult, do some of the practice problems on page 82 (answers start on page 518).
Do enough to either convince yourself you understand or find the places you are having problems!!
Recommended