DOC PREVIEW
CMU CS 15213 - Exam

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

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

Unformatted text preview:

Andrew login ID Full Name Section 15 213 18 243 Spring 2011 Exam 1 Thursday March 3 2011 v1 Instructions Make sure that your exam is not missing any sheets then write your Andrew login ID full name and section on the front This exam is closed book closed notes 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 100 points The problems are of varying difficulty The point value of each problem is indicated Good luck 1 12 2 17 3 13 4 11 5 20 6 12 7 15 TOTAL 100 Page 1 of 13 Problem 1 12 points Multiple choice Write the correct answer for each question in the following table 1 2 11 12 3 4 5 6 7 8 9 10 1 Consider an int a and an int n If the value of ecx is a and the value of edx is n which of the following assembly snippets best corresponds to the C statement return a n a ret ecx edx 4 b leal ecx edx 4 eax ret c mov ecx edx 4 eax ret d mov ecx edx 1 eax ret 2 Which of the following 8 bit floating point numbers 1 sign 3 exponent 4 fraction represent NaN a b c d 1 000 1111 0 111 1111 0 100 0000 1 111 0000 3 rsp is 0xdeadbeefdeadd0d0 What is the value in rsp after the following instruction executes pushq rbx a b c d 0xdeadbeefdeadd0d4 0xdeadbeefdeadd0d8 0xdeadbeefdeadd0cc 0xdeadbeefdeadd0c8 4 How many lines does a direct mapped cache have in a set a b c d 0 1 2 4 Page 2 of 13 5 On an x86 64 Linux system which of these takes up the most bytes in memory a char a 7 b short b 3 c int c d float d 6 Two dimensional arrays are stored in order to help with cache performance a column major b row major c diagonal major d Art major 7 Which register holds the first argument when an argument is called in IA32 32 bit architecture a edi b esi c eax d None of the above 8 What is the C equivalent of mov 0x10 rax rcx 4 rdx a rdx rax rcx 4 10 b rax rcx 4 10 rdx c rdx rax rcx 4 0x10 d rdx rax rcx 4 0x10 9 What is the C equivalent of leal 0x10 rax rcx 4 rdx a rdx 10 rax rcx 4 b rdx 0x10 rax rcx 4 c rdx 0x10 rax rcx 4 d 0x10 rax rcx 4 rdx 10 What is the C equivalent of mov rax rcx a rcx rax b rax rcx c rax rcx d rcx rax Page 3 of 13 11 In x86 IA32 an application s stack grows from a High memory addresses to low memory addresses b Low memory addresses to high memory addresses c Both towards higher and lower addresses depending on the action d Stacks are a fixed size and do not grow 12 True or False In x86 64 the rbp register can be used as a general purpose register True False Page 4 of 13 Problem 2 17 points Bits A Convert the following from decimal to 8 bit two s complement 67 35 B Please solve the following are datalab style puzzle Please write brief and clear comments You may use large constants eg instead of saying 1 16 you may use 0x10000 reverseBytes reverse bytes Example reverseBytes 0x12345678 0x78563412 Legal ops int reverseBytes int x C Assume x and y are of type int For each expression below give values for x and y which make the expression false or write none if the expression is always true x y 0 x x 1 31 0x1 x x x 31 x 31 0 x 31 1 0 x y 1 Page 5 of 13 Problem 3 13 points Floats Consider a 6 bit floating point data type with 3 exponent bits and 3 fraction bits there is no sign bit so the data type can only represent positive numbers Assume that this data type uses the conventions presented in class including representations on NaN infinity and denormalized values A What is the bias B What is the largest value other than infinity that can be represented C What is the smallest value other than zero that can be represented D Fill in the following table Use round to even If a number is too big to represent use the representation of infinity and if it is too small to represent use the representation of 0 Value should be written in decimal Bits 011 000 Value 1 17 110 001 9 1 2 Page 6 of 13 Bits Value 5 111 010 3 32 8 1 2 Problem 4 11 points Structs Consider the following struct typedef struct char a 3 short b 3 double c long double d int e int f JBOB A Show how the struct above would appear on a 64 bit x86 64 Linux machine Label the bytes that belong to the various fields with their names and clearly mark the end of the struct Use x s to indicate bytes that are allocated in the struct but are not used A long double is 16 bytes long Page 7 of 13 B Rearrange the above fields in foo to conserve the most space in the memory below Label the bytes that belong to the various fields with their names and clearly mark the end of the struct Use hatch marks or x s to indicate bytes that are allocated in the struct but are not used C How many bytes are wasted in part A inside and after the struct if the next memory value is a pointer D How many bytes are wasted in part B inside and after the struct if the next memory value is a pointer Page 8 of 13 Problem 5 20 points Assembly C translation Given the x86 assembly dump please fill in the blank lines for the function in the provided C code int lolwut char s int i n n 0 for i 0 i if return 1 n return 080483a4 lolwut 80483a4 55 80483a5 89 e5 80483a7 53 80483a8 8b 5d 08 80483ab 0f b6 0b 80483ae ba 00 00 80483b3 84 c9 80483b5 74 31 80483b7 8d 41 d0 80483ba ba 00 00 80483bf 3c 09 80483c1 76 0c 80483c3 eb 1e 80483c5 83 c3 01 80483c8 8d 41 d0 80483cb 3c 09 80483cd 77 14 80483cf 8d 14 92 80483d2 0f be c1 80483d5 8d 54 50 80483d9 0f b6 4b 80483dd 84 c9 80483df 75 e4 80483e1 eb 05 80483e3 ba ff ff 80483e8 89 d0 80483ea 5b 80483eb 5d 80483ec c3 00 00 00 00 d0 01 ff ff push mov push mov movzbl mov test je lea mov cmp jbe jmp add lea cmp ja lea movsbl lea movzbl test jne jmp mov mov pop pop ret ebp esp ebp …


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

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

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?