33
Data Manipulation CSC 2001

Data Manipulation CSC 2001. Overview Computer Architecture Machine Language Computer Architecture Machine Language

Embed Size (px)

Citation preview

Page 1: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

Data ManipulationData Manipulation

CSC 2001CSC 2001

Page 2: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

OverviewOverview

Computer ArchitectureMachine Language

Computer ArchitectureMachine Language

Page 3: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine 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.

Page 4: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

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.

Page 5: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

Computer ArchitectureComputer Architecture

Inputdevice Output

device

Auxiliarystoragedevice

Central Processing Unit

Control Unit

Arithmetic/logicunit

Memory unit

Page 6: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

Computer ArchitectureComputer Architecture

Central Processing Unit

Control Unit

Arithmetic/logicunit

Memory unit

Bus

Page 7: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

Central Processing Unit (CPU)

Central Processing Unit (CPU)

Central Processing Unit

Control Unit

Arithmetic/logicunit

• Pentium (Intel)• PowerPC (Motorola & IBM)• SPARC

Page 8: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

CPUCPU

Page 9: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

CPUCPU

~55 milliontransistors

Page 10: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

Control UnitControl Unit

Central Processing Unit

Control Unit

Arithmetic/logicunit

Memory unit

Bus

Page 11: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

Control UnitControl Unit

Control Unit

Circuits for coordinatingthe machine’s activities

Page 12: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

Arithmetic/Logic UnitArithmetic/Logic Unit

Central Processing Unit

Control Unit

Arithmetic/logicunit

Memory unit

Bus

Page 13: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

Arithmetic/Logic UnitArithmetic/Logic Unit

Arithmetic/logicunit

Circuits for performingdata manipulation.

Page 14: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

MemoryMemory

Main memoryRegistersCache memory

Main memoryRegistersCache memory

Page 15: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

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

Page 16: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

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)

Page 17: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

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

Page 18: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

BusBus

Central Processing Unit

Control Unit

Arithmetic/logicunit

Memory unit

Bus

Page 19: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

BusBus

Central Processing Unit

Memory unit

Bus

Physically transfersdata between CPUand main memory

Page 20: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

Early programmingEarly programming

Hardwiring (rewiring) the control unit.

Hardwiring (rewiring) the control unit.

Page 21: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

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.

Page 22: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  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?

Page 23: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

Instruction categoriesInstruction categories

Data transferArithmetic/logicControl

Data transferArithmetic/logicControl

Page 24: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

Data transferData transfer

Movement of dataLOAD or STORE

Movement of dataLOAD or STORE

Page 25: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

Arithmetic/logicArithmetic/logic

AND, OR, XOR, SHIFT, ROTATEAND, OR, XOR, SHIFT, ROTATE

Page 26: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

ControlControl

directs the execution of programJUMP to another part of the

program

directs the execution of programJUMP to another part of the

program

Page 27: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

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

Page 28: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

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

Page 29: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

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)

Page 30: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

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

Page 31: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

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

Page 32: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

Final programFinal program

21413138214231701138127031703238C000

21413138214231701138127031703238C000

Simple program completelystorable as data.

Page 33: Data Manipulation CSC 2001. Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language

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!!