DOC PREVIEW
CMU CS 15213 - Lecture

This preview shows page 1-2-3-22-23-24-45-46-47 out of 47 pages.

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

Unformatted text preview:

Carnegie Mellon Machine Level Programming I Basics 15 213 18 243 Introduc3on to Computer Systems 4th Lecture Sep 2 2010 Instructors Randy Bryant and Dave O Hallaron 1 Carnegie Mellon Today Machine Programming I Basics History of Intel processors and architectures C assembly machine code Assembly Basics Registers operands move Intro to x86 64 2 Carnegie Mellon Intel x86 Processors Totally dominate laptop desktop server market EvoluJonary design Backwards compa3ble up un3l 8086 introduced in 1978 Added more features as 3me goes on Complex instrucJon set computer CISC Many di erent instruc3ons with many di erent formats But only small subset encountered with Linux programs Hard to match performance of Reduced Instruc3on Set Computers RISC But Intel has done just that In terms of speed Less so for low power 3 Carnegie Mellon Intel x86 EvoluJon Milestones Name 8086 Date 1978 Transistors 29K MHz 5 10 First 16 bit processor Basis for IBM PC DOS 1MB address space 386 1985 275K 16 33 First 32 bit processor referred to as IA32 Added at addressing Capable of running Unix 32 bit Linux gcc uses no instruc3ons introduced in later models PenJum 4F 2004 125M 2800 3800 First 64 bit processor referred to as x86 64 Core i7 2008 731M 2667 3333 Our shark machines 4 Carnegie Mellon Intel x86 Processors Overview Architectures X86 16 Processors 8086 286 X86 32 IA32 MMX 386 486 PenJum PenJum MMX SSE PenJum III SSE2 PenJum 4 SSE3 PenJum 4E X86 64 EM64t PenJum 4F SSE4 Core 2 Duo Core i7 Jme IA o en rede ned as latest Intel architecture 5 Carnegie Mellon Intel x86 Processors contd Machine EvoluJon 386 Pen3um Pen3um MMX Pen3umPro Pen3um III Pen3um 4 Core 2 Duo Core i7 1985 1993 1997 1995 1999 2001 2006 2008 0 3M 3 1M 4 5M 6 5M 8 2M 42M 291M 731M Added Features Instruc3ons to support mul3media opera3ons Parallel opera3ons on 1 2 and 4 byte data both integer FP Instruc3ons to enable more e cient condi3onal opera3ons Linux GCC EvoluJon Two major steps 1 support 32 bit 386 2 support 64 bit x86 64 6 Carnegie Mellon More InformaJon Intel processors Wikipedia Intel microarchitectures 7 Carnegie Mellon New Species ia64 then IPF then Itanium Name Itanium Date 2001 Transistors 10M First shot at 64 bit architecture rst called IA64 Radically new instruc3on set designed for high performance Can run exis3ng IA32 programs On board x86 engine Joint project with Hewlef Packard Itanium 2 2002 221M Big performance boost Itanium 2 Dual Core 2006 1 7B Itanium has not taken o in marketplace Lack of backward compa3bility no good compiler support Pen3um 4 got too good 8 Carnegie Mellon x86 Clones Advanced Micro Devices AMD Historically AMD has followed just behind Intel A lifle bit slower a lot cheaper Then Recruited top circuit designers from Digital Equipment Corp and other downward trending companies Built Opteron tough compe3tor to Pen3um 4 Developed x86 64 their own extension to 64 bits 9 Carnegie Mellon Intel s 64 Bit Intel Adempted Radical Shi from IA32 to IA64 Totally di erent architecture Itanium Executes IA32 code only as legacy Performance disappoin3ng AMD Stepped in with EvoluJonary SoluJon x86 64 now called AMD64 Intel Felt Obligated to Focus on IA64 Hard to admit mistake or that AMD is befer 2004 Intel Announces EM64T extension to IA32 Extended Memory 64 bit Technology Almost iden3cal to x86 64 All but low end x86 processors support x86 64 But lots of code s3ll runs in 32 bit mode 10 Carnegie Mellon Our Coverage IA32 The tradi3onal x86 x86 64 EM64T The emerging standard PresentaJon Book presents IA32 in Sec3ons 3 1 3 12 Covers x86 64 in 3 13 We will cover both simultaneously Some labs will be based on x86 64 others on IA32 11 Carnegie Mellon Today Machine Programming I Basics History of Intel processors and architectures C assembly machine code Assembly Basics Registers operands move Intro to x86 64 12 Carnegie Mellon De niJons Architecture also instrucJon set architecture ISA The parts of a processor design that one needs to understand to write assembly code Examples instruc3on set speci ca3on registers Microarchitecture ImplementaJon of the architecture Examples cache sizes and core frequency Example ISAs Intel x86 IA IPF 13 Carnegie Mellon Assembly Programmer s View CPU PC Registers CondiJon Codes Addresses Data Instruc3ons Address of next instruc3on Called EIP IA32 or RIP x86 64 Register le Heavily used program data Condi3on codes Object Code Program Data OS Data Stack Programmer Visible State PC Program counter Memory Store status informa3on about most recent arithme3c opera3on Used for condi3onal branching Memory Byte addressable array Code user data some OS data Includes stack used to support procedures 14 Carnegie Mellon Turning C into Object Code Code in les p1 c p2 c Compile with command gcc O1 p1 c p2 c o p Use basic op3miza3ons O1 Put resul3ng binary in le p text C program p1 c p2 c Compiler gcc S text Asm program p1 s p2 s Assembler gcc or as binary Object program p1 o p2 o Linker gcc or ld binary StaJc libraries a Executable program p 15 Carnegie Mellon Compiling Into Assembly C Code int sum int x int y int t x y return t Generated IA32 Assembly sum pushl ebp movl esp ebp movl 12 ebp eax addl 8 ebp eax popl ebp ret Some compilers use instrucJon leave Obtain with command usr local bin gcc O1 S code c Produces le code s 16 Carnegie Mellon Assembly CharacterisJcs Data Types Integer data of 1 2 or 4 bytes Data values Addresses untyped pointers FloaJng point data of 4 8 or 10 bytes No aggregate types such as arrays or structures Just con3guously allocated bytes in memory 17 Carnegie Mellon Assembly CharacterisJcs OperaJons Perform arithmeJc funcJon on register or memory data Transfer data between memory and register Load data from memory into register Store register data into memory Transfer control Uncondi3onal jumps to from procedures Condi3onal branches 18 Carnegie Mellon Object Code Code for sum 0x401040 sum 0x55 0x89 0xe5 0x8b 0x45 0x0c 0x03 0x45 0x08 Total of 11 bytes 0x5d 0xc3 Each instrucJon 1 2 or 3 bytes Starts at address 0x401040 Assembler Translates s into o Binary encoding of each instruc3on Nearly complete image of executable code Missing linkages between code in di erent les Linker Resolves references between les Combines with sta3c run 3me libraries E g code for malloc printf Some libraries are dynamically linked Linking occurs when program begins execu3on 19 Carnegie Mellon Machine InstrucJon Example int t x y Add two signed integers Long words in GCC parlance Same instruc3on whether signed


