cs1001 lecture 3. overview computer science; algorithms computer science; algorithms...

25
CS1001 CS1001 Lecture 3 Lecture 3

Post on 21-Dec-2015

236 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

CS1001CS1001

Lecture 3Lecture 3

Page 2: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

OverviewOverview

Computer Science; AlgorithmsComputer Science; Algorithms Multidisciplinary HeritageMultidisciplinary Heritage Evolution of Machine ArchitectureEvolution of Machine Architecture Modern Machine ArchitectureModern Machine Architecture Some SimulatorsSome Simulators Homework 1Homework 1

Page 3: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

GoalsGoals

Define Computer Science; what Define Computer Science; what things are part of computer things are part of computer science?science?

Define “Algorithm”Define “Algorithm” Understand origins of Mechanical Understand origins of Mechanical

ComputingComputing How did mechanical computing How did mechanical computing

influence modern computer influence modern computer architecture?architecture?

Page 4: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Goals (2)Goals (2)

Understand the components of Understand the components of modern machine architecturemodern machine architecture

Examine some basic assembly Examine some basic assembly languageslanguages

Learn how to codify solutions Learn how to codify solutions using a given set of actionsusing a given set of actions

Page 5: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

AssignmentsAssignments

Brookshear, Ch 2 (Read)Brookshear, Ch 2 (Read) Read linked documents on these Read linked documents on these

slides (slides will be posted in slides (slides will be posted in courseworks)courseworks)

