26
CS 271 Summer CS 271 Summer 2010 2010 Computer Architecture and Assembly Language Computer Architecture and Assembly Language MTWRF MTWRF 11:00 – 11:50 PM 11:00 – 11:50 PM STAG 106 STAG 106 Instructor: Instructor: Joe Crop Joe Crop Office hours Office hours (KEC 1130): (KEC 1130): Tuesday: 2:00 - 3:00 pm Tuesday: 2:00 - 3:00 pm Thursday: 2:00 - 3:00 pm Thursday: 2:00 - 3:00 pm Other times by appointment Other times by appointment

CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Embed Size (px)

Citation preview

Page 1: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

CS 271 SummerCS 271 Summer 2010 2010 Computer Architecture and Assembly Computer Architecture and Assembly

LanguageLanguage MTWRFMTWRF 11:00 – 11:50 PM11:00 – 11:50 PM

STAG 106STAG 106

Instructor:Instructor: Joe CropJoe CropOffice hoursOffice hours (KEC 1130): (KEC 1130):

Tuesday: 2:00 - 3:00 pmTuesday: 2:00 - 3:00 pm

Thursday: 2:00 - 3:00 pmThursday: 2:00 - 3:00 pm

Other times by appointmentOther times by appointment

Page 2: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Web pagesWeb pages

Course:Course:http://classes.engr.oregonstate.edu/eecs/http://classes.engr.oregonstate.edu/eecs/summer2010/cs271summer2010/cs271

Instructor:Instructor:http://people.oregonstate.edu/~cropjhttp://people.oregonstate.edu/~cropj

Textbook supplemental material:Textbook supplemental material:http://kipirvine.com/asm/http://kipirvine.com/asm/

Get an Get an engrengr account (if you don’t have one already): account (if you don’t have one already):http://engr.oregonstate.edu/teach http://engr.oregonstate.edu/teach

Page 3: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Required TextbookRequired TextbookIrvine, Kip R., Irvine, Kip R., Assembly Assembly

Language for Intel-Language for Intel-Based Computers Based Computers (5th (5th edition),edition),

Prentice-Hall, 2007.Prentice-Hall, 2007.

(ISBN 0132383101)(ISBN 0132383101)

More …More …

One copy will be on 2-One copy will be on 2-hour reserve at Valley hour reserve at Valley LibraryLibrary

Page 4: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Assembler, Linker, IDEAssembler, Linker, IDE

http://kipirvine.com/asm/http://kipirvine.com/asm/gettingStartedgettingStarted

Install Install Visual C++ 2008 Express Visual C++ 2008 Express EditionEdition (if you don’t already have a (if you don’t already have a version of version of Visual C++Visual C++))

Install the Install the Microsoft AssemblerMicrosoft Assembler Install the textbook's libraries Install the textbook's libraries

Page 5: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

PrerequisitesPrerequisites

Official:Official:CS 161, MTH 231CS 161, MTH 231

The real requirements:The real requirements: Analytical skills, problem-solving abilityAnalytical skills, problem-solving ability Flexibility, patience, persistenceFlexibility, patience, persistence Integrity, responsibilityIntegrity, responsibility

Page 6: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Academic HonestyAcademic HonestyFor group work:For group work:

Each team member does his/her share.Each team member does his/her share.

Each member works toward the team Each member works toward the team goal.goal.

For individual work:For individual work:DiscussionDiscussion is encouraged, but is encouraged, but each each student is expected to produce student is expected to produce and understand all aspects of his and understand all aspects of his her own programs and solutionsher own programs and solutions..

For quizzes and exams:For quizzes and exams:No sharing of information is permitted.No sharing of information is permitted.

Page 7: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Academic HonestyAcademic Honesty

If you are having trouble with an If you are having trouble with an assignment …assignment … discuss it with other students, TAs, the discuss it with other students, TAs, the

instructor, or anyone else who will listeninstructor, or anyone else who will listen don’t just have someone else tell you how to don’t just have someone else tell you how to

solve the problem!solve the problem! If other students ask you for help, don’t If other students ask you for help, don’t

just let them copy your work!just let them copy your work! It is possible to discuss problems without It is possible to discuss problems without

plagiarizingplagiarizing One of the best methods of debugging is One of the best methods of debugging is

to explain your solution to someone else.to explain your solution to someone else.

Page 8: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Academic HonestyAcademic Honesty If you get help from, give help to, or "work If you get help from, give help to, or "work

together" with someone …together" with someone … you must (in the program header block) list you must (in the program header block) list

that person as a collaborator and describe the that person as a collaborator and describe the helphelp

Programs that are very similar will be Programs that are very similar will be subjected to review unless both programs subjected to review unless both programs indicate that they were produced indicate that they were produced collaborativelycollaboratively

