Docsity

CS30 Winter 2008 Quiz 5: Compilation and Storage - Prof. Richard Ord, Quizzes of Computer Science

Toggle sidebar
bg1
Signature __________________
Name
_________________________
cs30x____
Student ID _________________ Score:
Quiz 5
CSE 30
Winter 2008
1) Which part of the entire compilation sequence clear through to program execution is responsible for:
a) ensuring the bss segment is set up and zero-filled ________________________________
b) creating an executable from multiple object files ________________________________
c) translating C source code into assembly target code ________________________________
d) resolving undefined external references with defined global references in other modules _________________
e) getting the executable image from disk into memory ________________________________
f) translating assembly source code into object target code ________________________________
Order the following storage elements/types from fastest to slowest
A) RAM (Main Memory) B) Registers C) L2 cache
D) L1 cache E) Hard disk F) Tape
______ (Fastest)
______
______
______
______
______ (Slowest)
2) What gets printed if the following function is invoked as
recurse( 3, 11 )
?
int
recurse( int a, int b ) {
int local = b - a;
int result;
if ( a < 6 )
result = local + recurse( a + 1, b );
else
result = local + 2;
printf( "%d\n", result );
return result;
}
(over)
Put answers here
pf2

Partial preview of the text

Download CS30 Winter 2008 Quiz 5: Compilation and Storage - Prof. Richard Ord and more Quizzes Computer Science in PDF only on Docsity!

Signature __________________ Name_________________________

cs30x____

Student ID _________________ Score:

Quiz 5

CSE 30

Winter 2008

1) Which part of the entire compilation sequence clear through to program execution is responsible for:

a) ensuring the bss segment is set up and zero-filled ________________________________

b) creating an executable from multiple object files ________________________________

c) translating C source code into assembly target code ________________________________

d) resolving undefined external references with defined global references in other modules _________________

e) getting the executable image from disk into memory ________________________________

f) translating assembly source code into object target code ________________________________

Order the following storage elements/types from fastest to slowest

A) RAM (Main Memory) B) Registers C) L2 cache

D) L1 cache E) Hard disk F) Tape

______ (Fastest)

______

______

______

______

______ (Slowest)

2) What gets printed if the following function is invoked as recurse( 3, 11 )?

int recurse( int a, int b ) { int local = b - a; int result;

if ( a < 6 ) result = local + recurse( a + 1, b ); else result = local + 2;

printf( "%d\n", result );

return result; }

(over)

Put answers here

3) Given the following program, reorder the printf lines so that the values that are printed are sorted from small-

est to largest if compiled and run on a Sun SPARC architecture. These lines print out the address of the different

parts of the program (not the values assigned) with the printf() format specifier %p.

int a;

int main( int argc, char *argv[] ) {

int b; static int c = 404;

/* 1 */ (void) printf( "b --> %p\n", &b );

/* 2 */ (void) printf( "a --> %p\n", &a );

/* 3 */ (void) printf( "main --> %p\n", main );

/* 4 */ (void) printf( "argc --> %p\n", &argc );

/* 5 */ (void) printf( "malloc --> %p\n", malloc(50) );

/* 6 */ (void) printf( "c --> %p\n", &c ); }

___________ This line number would print the smallest value

___________

___________

___________

___________

___________ This line number would print the largest value

4) The keyword _________________ is used to turn off optimizations in C/C++/Java.

What question would you most like to see on the Final Exam?