DOC PREVIEW
CMU CS 15213 - Lecture

This preview shows page 1-2-3-4-28-29-30-31-58-59-60-61 out of 61 pages.

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

Unformatted text preview:

Carnegie Mellon Introduction to Computer Systems 15 213 18 243 spring 2009 6th Lecture Jan 29th Instructors Gregory Kesden and Markus P schel Carnegie Mellon Last Time Machine Programming Basics History of Intel processors and architectures C assembly machine code Assembly IA32 eax Registers Operands Move what s the l in movl movl 0x4 eax movl eax edx movl eax edx ecx edx ebx esi edi esp ebp Carnegie Mellon Today Complete addressing mode address computation leal Arithmetic operations x86 64 Control Condition codes Conditional branches While loops Carnegie Mellon Complete Memory Addressing Modes Most General Form D Rb Ri S Mem Reg Rb S Reg Ri D D Rb Ri Constant displacement 1 2 or 4 bytes Base register Any of 8 integer registers Index register Any except for esp Unlikely you d use ebp either S Scale 1 2 4 or 8 why these numbers Special Cases Rb Ri D Rb Ri Rb Ri S Mem Reg Rb Reg Ri Mem Reg Rb Reg Ri D Mem Reg Rb S Reg Ri Carnegie Mellon Address Computation Examples edx 0xf000 ecx 0x100 Expression Address Computation Address 0x8 edx 0xf000 0x8 0xf008 edx ecx 0xf000 0x100 0xf100 edx ecx 4 will disappear 0xf000 blackboard 4 0x100 0xf400 0x80 edx 2 2 0xf000 0x80 0x1e080 Carnegie Mellon Address Computation Examples edx 0xf000 ecx 0x100 Expression Address Computation Address 0x8 edx 0xf000 0x8 0xf008 edx ecx 0xf000 0x100 0xf100 edx ecx 4 0xf000 4 0x100 0xf400 0x80 edx 2 2 0xf000 0x80 0x1e080 Carnegie Mellon Address Computation Instruction leal Src Dest Src is address mode expression Set Dest to address denoted by expression Uses Computing addresses without a memory reference E g translation of p x i Computing arithmetic expressions of the form x k y k 1 2 4 or 8 Example Carnegie Mellon Today Complete addressing mode address computation leal Arithmetic operations x86 64 Control Condition codes Conditional branches While loops Carnegie Mellon Some Arithmetic Operations Two Operand Instructions Format addl Src Dest Computation Dest Dest Src subl Src Dest Dest Dest Src imull Src Dest Dest Dest Src sall Src Dest Dest Dest Src Also called shll sarl Src Dest Dest Dest Src Arithmetic shrl Src Dest Dest Dest Src Logical xorl Src Dest Dest Dest Src andl Src Dest Dest Dest Src orl Dest Dest Src Src Dest No distinction between signed and unsigned int why Carnegie Mellon Some Arithmetic Operations One Operand Instructions incl Dest Dest Dest 1 decl Dest Dest Dest 1 negl Dest Dest Dest notl Dest Dest Dest See book for more instructions Carnegie Mellon Using leal for Arithmetic Expressions int arith int x int y int z int t1 x y int t2 z t1 int t3 x 4 int t4 y 48 int t5 t3 t4 int rval t2 t5 return rval arith pushl ebp movl esp ebp movl 8 ebp eax movl 12 ebp edx leal edx eax ecx leal edx edx 2 edx sall 4 edx addl 16 ebp ecx leal 4 edx eax eax imull ecx eax movl ebp esp popl ebp ret Set Up Body Finish Carnegie Mellon Understanding arith int arith int x int y int z int t1 x y int t2 z t1 int t3 x 4 int t4 y 48 int t5 t3 t4 int rval t2 t5 return rval movl 8 ebp eax movl 12 ebp edx leal edx eax ecx leal edx edx 2 edx sall 4 edx addl 16 ebp ecx leal 4 edx eax eax imull ecx eax Offset 16 z 12 y 8 x 4 Rtn adr 0 Old ebp eax x edx y ecx x y t1 will edx disappear 3 y edxblackboard 48 y t4 ecx z t1 t2 eax 4 t4 x t5 eax t5 t2 rval Stack ebp Carnegie Mellon Understanding arith int arith int x int y int z int t1 x y int t2 z t1 int t3 x 4 int t4 y 48 int t5 t3 t4 int rval t2 t5 return rval movl 8 ebp eax movl 12 ebp edx leal edx eax ecx leal edx edx 2 edx sall 4 edx addl 16 ebp ecx leal 4 edx eax eax imull ecx eax Offset 16 z 12 y 8 x 4 Rtn adr 0 Old ebp eax edx ecx edx edx ecx eax eax x y x y t1 3 y 48 y t4 z t1 t2 4 t4 x t5 t5 t2 rval Stack ebp Carnegie Mellon Understanding arith int arith int x int y int z int t1 x y int t2 z t1 int t3 x 4 int t4 y 48 int t5 t3 t4 int rval t2 t5 return rval movl 8 ebp eax movl 12 ebp edx leal edx eax ecx leal edx edx 2 edx sall 4 edx addl 16 ebp ecx leal 4 edx eax eax imull ecx eax Offset 16 z 12 y 8 x 4 Rtn adr 0 Old ebp eax edx ecx edx edx ecx eax eax x y x y t1 3 y 48 y t4 z t1 t2 4 t4 x t5 t5 t2 rval Stack ebp Carnegie Mellon Understanding arith int arith int x int y int z int t1 x y int t2 z t1 int t3 x 4 int t4 y 48 int t5 t3 t4 int rval t2 t5 return rval movl 8 ebp eax movl 12 ebp edx leal edx eax ecx leal edx edx 2 edx sall 4 edx addl 16 ebp ecx leal 4 edx eax eax imull ecx eax Offset 16 z 12 y 8 x 4 Rtn adr 0 Old ebp eax edx ecx edx edx ecx eax eax x y x y t1 3 y 48 y t4 z t1 t2 4 t4 x t5 t5 t2 rval Stack ebp Carnegie Mellon Understanding arith int arith int x int y int z int t1 x y int t2 z t1 int t3 x 4 int t4 y 48 int t5 t3 t4 int rval t2 t5 return rval movl 8 ebp eax movl 12 ebp edx leal edx eax ecx leal edx edx 2 edx sall 4 edx addl 16 ebp ecx leal 4 edx eax eax imull ecx eax Offset 16 z 12 y 8 x 4 Rtn adr 0 Old ebp eax edx ecx edx edx ecx eax eax x y x y t1 3 y 48 y t4 z t1 t2 4 t4 x t5 t5 t2 rval Stack ebp Carnegie Mellon Another Example int logical int x int y int t1 x y int t2 t1 17 int mask 1 13 7 int rval t2 mask return rval logical pushl ebp movl esp ebp movl xorl sarl andl 8 ebp eax 12 ebp eax 17 eax 8185 eax Body movl ebp esp popl ebp ret movl xorl sarl andl 8 ebp eax 12 ebp eax 17 eax 8185 eax Set Up eax eax eax eax x x y t1 17 t2 8185 Finish Carnegie Mellon Another Example int logical int x int y int t1 x y int t2 t1 17 int mask 1 13 7 int rval t2 mask return rval logical pushl …


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

47 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

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?