If you get help from printed or online If you get help from printed or online sources, you must cite your referencessources, you must cite your references

The bottom line is:The bottom line is: Each student is expected to produce and Each student is expected to produce and

understand all aspects of his/her own understand all aspects of his/her own programs and solutionsprograms and solutions. .

Page 9: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Course calendarCourse calendarhttp://classes.engr.oregonstate.edu/eecs/summer2010/http://classes.engr.oregonstate.edu/eecs/summer2010/

cs271/271Schedule.htmcs271/271Schedule.htm Check here every week; the syllabus may be Check here every week; the syllabus may be

adjusted if it becomes apparent that adjusted if it becomes apparent that more/less time is needed for some of the more/less time is needed for some of the topics.topics.

PowerPoint slides will be available here after PowerPoint slides will be available here after the actual lecture.the actual lecture. Do not depend solely on Do not depend solely on these slides for the course material; much of these slides for the course material; much of the lecture material will be covered using the lecture material will be covered using other mediaother media..

Page 10: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Course Learning ObjectivesCourse Learning Objectives

1.1. Identify the major components of a computer Identify the major components of a computer architecture, and explain their purposes and architecture, and explain their purposes and interactions.interactions.

2.2. Simulate the internal representation of data, Simulate the internal representation of data, and show how data is stored and accessed in and show how data is stored and accessed in memory.memory.

3.3. Explain the relationships between a hardware Explain the relationships between a hardware architecture and its instruction set, and architecture and its instruction set, and simulate micro-programs.simulate micro-programs.

4.4. Create and simplify circuits that produce Create and simplify circuits that produce specified output for given inputs (e.g., adders, specified output for given inputs (e.g., adders, multiplexers, etc.).multiplexers, etc.).

5.5. Explain the Instruction Execution Cycle.Explain the Instruction Execution Cycle.6.6. Explain the differences and relationships Explain the differences and relationships

among high-level, assembly, and machine among high-level, assembly, and machine languages.languages.

Page 11: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Course Learning ObjectivesCourse Learning Objectives

1.1. Write well-modularized computer programs in Write well-modularized computer programs in an assembly language, implementing an assembly language, implementing decision, repetition, and procedure structures.decision, repetition, and procedure structures.

2.2. Use a debugger, and explain register Use a debugger, and explain register contents.contents.

3.3. Simulate the system stack as it is used for Simulate the system stack as it is used for procedure calls and parameter passing.procedure calls and parameter passing.

4.4. Explain how editors, assemblers, linkers, and Explain how editors, assemblers, linkers, and operating systems enable computer operating systems enable computer programming.programming.

5.5. Explain various mechanisms for implementing Explain various mechanisms for implementing parallelism in hardware/software.parallelism in hardware/software.

Page 12: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

FHCs FHCs (Frequently Heard Complaints)(Frequently Heard Complaints)

““I’ve never seen any of this stuff I’ve never seen any of this stuff before!”before!”

““This is waaaaay beyond boring!”This is waaaaay beyond boring!” ““I'm CS, not ECE”I'm CS, not ECE” ““I know for sure that I will never use I know for sure that I will never use

this stuff!”this stuff!” (… so why should I learn it?)(… so why should I learn it?)

Page 13: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Introduction to LanguagesIntroduction to Languages Viewed by "levels"Viewed by "levels" Natural languagesNatural languages

Used by humansUsed by humans Many interpretationsMany interpretations E.G.: English, Spanish, ChineseE.G.: English, Spanish, Chinese

High-level programming languagesHigh-level programming languages English-like, translated for computer by compilersEnglish-like, translated for computer by compilers Strict rules of syntax and semanticsStrict rules of syntax and semantics E.G.: Java, C++, Perl, PythonE.G.: Java, C++, Perl, Python

Low-level programming languagesLow-level programming languages Mnemonic instructions for specific architectureMnemonic instructions for specific architecture Translated for computer by assemblersTranslated for computer by assemblers E.G.: Intel assembly, Mac assemblyE.G.: Intel assembly, Mac assembly

Machine-level computer languagesMachine-level computer languages Actual binary code instructions for specific architectureActual binary code instructions for specific architecture Can be represented numericallyCan be represented numerically E.G.: Intel machine instructions, Mac machine instructionsE.G.: Intel machine instructions, Mac machine instructions

Page 14: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Programming environments for Programming environments for various language levelsvarious language levels

Natural languageNatural language word processorsword processors

High-level programming languagesHigh-level programming languages Text editor, compiler, linker, loader (debugger)Text editor, compiler, linker, loader (debugger) E.G.: Eclipse, Visual C++, etc.E.G.: Eclipse, Visual C++, etc.

Low-level programming languagesLow-level programming languages Text editor, assembler, (debugger)Text editor, assembler, (debugger) E.G.: any text editor together with MASM, Visual C++, E.G.: any text editor together with MASM, Visual C++,

