CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128...

27
CS 271 CS 271 Winter 2013 Winter 2013 Computer Architecture and Assembly Language Computer Architecture and Assembly Language MW MW 10:00 – 12:00 AM 10:00 – 12:00 AM Bldg 19 Rm 128 Bldg 19 Rm 128 Instructor: Instructor: Jim Bailey Jim Bailey Office hours Office hours (19/146): (19/146): MW: 12:00-1:00 MW: 12:00-1:00 TuTh: 3:00-4:00 TuTh: 3:00-4:00 Other times by appointment Other times by appointment

Transcript of CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128...

Page 1: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1:00.

CS 271 CS 271 Winter 2013 Winter 2013 Computer Architecture and Assembly Computer Architecture and Assembly

LanguageLanguage MWMW 10:00 – 12:00 AM10:00 – 12:00 AM

Bldg 19 Rm 128Bldg 19 Rm 128

Instructor:Instructor: Jim BaileyJim BaileyOffice hoursOffice hours (19/146): (19/146):

MW: 12:00-1:00MW: 12:00-1:00

TuTh: 3:00-4:00TuTh: 3:00-4:00

Other times by appointmentOther times by appointment

Page 2: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1:00.

Assembler, Linker, IDEAssembler, Linker, IDE

http://kipirvine.com/asm/gettingStarted

Install Install Visual C++ 2010 Express Visual C++ 2010 Express EditionEdition (if you don (if you don’’t already have a 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 3: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1:00.

PrerequisitesPrerequisites

Official:Official:CS 161J, 161C+, 133C#CS 161J, 161C+, 133C#

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

Page 4: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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 5: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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 dondon’’t just have someone else tell you how to t just have someone else tell you how to

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

let them copy your work!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 to One of the best methods of debugging is to

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

Page 6: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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 that you must (in the program header block) list that

person as a collaborator and describe the helpperson as a collaborator and describe the help 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 7: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1:00.

Course calendarCourse calendar

All Resources will be in the Moodle SiteAll Resources will be in the Moodle Site Check here every week; the syllabus Check here every week; the syllabus

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

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

Page 8: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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, and Simulate the internal representation of data, and show how data is stored and accessed in 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 simulate architecture and its instruction set, and simulate micro-programs.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 among Explain the differences and relationships among

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

Page 9: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1:00.

Course Learning ObjectivesCourse Learning Objectives

7.7. 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.

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

9.9. 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.

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

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

Page 10: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1:00.

GradingGrading4 homework sets @ 2.5% 4 homework sets @ 2.5% 10%10%5 programming projects @ 5% 5 programming projects @ 5% 25%25%3 quizzes @ 10% 3 quizzes @ 10% 30%30%

(4 quizzes given, lowest score dropped.)(4 quizzes given, lowest score dropped.)

Midterm examMidterm exam 15%15%Final exam (Final exam (Mon., March 18, 10:00 amMon., March 18, 10:00 am)) 20%20%

NOTENOTE: Extra credit may be available in any of the evaluation categories, but : Extra credit may be available in any of the evaluation categories, but excess points in one category may not carry over to another category.excess points in one category may not carry over to another category.

Page 11: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1:00.

Scores will be postedScores will be posted

Grades will be posted in Moodle Grades will be posted in Moodle within a week after due datewithin a week after due date

It is your responsibility to check the It is your responsibility to check the posting frequently and report any posting frequently and report any errors with your scores.errors with your scores.

Page 12: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1:00.

End administrative stuffEnd administrative stuff

Begin CS 271Begin CS 271

Page 13: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1:00.

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

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

““This is waaaaay beyond boring!This is waaaaay beyond boring!”” ““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 14: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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 15: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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++, etc.E.G.: any text editor together with MASM, Visual C++, 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 16: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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 with Lowest level (level 0) is the actual hardware with its associated machine languageits 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 in into statements in the language that can be executed by level the language that can be executed by level kk-1.-1.

Page 17: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1:00.
Page 18: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1:00.
Page 19: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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 20: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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 21: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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 22: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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 23: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1:00.

Two architecture tracksTwo architecture tracks

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

Page 24: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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 25: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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 26: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1: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 binary Size in bits, bytes is measured in binary unitsunits 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 27: CS 271 Winter 2013 Computer Architecture and Assembly Language MW10:00 – 12:00 AM Bldg 19 Rm 128 Instructor:Jim Bailey Office hours (19/146): MW: 12:00-1:00.

Questions?Questions?

Read:Read: Irvine Chapter 1Irvine Chapter 1