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 Tues 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 6 16 6 4 1 010 10 11 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 int y short x struct s2 struct s1 a struct s1 b int x char c int y char e 5 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 movswl pop ret ebp esp ebp 0x8 ebp eax 0x4 eax eax ebp ANSWER push mov mov mov movswl pop ret ebp esp ebp 0x8 ebp eax 0x8 eax eax 0x4 eax eax ebp ANSWER push mov mov mov pop ret ebp esp ebp 0x8 ebp eax 0x20 eax eax ebp ANSWER push mov mov add pop ret ebp esp ebp 0x8 ebp eax 0x20 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 0xbfbdc300 gdb x 20w myS2 0xbfbdc300 0x000000d5 0xbfbdc310 0x000000ff 0xbfbdc320 0x0000000c 0xbfbdc330 0xb7ed9fd5 0xbfbdc340 0xb7eda0b9 0x0000000f 0x0000012c 0x080496a0 0xb7fc1ff4 0xb7fc1ff4 0xbfbdc338 0x01020501 0xbfbdc338 0x000000f3 0xbfbdc3a8 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 0x00000000 0xb7f0a603 0x0804828d 0x08040012 0xb7ec6dce Problem 3 13 points This problem concerns assembly code generated by GCC for a function containing a switch statement on an x86 64 machine Below is the entire assembly dump of the function selector whose C skeleton is given subsequently 0000000000400470 selector 400470 8d 46 01 400473 83 f8 06 400476 77 1a 400478 89 c0 40047a ff 24 c5 a0 05 40 00 400481 48 83 c7 04 400485 eb 0e 400487 8b 37 400489 eb 0a 40048b d1 fe 40048d 83 c6 05 400490 eb 03 400492 8d 34 f6 400495 48 63 c6 400498 8b 04 87 40049b c3 lea cmp ja mov jmpq add jmp mov jmp sar add jmp lea movslq mov retq 0x1 rsi eax 0x6 eax 400492 selector 0x22 eax eax 0x4005a0 rax 8 0x4 rdi 400495 selector 0x25 rdi esi 400495 selector 0x25 esi 0x5 esi 400495 selector 0x25 rsi rsi 8 esi esi rax rdi rax 4 eax The code at line 40047a uses an indirect jump to index into a jump table 40047a ff 24 c5 a0 05 40 00 jmpq 0x4005a0 rax 8 In GDB we examine the memory dump at address 0x4005a0 which produces the following output gdb x 8g 0x4005a0 0x4005a0 0x0000000000400487 0x4005b0 0x0000000000400492 0x4005c0 0x000000000040048b 0x4005d0 0x0000000000400481 0x0000000000400481 0x000000000040048d 0x0000000000400492 0x0000002c3b031b01 Page 7 of 17 Fill in the blank portions of C code below to reproduce the function corresponding to this object code int selector int x int y switch y case case break case y break case y case y break default y return Page 8 of 17 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 dec exports the symbol so other c files can call the function rsi xor inc jmp rdx rdx rdx loop1 check xor mov jmp rdx rdx rsi rcx loop2 check dec mov mov cmp jle mov mov inc rcx 8 rdi rcx 8 r8 rdi rcx 8 r9 r8 r9 loop2 check r8 rdi rcx 8 r9 8 rdi rcx 8 rdx loop1 loop2 loop2 check test jnz rcx rcx loop2 loop1 check test jnz rdx rdx loop1 ret Page 9 of 17 void mystery sort long array long len long a b tmp do a for b b b if array array tmp array array array array tmp a while a Page 10 of 17 Problem 5 22 points Circle the correct answer 1 What register is the return value from a function stored in Assume 32 bit return value a eip b ebp c eax d esp 2 The pushl instruction does what to the stack pointer a decrements the stack pointer by 4 bytes b decrements the stack pointer by 1 byte c increments the stack pointer by 4 bytes d increments the stack pointer by 1 byte 3 What does the test instruction do before setting condition flags a bitwise and b subtraction c bitwise xor d bitwise bang 4 On the x86 64 fish machines what is the size of an int a 1 byte b 32 bytes c 4 bytes d 8 bytes 5 Which of the following represents the order of the registers that store the first four arguments to a function in x86 64 a rdi rsi rcx rdx b rax rbx rsi rdi c rsi rdi rdx rbx d rdi rsi rdx rcx Page 11 of 17 6 The operator performs what operation on a value a bitwise complement b logical complement c reverses the order of the bits d determines if the number is zero 7 What byte ordering system do the fish machines use a Little endian b Big endian c Intel x86 64 …


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

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

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?