DOC PREVIEW
CMU CS 15213 - Exam

This preview shows page 1-2-3-4-5 out of 15 pages.

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

Unformatted text preview:

Andrew ID print clearly Full Name 15 213 18 213 Fall 2011 Exam 1 Tuesday October 18 2011 Instructions Make sure that your exam is not missing any sheets then write your Andrew ID and full name on the front This exam is closed book closed notes except for 1 double sided note sheet You may not use any electronic devices Write your answers in the space provided below the problem If you make a mess clearly indicate your final answer The exam has a maximum score of 66 points The problems are of varying difficulty The point value of each problem is indicated Good luck 1 08 2 08 3 08 4 04 5 10 6 08 7 10 8 04 9 06 TOTAL 66 Page 1 of 15 Problem 1 8 points Multiple choice Write your answer for each question in the following table 1 2 3 4 5 6 7 8 1 What is the minimum most negative value of a 32 bit two s complement integer a 232 b 232 1 c 231 d 231 1 2 What is the difference between the mov and lea instructions a lea dereferences an address while mov doesn t b mov dereferences an address while lea doesn t c lea can be used to copy a register into another register while mov cannot d mov can be used to copy a register into another register while lea cannnot 3 After executing the following code which of the variables are equal to 0 unsigned unsigned unsigned unsigned unsigned int a 0xffffffff int b 1 int c a b long d a b long e unsigned long a b Assume ints are 32 bits wide and longs are 64 bits wide a None of them b c c c and d d c d and e Page 2 of 15 4 Assume a function foo takes two arguments When calling foo arg1 arg2 which is the correct order of operations assuming x86 calling conventions and that foo must allocate stack space implies that we must save the ebp a push arg1 push arg2 call foo push ebp b push arg1 push arg2 push ebp call foo c push arg2 push arg1 call foo push ebp d push arg2 push arg1 push ebp call foo 5 Which one of the following statements is NOT true a x86 64 provides a larger virtual address space than x86 b The stack disciplines for x86 and x86 64 are different c x86 uses ebp as the base pointer for the stack frame d x86 64 uses rbp as the base pointer for the stack frame 6 Consider a 4 way set associative cache E 4 Which one of the following statements it true a The cache has 4 blocks per line b The cache has 4 sets per line c The cache has 4 lines per set d The cache has 4 sets per block e None of the above 7 Which one of the following statements about cache memories is true a Fully associative caches offer better latency while direct mapped caches have lower miss rates b Fully associative caches offer lower miss rates while direct mapped caches have better latency c Direct mapped caches have both better miss rates and better latency d Both generally have similar latency and miss rates 8 Consider an SRAM based cache for a DRAM based main memory Neglect the possibility of other caches or levels of the memory hierarchy below main memory If a cache is improved increasing the typical hit rate from 98 to 99 which one of the following would best characterize the likely decrease in typical access time a 0 b 1 c 10 d 100 Page 3 of 15 Problem 2 8 points Integer encoding Fill in the blanks in the table below with the number described in the first column of each row You can give your answers as unexpanded simple arithmetic expressions such as 15213 42 you should not have trouble fitting your answers into the space provided For this problem assume a 6 bit word size Description Number Umax Tmin unsigned int 4 unsigned int 7 unsigned 0x21 1 0x3F int 20 12 12 4 0x15 16 Page 4 of 15 Problem 3 8 points Floating point encoding Consider the following 5 bit floating point representation based on the IEEE floating point format This format does not have a sign bit it can only represent nonnegative numbers There are k 3 exponent bits The exponent bias is 3 There are n 2 fraction bits Recall that numeric values are encoded as a value of the form V M 2E where E is the exponent after biasing and M is the significand value The fraction bits encode the significand value M using either a denormalized exponent field 0 or a normalized representation exponent field nonzero The exponent E is given by E 1 Bias for denormalized values and E e Bias for normalized values where e is the value of the exponent field exp interpreted as an unsigned number Below you are given some decimal values and your task it to encode them in floating point format In addition you should give the rounded value of the encoded floating point number To get credit you must give these as whole numbers e g 17 or as fractions in reduced form e g 3 4 Any rounding of the significand is based on round to even which rounds an unrepresentable value that lies halfway between two representable values to the nearest even representable value Value Floating Point Bits Rounded value 9 32 001 00 1 4 3 9 3 16 15 2 Page 5 of 15 Problem 4 4 points Functions I never learned to properly comment my code and now I ve forgotten what this function does Help me out by looking at the assembly code and reconstructing the C code for this recursive function Fill in the blanks unsigned mystery1 unsigned n if return 1 else return 1 mystery1 mystery1 pushl ebp movl esp ebp subl 8 esp cmpl 0 8 ebp jne L2 movl 1 4 ebp jmp L3 L2 movl 8 ebp eax shrl eax movl eax esp call mystery1 addl 1 eax movl eax 4 ebp L3 movl 4 ebp eax leave ret Page 6 of 15 Problem 5 10 points Stack discipline Consider the following C code and assembly code for a recursive function int gcd int a int b if b return a return gcd b a b 0x08048394 0x08048395 0x08048397 0x0804839a 0x0804839d 0x080483a0 0x080483a2 0x080483a4 0x080483a6 0x080483a9 0x080483ab 0x080483af 0x080483b2 0x080483b7 0x080483b8 0 1 3 6 9 12 14 16 18 21 23 27 30 35 36 push mov sub mov mov test je mov sar idiv mov mov call leave ret ebp esp ebp 0x10 esp 0x8 ebp eax 0xc ebp ecx ecx ecx 0x80483b7 gcd 35 eax edx 0x1f edx ecx edx 0x4 esp ecx esp 0x8048394 gcd Imagine that a program makes the procedure call gcd 213 18 Also imagine that prior to the invocation the value of esp is 0xffff1000 that is 0xffff1000 is the value of esp immediately before …


View Full Document

CMU CS 15213 - Exam

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

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 Exam
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 Exam 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 Exam 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?