View Full Document

CMU CS 15213 - Lecture

Documents in this Course
lecture

lecture

14 pages

lecture

lecture

46 pages

Caches

Caches

9 pages

lecture

lecture

39 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

56 pages

lecture

lecture

11 pages

lecture

lecture

9 pages

Lecture

Lecture

36 pages

Lecture

Lecture

37 pages

Exam

Exam

16 pages

Lecture

Lecture

10 pages

Lecture

Lecture

43 pages

Lecture

Lecture

8 pages

Lecture

Lecture

8 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

37 pages

Lecture

Lecture

6 pages

Lecture

Lecture

40 pages

coding

coding

2 pages

Exam

Exam

17 pages

Exam

Exam

14 pages

Lecture

Lecture

29 pages

Lecture

Lecture

34 pages

Exam

Exam

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

lecture

lecture

46 pages

Lecture

Lecture

33 pages

Lecture

Lecture

57 pages

Lecture

Lecture

32 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

11 pages

Lecture

Lecture

6 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

18 pages

Exam

Exam

10 pages

Lecture

Lecture

45 pages

Lecture

Lecture

37 pages

Exam

Exam

24 pages

class09

class09

21 pages

class22

class22

37 pages

class20

class20

30 pages

class27

class27

33 pages

class25

class25

21 pages

class04

class04

31 pages

Lecture

Lecture

59 pages

class01a

class01a

