DOC PREVIEW
Princeton COS 217 - Computer Architecture

This preview shows page 1-2-3-4-5-38-39-40-41-42-43-76-77-78-79-80 out of 80 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 80 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Computer Architecture and Assembly LanguageGoals of Today’s LectureLevels of LanguagesWhy Learn Assembly Language?A Typical Computer Von Neumann ArchitectureControl UnitExample: Kinds of InstructionsSize of Variables Four-Byte Memory WordsIA32 General Purpose RegistersRegisters for Executing the CodeOther Registers that you don’t much care aboutReading IA32 Assembly LanguageDetailed ExampleFlattening Code ExampleMachine-Language InstructionsInstructionHow Many Instructions to Have?CISC vs. RISCData Transfer InstructionsData Access MethodsEffective AddressBitwise Logic InstructionsArithmetic InstructionsEFLAG Register & Condition CodesBranch InstructionsMaking the Computer FasterMemory HierarchyConclusionInstructionsStateState – Main MemoryState – Main MemoryState – Main MemoryState – Registers (Register File)State – Program CounterState – Program CounterState – SummaryAn Aside: State and The Core DumpInterfaces in Computer SystemsInstructionsInstructionsInstructionsInstructionsInstructionsInstructionsInstructionsInstructionsInstructions Assembly Instructions and CBranchingTherefore…Unconditional BranchesConditional BranchConditional BranchIndirect BranchesBranch SummaryA Note on Notation…Specific Instance: MIPS Instruction Set Specific Instance: MIPS Instruction Set Specific Instance: MIPS Instruction Set Specific Instance: MIPS Instruction Set How are MIPS Instructions Encoded?MIPS Encodings 32-bits/InstructionMIPS Add Instruction Encoding MIPS Add Instruction Encoding Add and Subtract A little foreshadowing…Memory Addressing Memory OrganizationAddressing ModesHello World Hello World Hello World Control (from the back of a napkin)The Hardware/Software Interface The Instruction Set Architecture1Computer Architecture and Assembly LanguageProf. David AugustCOS 2172Goals of Today’s Lecture• Computer architectureo Central processing unit (CPU)o Fetch-decode-execute cycleo Memory hierarchy, and other optimization• Assembly languageo Machine vs. assembly vs. high-level languageso Motivation for learning assembly languageo Intel Architecture (IA32) assembly language3Levels of Languages• Machine languageo What the computer sees and deals witho Every command is a sequence of one or more numbers• Assembly languageo Command numbers replaced by letter sequences that are easier to reado Still have to work with the specifics of the machine itself• High-level languageo Make programming easier by describing operations in a natural languageo A single command replaces a group of low-level assembly language commands4Why Learn Assembly Language?• Understand how things work underneatho Learn the basic organization of the underlying machineo Learn how the computer actually runs a programo Design better computers in the future• Write faster code (even in high-level language)o By understanding which high-level constructs are bettero … in terms of how efficient they are at the machine level• Some software is still written in assembly languageo Code that really needs to run quicklyo Code for embedded systems, network processors, etc.5A Typical Computer CPUChipsetMemoryI/O busCPU. . .NetworkROM6Von Neumann Architecture• Central Processing Unito Control unit– Fetch, decode, and execute o Arithmetic and logic unit– Execution of low-level operationso General-purpose registers– High-speed temporary storageo Data bus– Provide access to memory•Memoryo Store instructionso Store dataRandom AccessMemory (RAM)ControlUnitALUCPURegistersData bus7Control Unit• Instruction pointero Stores the location of the next instruction– Address to use when reading from memoryo Changing the instruction pointer– Increment by one to go to the next instruction– Or, load a new value to “jump” to a new location• Instruction decodero Determines what operations need to take place– Translate the machine-language instruction o Control the registers, arithmetic logic unit, and memory– E.g., control which registers are fed to the ALU– E.g., enable the ALU to do multiplication– E.g., read from a particular address in memory8Example: Kinds of Instructions• Storing values in registerso count = 0o n• Arithmetic and logic operationso Increment: count++o Multiply: n * 3o Divide: n/2o Logical AND: n & 1• Checking results of comparisons o while (n > 1)o if (n & 1)• Jumpingo To the end of the while loop (if “n > 1”)o Back to the beginning of the loopo To the else clause (if “n & 1” is 0)count = 0;while (n > 1) {count++;if (n & 1)n = n*3 + 1;elsen = n/2;}9Size of Variables • Data types in high-level languages vary in sizeo Character: 1 byteo Short, int, and long: varies, depending on the computero Pointers: typically 4 byteso Struct: arbitrary size, depending on the elements• Implicationso Need to be able to store and manipulate in multiple sizeso Byte (1 byte), word (2 bytes), and extended (4 bytes)o Separate assembly-language instructions – e.g., addb, addw, addlo Separate ways to access (parts of) a 4-byte register10Four-Byte Memory WordsMemory232-10Byte order is little endian31 08 716 15...24 23Byte 4Byte 0Byte 5Byte 1Byte 2Byte 6Byte 3Byte 711IA32 General Purpose RegistersGeneral-purpose registersEAXEBXECXEDXESIEDI31016-bit 32-bitAXBXCXDXDISIALAHBLCLDLBHCHDH8 71512Registers for Executing the Code• Execution control flowo Instruction pointer (EIP)– Address in memory of the current instructiono Flags (EFLAGS)– Stores the status of operations, such as comparisons– E.g., last result was positive/negative, was zero, etc.• Function calls (more on these later!)o Stack register (ESP)– Address of the top of the stacko Base pointer (EBP)– Address of a particular element on the stack– Access function parameters and local variables13Other Registers that you don’t much care about• Segment registerso CS, SS, DS, ES, FS, GS• Floating Point Unit (FPU) (x87)o Eight 80-bit registers (ST0, …, ST7)o 16-bit control, status, tag registerso 11-bit opcode registero 48-bit FPU instruction pointer, data pointer registers• MMXo Eight 64-bit registers• SSE and SSE2 o Eight 128-bit registerso 32-bit MXCRS register• Systemo I/O portso Control registers (CR0, …, CR4)o Memory management registers (GDTR, IDTR, LDTR)o Debug registers (DR0, …, DR7)o Machine specific registerso Machine check registerso Performance monitor registers14Reading IA32 Assembly Language• Assembler directives: starting with a period (“.”)o E.g., “.section


View Full Document

Princeton COS 217 - Computer Architecture

Documents in this Course
Summary

Summary

4 pages

Lecture

Lecture

4 pages

Generics

Generics

14 pages

Generics

Generics

16 pages

Lecture

Lecture

20 pages

Debugging

Debugging

35 pages

Types

Types

7 pages

Lecture

Lecture

21 pages

Assembler

Assembler

16 pages

Lecture

Lecture

20 pages

Lecture

Lecture

39 pages

Testing

Testing

44 pages

Pipeline

Pipeline

19 pages

Lecture

Lecture

6 pages

Signals

Signals

67 pages

Building

Building

17 pages

Lecture

Lecture

7 pages

Modules

Modules

12 pages

Generics

Generics

16 pages

Testing

Testing

22 pages

Signals

Signals

34 pages

Lecture

Lecture

19 pages

Load more
Download Computer Architecture
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Computer Architecture and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Computer Architecture 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?