DOC PREVIEW
CMU CS 15213 - Exam

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

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

Unformatted text preview:

Andrew login ID Full Name Recitation Section CS 15 213 Spring 2009 Exam 1 Tuesday February 24 2009 Instructions Make sure that your exam is not missing any sheets then write your full name Andrew login ID and recitation section A J on the front Write your answers in the space provided for 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 Pile up the easy points quickly and then come back to the harder problems This exam is OPEN BOOK You may use any books or notes you like No calculators or other electronic devices are allowed Good luck 1 16 2 22 3 13 4 13 5 22 6 14 TOTAL 100 Page 1 of 17 Problem 1 16 points Consider a new floating point format that follows the IEEE spec you should be familiar except with 3 exponent bits and 2 fraction bits and 1 sign bit Fill in all blank cells in the table below If in the process of converting a decimal number to a float you have to round write the rounded value next to the original decimal as well Description Decimal Bias Binary Representation Smallest positive number Lowest finite Smallest positive normalized 7 16 5 4 1 010 01 13 Page 2 of 17 Problem 2 22 points Consider the C code written below and compiled on a 32 bit Linux system using GCC struct s1 short x int y struct s2 struct s1 a struct s1 b int x char c int y char e 3 int z short fun1 struct s2 s return s a x void fun2 struct s2 s return s z int fun3 struct s2 s return s z short fun4 struct s2 s return s b x Page 3 of 17 a What is the size of struct s2 b How many bytes are wasted for padding You may use the rest of the space on this page for scratch space to help with the rest of this problem Nothing written below this line will be graded Page 4 of 17 c Which of the following correspond to functions fun1 fun2 fun3 and fun4 push mov mov add pop ret ebp esp ebp 0x8 ebp eax 0x1c eax ebp ANSWER push mov mov mov movswl pop ret ebp esp ebp 0x8 ebp eax 0x8 eax eax eax eax ebp ANSWER push mov mov mov pop ret ebp esp ebp 0x8 ebp eax 0x1c eax eax ebp ANSWER push mov mov movswl pop ret ebp esp ebp 0x8 ebp eax eax eax ebp ANSWER Page 5 of 17 d Assume a variable is declared as struct s2 myS2 and the storage for this variable begins at address 0xbfb2ffc0 gdb x 20w 0xbfb2ffc0 0xbfb2ffd0 0xbfb2ffe0 0xbfb2fff0 0xbfb30000 myS2 0x0000000f 0xb7f173ff 0xb7e2dfd5 0xb7e2e0b9 0x00000001 0x000000d5 0x0000012c 0xb7f15ff4 0xb7f15ff4 0xbfb30084 0xbfb2ffe8 0xbf030102 0xbfb30012 0xbfb30058 0xbfb3008c 0x00000000 0x0000000c 0x000000f3 0xb7e1adce 0xbfb30010 Fill in all the blanks below HINTS Label the fields Not all 20 words are used Remember endianness What would be returned by fun1 myS2 0x fun2 myS2 0x fun3 myS2 0x fun4 myS2 0x What is the value of myS2 b y 0x myS2 a y 0x myS2 z 0x myS2 e 1 0x Page 6 of 17 Problem 3 13 points Given the memory dump and disassembly from GDB on the next page fill in the C skeleton of the function switchfn int switchfn int a long b int y 0 x switch a b case 1 return 24 case 6 a return a case 0 return a b case 4 x a y b break case a y x case 3 b y x case 5 return a b return x y Page 7 of 17 There may be a few instructions you haven t seen before in this assembly dump data16 is functionally equivalent to nop setcc functions similarly to jcc except it will set its operand to 1 or 0 instead of jumping or not jumping respectively cqto is the 64 bit equivalent of cltd gdb x 7xg 0x4005c0 0x4005c0 IO stdin used 8 0x4005d0 IO stdin used 24 0x4005e0 IO stdin used 40 0x4005f0 IO stdin used 56 0x0000000000400476 0x000000000040047b 0x0000000000400480 0x0000000000400483 0x0000000000400487 0x000000000040048b 0x000000000040048d 0x0000000000400494 0x0000000000400499 0x000000000040049a 0x000000000040049d 0x000000000040049e 0x000000000040049f 0x00000000004004a0 0x00000000004004a1 0x00000000004004a4 0x00000000004004a5 0x00000000004004a7 0x00000000004004aa 0x00000000004004ac 0x00000000004004ae 0x00000000004004b1 0x00000000004004b4 0x00000000004004b6 0x00000000004004b9 0x00000000004004bc 0x00000000004004bf 0x00000000004004c1 0x00000000004004c4 0x00000000004004c5 0x00000000004004c7 0x00000000004004ca 0x00000000004004cd 0x00000000004004a1 0x00000000004004ac 0x00000000004004a5 0x000000000040049a switchfn 0 switchfn 5 switchfn 10 switchfn 13 switchfn 17 switchfn 21 switchfn 23 switchfn 30 switchfn 35 switchfn 36 switchfn 39 switchfn 40 switchfn 41 switchfn 42 switchfn 43 switchfn 46 switchfn 47 switchfn 49 switchfn 52 switchfn 54 switchfn 56 switchfn 59 switchfn 62 switchfn 64 switchfn 67 switchfn 70 switchfn 73 switchfn 75 switchfn 78 switchfn 79 switchfn 81 switchfn 84 switchfn 87 Page 8 of 17 mov mov movslq imul cmp ja jmpq mov retq lea data16 data16 nop retq lea retq mov imul jmp cmp sete movzbl cmp setl movzbl movslq cqto idiv retq cmp sete movzbl retq 0x0000000000400494 0x00000000004004b4 0x00000000004004bc 0x0 ecx 0xdeadbeef edx edi rax rsi rax 0x6 rax 0x4004c5 switchfn 79 0x4005c0 rax 8 0x18 eax rdx rsi 4 eax rdi rsi 1 eax edi edx esi ecx 0x4004c5 switchfn 79 edx ecx al al edi edx ecx al al esi edi rax rsi ecx edx al al eax Problem 4 13 points The function below is hand written assembly code for a sorting algorithm Fill in the blanks on the next page by converting this assembly to C code globl mystery sort mystery sort jmp exports the symbol so other c files can call the function loop1 check loop1 xor mov jmp rdx rdx rsi rcx loop2 check mov cmp jg mov rdi rcx 8 rax rax rdi rdx 8 loop2 check rcx rdx loop2 loop2 check dec test jnz dec mov mov mov mov loop1 check test jnz rcx rcx rcx loop2 rsi rdi rsi rdi rdx rcx rdi rax rdi 8 rax 8 rcx rsi 8 rdx 8 rsi rsi loop1 ret Page 9 of 17 void mystery sort long array long len long a b tmp while a for b b b if array array len tmp array array array array tmp Page 10 of 17 Problem 5 22 points Circle the correct answer 1 What sequence of operations does the leave instruction execute a mov ebp esp pop ebp b pop ebp mov ebp esp c pop esp mov ebp esp d push ebp mov esp ebp 2 Who is responsible for storing the return address of a function call a the caller b the callee c the kernel d the CPU 3 On what variable types does C perform logical right shifts a signed types b unsigned types c signed and unsigned types d C does not perform logical right shifts 4 What is the difference between the rbx and the ebx register on an x86 64 machine a nothing they are the same register b ebx refers to only the low order 32 bits of the rbx register


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

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

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?