14 pages

class12

class12

45 pages

class29

class29

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

6 pages

class03

class03

34 pages

lecture

lecture

42 pages

Lecture

Lecture

40 pages

Lecture

Lecture

47 pages

Exam

Exam

19 pages

R06-B

R06-B

25 pages

class17

class17

37 pages

class25

class25

31 pages

Lecture

Lecture

15 pages

final-f06

final-f06

17 pages

Lecture

Lecture

9 pages

lecture

lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

22 pages

class11

class11

45 pages

lecture

lecture

50 pages

Linking

Linking

37 pages

Lecture

Lecture

64 pages

Integers

Integers

40 pages

Exam

Exam

11 pages

Lecture

Lecture

37 pages

Lecture

Lecture

44 pages

Lecture

Lecture

37 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

45 pages

Final

Final

25 pages

lecture

lecture

9 pages

Lecture

Lecture

30 pages

Lecture

Lecture

16 pages

Final

Final

17 pages

Lecture

Lecture

8 pages

Exam

Exam

11 pages

Lecture

Lecture

47 pages

Lecture

Lecture

9 pages

lecture

lecture

39 pages

Exam

Exam

11 pages

lecture

lecture

41 pages

lecture

lecture

37 pages

Lecture

Lecture

59 pages

Lecture

Lecture

45 pages

Exam 1

Exam 1

18 pages

Lecture

Lecture

41 pages

Lecture

Lecture

32 pages

Lecture

Lecture

30 pages

Lecture

Lecture

9 pages

Lecture

Lecture

9 pages

Lecture

Lecture

15 pages

Lecture

Lecture

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

4 pages

Lecture

Lecture

46 pages

Lecture

Lecture

8 pages

Lecture

Lecture

65 pages

Lecture

Lecture

38 pages

Lecture

Lecture

35 pages

Lecture

Lecture

8 pages

Lecture

Lecture

34 pages

Lecture

Lecture

8 pages

Exam

Exam

13 pages

Lecture

Lecture

43 pages

Lecture

Lecture

9 pages

Lecture

Lecture

12 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

43 pages

Lecture

Lecture

7 pages

Lecture

Lecture

45 pages

Lecture

Lecture

24 pages

Lecture

Lecture

12 pages

Lecture

Lecture

20 pages

Lecture

Lecture

9 pages

Exam

Exam

11 pages

Lecture

Lecture

52 pages

Lecture

Lecture

20 pages

Exam

Exam

11 pages

Lecture

Lecture

35 pages

Lecture

Lecture

47 pages

Lecture

Lecture

18 pages

Lecture

Lecture

30 pages

Lecture

Lecture

59 pages

Lecture

Lecture

37 pages

Lecture

Lecture

22 pages

Lecture

Lecture

35 pages

Exam

Exam

23 pages

Lecture

Lecture

9 pages

Lecture

Lecture

22 pages

class12

class12

32 pages

Lecture

Lecture

8 pages

Lecture

Lecture

39 pages

Lecture

Lecture

44 pages

Lecture

Lecture

38 pages

Lecture

Lecture

69 pages

Lecture

Lecture

41 pages

Lecture

Lecture

12 pages

Lecture

Lecture

52 pages

Lecture

Lecture

59 pages

Lecture

Lecture

39 pages

Lecture

Lecture

83 pages

Lecture

Lecture

59 pages

class01b

class01b

17 pages

Exam

Exam

21 pages

class07

class07

47 pages

Lecture

Lecture

11 pages

Odyssey

Odyssey

18 pages

multicore

multicore

66 pages

Lecture

Lecture

6 pages

lecture

lecture

41 pages

lecture

lecture

55 pages

lecture

lecture

52 pages

lecture

lecture

33 pages

lecture

lecture

46 pages

lecture

lecture

55 pages

lecture

lecture

17 pages

lecture

lecture

49 pages

Exam

Exam

17 pages

lecture

lecture

56 pages

Exam 2

Exam 2

16 pages

Exam 2

Exam 2

16 pages

Notes

Notes

37 pages

Lecture

Lecture

40 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 pages

Exam

Exam

13 pages

Lecture

Lecture

32 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

29 pages

Lecture

Lecture

59 pages

Lecture

Lecture

41 pages

Lecture

Lecture

50 pages

Exam

Exam

17 pages

Lecture