etc.etc. Machine-level computer languagesMachine-level computer languages

Some way to assign machine instructions directly into Some way to assign machine instructions directly into memorymemory

E.G.: set individual bits (switches)E.G.: set individual bits (switches)

Page 15: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Introduction to Computer Introduction to Computer ArchitectureArchitecture

Viewed by "levels"Viewed by "levels" Each level has an associated languageEach level has an associated language

Lowest level (level 0) is the actual hardware Lowest level (level 0) is the actual hardware with its associated machine languagewith its associated machine language

Highest level is a "virtual machine" with its Highest level is a "virtual machine" with its associated high-level languageassociated high-level language

Program statements at level Program statements at level kk ( (kk > 0) are > 0) are translated or interpretedtranslated or interpreted into statements into statements in the language that can be executed by in the language that can be executed by level level kk-1.-1.

Page 16: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00
Page 17: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00
Page 18: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

RelationshipRelationship

A computer's instruction set is defined by A computer's instruction set is defined by the computer's architecture.the computer's architecture. I.E.: each computer architecture has its own I.E.: each computer architecture has its own

machine language.machine language. E.G.: Mac machine instructions will not work on E.G.: Mac machine instructions will not work on

an Intel architecture.an Intel architecture. Virtual machinesVirtual machines can be used to simulate can be used to simulate

another computer's architecture.another computer's architecture. Cross-assemblersCross-assemblers can be used to covert a can be used to covert a

machine language to another machine machine language to another machine language.language.

Page 19: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

RelationshipRelationship

Hardware:Hardware: Physical devicesPhysical devices E.G.: circuits, chips, disk drives, printers, etc.E.G.: circuits, chips, disk drives, printers, etc.

Software:Software: Instructions that control hardwareInstructions that control hardware E.G.:E.G.: assemblers, compilers, operating systems, assemblers, compilers, operating systems,

word processors, games, etc.word processors, games, etc.

Page 20: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Operating SystemsOperating Systems

Operating systems provide interfaces Operating systems provide interfaces among users, programs, and devices among users, programs, and devices (including the computer itself).(including the computer itself).

An operating system is implemented An operating system is implemented in the host computer's machine in the host computer's machine language.language.

Page 21: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

System ArchitecturesSystem Architectures Super-computer Super-computer MainframeMainframe Multiprocessor/ParallelMultiprocessor/Parallel ServerServer Distributed (Collection of Workstations)Distributed (Collection of Workstations)

NetworkNetwork Personal computerPersonal computer

Desktop, PDA, etc.Desktop, PDA, etc. Micro-controller (Real-time/Embedded Micro-controller (Real-time/Embedded

system)system) Car, appliance, watch, etc.Car, appliance, watch, etc.

etc.etc.

Page 22: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Three architecture tracksThree architecture tracks

Build more powerful machinesBuild more powerful machines Build same machine smaller/cheaperBuild same machine smaller/cheaper Build lower power machinesBuild lower power machines

Page 23: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

How is assembly language How is assembly language related to hardware/software? related to hardware/software?

We will use assembly language to We will use assembly language to implement some software.implement some software.

Unlike most high-level languages, Unlike most high-level languages, assembly language allows direct assembly language allows direct control of hardware components control of hardware components Good way to really understand how the Good way to really understand how the

hardware works.hardware works.

Page 24: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Other uses for assembly Other uses for assembly languagelanguage

Embedded systemsEmbedded systems Efficiency is criticalEfficiency is critical

Real-time applicationsReal-time applications Timing is criticalTiming is critical

Interactive gamesInteractive games Speed is criticalSpeed is critical

Low-level tasksLow-level tasks Direct control is criticalDirect control is critical

Device driversDevice drivers Direct control is criticalDirect control is critical

Page 25: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Metrics (measurements)Metrics (measurements)

Speed (distance/time) is measured in Speed (distance/time) is measured in electronic units:electronic units: K = 10K = 1033, M = 10, M = 1066, G = 10, G = 1099, etc., etc.

Size in bits, bytes is measured in Size in bits, bytes is measured in binary unitsbinary units K = 2K = 21010, M = 2, M = 22020, G = 2, G = 23030, etc., etc. We use Ki, Mi, Gi for clarityWe use Ki, Mi, Gi for clarity

E.G., 200 GiB hard diskE.G., 200 GiB hard disk

E.G., E.G., 100K = 100,000100K = 100,000

100Ki = 102,400100Ki = 102,400

Page 26: CS 271 Summer 2010 Computer Architecture and Assembly Language MTWRF 11:00 – 11:50 PM STAG 106 Instructor:Joe Crop Office hours (KEC 1130): Tuesday: 2:00

Questions?Questions?

Read:Read: Irvine Chapter 1Irvine Chapter 1