Check your email and Check your email and courseworks courseworks (http://courseworks.columbia.edu)(http://courseworks.columbia.edu)

Page 6: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

What is an Algorithm?What is an Algorithm?

““An ordered set of unambiguous, An ordered set of unambiguous, executable steps that define a executable steps that define a terminatingterminating activity” activity”

Page 7: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

PythagorasPythagoras

The natural world and whole The natural world and whole number ratiosnumber ratios

Credited with “discovering” Credited with “discovering” irrational numbers, but that’s up irrational numbers, but that’s up for debatefor debate

http://www-gap.dcs.st-and.ac.uk/~history/Mathematicians/Pythagorahttp://www-gap.dcs.st-and.ac.uk/~history/Mathematicians/Pythagoras.htmls.html

Page 8: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

PascalPascal

Many contributions to mathematicsMany contributions to mathematics A primitive adder, like an odomoter, called A primitive adder, like an odomoter, called

the “Pascaline”the “Pascaline” Economics limited its appeal (too Economics limited its appeal (too

expensive)expensive) http://http://lecture.eingang.org/pascal.htmllecture.eingang.org/pascal.html

Page 9: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Gottfried Wilhelm von Gottfried Wilhelm von

LeibnizLeibniz 1666 as 1666 as Dissertatio de arte combinatoriaDissertatio de arte combinatoria (Dissertation on (Dissertation on

the combinatorial art) the combinatorial art) (Mozart/Dice Games) (Mozart/Dice Games) http://http://www.worldvillage.com/jchuang/Music/Dice/dice.cgiwww.worldvillage.com/jchuang/Music/Dice/dice.cgi

Machine below: business success; add, subtract, mult, Machine below: business success; add, subtract, mult, divide. There was a primitive “language” for divide. There was a primitive “language” for programming this device (setting wheel positions)programming this device (setting wheel positions)

http://www-gap.dcs.st-and.ac.uk/~history/Mathematicians/Leibniz.htmlhttp://www-gap.dcs.st-and.ac.uk/~history/Mathematicians/Leibniz.html

Page 10: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Charles BabbageCharles Babbage

Designed a machine Designed a machine (Difference Engine) (Difference Engine) capable of performing capable of performing a calculation many a calculation many times over (useful for times over (useful for limits, logs, etc)limits, logs, etc)

Steam Powered; only Steam Powered; only capable of performing capable of performing one type of operation one type of operation without changing the without changing the gears on the machinegears on the machine

Page 11: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Charles Babbage (2)Charles Babbage (2)

Analytical Engine – A generic machine Analytical Engine – A generic machine (never built) that was capable of (never built) that was capable of reading instructions from punched reading instructions from punched cards.cards.

This is the basis of the modern This is the basis of the modern instruction set/execution architectureinstruction set/execution architecture

Ada Lovelace is credited with Ada Lovelace is credited with designing the language for the designing the language for the analytical engineanalytical engine

Page 12: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Foundations of CSFoundations of CS(To be continued)(To be continued) David Hilbert – Infinity, is David Hilbert – Infinity, is

mathematics consistent?mathematics consistent? Kurt Goedel – No formal system is Kurt Goedel – No formal system is

consistentconsistent Alan Turing – Demonstrated a real Alan Turing – Demonstrated a real

problem in a formal system that problem in a formal system that no machine could solveno machine could solve

Turing MachinesTuring Machines

Page 13: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

The Von Neumann The Von Neumann ArchitectureArchitecture The “Shared Program Technique”The “Shared Program Technique”

– Hardware need not be fixed to solve Hardware need not be fixed to solve any problem. Given a simple hardware any problem. Given a simple hardware design, one can program that hardware design, one can program that hardware to accomplish any taskto accomplish any task

““Conditional Control Transfer”Conditional Control Transfer”– Any program can be written with simple Any program can be written with simple

IF/THEN decisions plus Jumps (GOTOs)IF/THEN decisions plus Jumps (GOTOs)

Page 14: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Modern SystemsModern Systems

Memory (a program Memory (a program isis data) to data) to store volatile informationstore volatile information

Hardware that reads the program Hardware that reads the program and manipulates associated data and manipulates associated data (or itself, like a virus)(or itself, like a virus)

Critical idea: A program Critical idea: A program isis data data

Page 15: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Figure 2.8: The machine Figure 2.8: The machine cyclecycle

Page 16: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Figure 2.1: Figure 2.1: CPU and main memory CPU and main memory connected connected

via a busvia a bus

Page 17: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Figure 2.4: Figure 2.4: The architecture of the The architecture of the machine machine described in Appendix Cdescribed in Appendix C

Page 18: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Figure 2.5: Figure 2.5: The composition of an The composition of an instruction instruction for the machine in for the machine in Appendix CAppendix C

Page 19: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Figure 2.6: Decoding Figure 2.6: Decoding the instruction 35A7the instruction 35A7

Page 20: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Figure 2.10: Figure 2.10: The program from Figure 2.7The program from Figure 2.7stored in main memory ready for stored in main memory ready for executionexecution

Page 21: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Figure 2.11: Figure 2.11: Performing the fetch step Performing the fetch step of the of the machine cycle (continued)machine cycle (continued)

Page 22: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

Figure 2.11: Figure 2.11: Performing the fetch step Performing the fetch step of the of the machine cyclemachine cycle

Page 23: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

A simple instruction A simple instruction setset MOVR <id>MOVR <id> MOVL <id>MOVL <id> MOVU <id>MOVU <id> LABEL <labelid>LABEL <labelid> GOTO <labelid>GOTO <labelid>

Page 24: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

SimulatorsSimulators

Modern ArchitecturesModern Architectures– IntelIntel– Apple/Motorola PowerApple/Motorola Power– ARMARM– Simulation/EmulationSimulation/Emulation

Page 25: CS1001 Lecture 3. Overview Computer Science; Algorithms Computer Science; Algorithms Multidisciplinary Heritage Multidisciplinary Heritage Evolution of

HomeworkHomework

The challenge – expressing a process using a fixed The challenge – expressing a process using a fixed number of operationsnumber of operations

The problem:The problem:Two creatures (C1 and C2) are to be parachuted onto Two creatures (C1 and C2) are to be parachuted onto

random locations on an infinite line. When they land, random locations on an infinite line. When they land, their parachutes detach and remain where they are. their parachutes detach and remain where they are. The robots may be programmed from the following The robots may be programmed from the following instruction set:instruction set:

Go left one unit Go left one unit (MOVL <C1 or C2>)(MOVL <C1 or C2>)Go right one unit Go right one unit (MOVR <C1 or C2>)(MOVR <C1 or C2>)LabelLabel (LABEL <labelid>)(LABEL <labelid>)Skip next instruction unless there is a parachute hereSkip next instruction unless there is a parachute here

(SKIPPAR)(SKIPPAR)Go to labelGo to label (GOTO <labelid>)(GOTO <labelid>)Each instruction takes one cycle to execute.Each instruction takes one cycle to execute.Program the robots to collide.Program the robots to collide.