Lecture

29 pages

Lecture

Lecture

44 pages

Lecture

Lecture

41 pages

Lecture

Lecture

52 pages

Lecture

Lecture

40 pages

Lecture

Lecture

33 pages

lecture

lecture

10 pages

Lecture

Lecture

27 pages

Lecture

Lecture

29 pages

Lecture

Lecture

39 pages

Lecture

Lecture

9 pages

Lecture

Lecture

29 pages

Lecture

Lecture

8 pages

Lecture

Lecture

43 pages

Lecture

Lecture

43 pages

Lecture

Lecture

75 pages

Lecture

Lecture

55 pages

Exam

Exam

12 pages

Lecture

Lecture

43 pages

Lecture

Lecture

35 pages

lecture

lecture

36 pages

Exam

Exam

33 pages

lecture

lecture

56 pages

lecture

lecture

64 pages

lecture

lecture

8 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

36 pages

lecture

lecture

56 pages

lecture

lecture

75 pages

lecture

lecture

36 pages

Lecture

Lecture

50 pages

Lecture

Lecture

45 pages

Lecture

Lecture

13 pages

Exam

Exam

23 pages

Lecture

Lecture

10 pages

Lecture

Lecture

48 pages

Lecture

Lecture

83 pages

lecture

lecture

57 pages

Lecture

Lecture

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

33 pages

lecture

lecture

54 pages

Lecture

Lecture

30 pages

Exam

Exam

13 pages

Lecture

Lecture

36 pages

Lecture

Lecture

40 pages

Exam

Exam

17 pages

Lecture

Lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

44 pages

Lecture

Lecture

34 pages

Lecture

Lecture

24 pages

Lecture

Lecture

29 pages

class12

class12

43 pages

lecture

lecture

43 pages

class22

class22

22 pages

R06-B

R06-B

25 pages

class01b

class01b

19 pages

lecture

lecture

29 pages

lab1

lab1

8 pages

Caches

Caches

36 pages

lecture

lecture

55 pages

Lecture,

Lecture,

37 pages

Integers

Integers

40 pages

Linking

Linking

38 pages

lecture

lecture

45 pages

Lecture

Lecture

61 pages

Linking

Linking

33 pages

lecture

lecture

40 pages

lecture

lecture

40 pages

Lecture

Lecture

32 pages

lecture

lecture

48 pages

lecture

lecture

44 pages

Exam

Exam

11 pages

Lecture

Lecture

31 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

40 pages

Exam

Exam

12 pages

Lecture

Lecture

42 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

Lecture

Lecture

13 pages

Lecture

Lecture

35 pages

Lecture

Lecture

20 pages

Final

Final

19 pages

Lecture

Lecture

33 pages

Lecture

Lecture

50 pages

Lecture

Lecture

33 pages

Lecture

Lecture

27 pages

Lecture

Lecture

6 pages

Exam

Exam

15 pages

Lecture

Lecture

24 pages

Lecture

Lecture

23 pages

Lecture

Lecture

43 pages

Lecture

Lecture

32 pages

Lecture

Lecture

52 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

15 pages

lecture

lecture

21 pages

Lecture

Lecture

58 pages

Lecture

Lecture

49 pages

Lecture

Lecture

36 pages

Lecture

Lecture

11 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

33 pages

Exam

Exam

15 pages

Lecture

Lecture

35 pages

Lecture

Lecture

10 pages

Lecture

Lecture

25 pages

Lecture

Lecture

31 pages

Lecture

Lecture

24 pages

Lecture

Lecture

34 pages

Lecture

Lecture

50 pages

lecture

lecture

35 pages

Lecture

Lecture

11 pages

Lecture

Lecture

39 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

exam1-f05

exam1-f05

11 pages

Lecture

Lecture

4 pages

Lecture

Lecture

17 pages

Exam

Exam

17 pages

malloc()

malloc()

12 pages

Lecture

Lecture

57 pages

Lecture

Lecture

30 pages

Lecture

Lecture

30 pages

Lecture

Lecture

47 pages

Lecture

Lecture

33 pages

Exam

Exam

12 pages

Lecture

Lecture

43 pages

Lectures

Lectures

33 pages

Lecture

Lecture

36 pages

lecture

lecture

33 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 pages

Load more
Download Lecture
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 Lecture 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 Lecture 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?