CS30 Spring 2010 Quiz 4 Solutions - Prof. Richard Ord, Quizzes of Computer Science

Solutions to quiz 4 of the cs30 course offered in spring 2010. It covers topics such as sparc architecture, fixed-point and floating-point conversions, and the c runtime environment.

Typology: Quizzes

2010/2011

Uploaded on 06/06/2011

koofers-user-nmt
koofers-user-nmt 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Signature __________________
Name_______________
cs30x____
Student ID _________________
Score:
Quiz 4
CSE 30
Spring 2010
#1. In the SPARC architecture, to access local variables allocated on the stack you would use a _____________
(positive or negative) offset relative to register ____________.
The _________________ SPARC instruction saves the current value of %pc into %o7.
The _________________ SPARC instruction adds ____to the value in %i7 and sets %pc with the result.
Using the Rt-Lt Rule, define a variable named foo that is a pointer to a function that takes a pointer to a double
as its single argument and returns a pointer to a stuct fubar.
#2. a) Convert 97.875
10
to binary fixed-point and single precision IEEE floating-point representation
(expressed in hexadecimal).
binary fixed-point __________________________________ x 2
0
IEEE floating-point _______________________________________ (hexadecimal)
b) Convert 0xC27E8000 (single precision IEEE floating-point representation) to fixed-point decimal.
fixed-point decimal ______________________________ (decimal / no exponential notation)
(over)
pf2

Partial preview of the text

Download CS30 Spring 2010 Quiz 4 Solutions - Prof. Richard Ord and more Quizzes Computer Science in PDF only on Docsity!

Signature __________________ Name_______________

cs30x____

Student ID _________________ Score:

Quiz 4

CSE 30

Spring 2010

#1. In the SPARC architecture, to access local variables allocated on the stack you would use a _____________

(positive or negative) offset relative to register ____________.

The _________________ SPARC instruction saves the current value of %pc into %o7.

The _________________ SPARC instruction adds ____to the value in %i7 and sets %pc with the result.

Using the Rt-Lt Rule, define a variable named foo that is a pointer to a function that takes a pointer to a double

as its single argument and returns a pointer to a stuct fubar.

#2. a) Convert 97.875 10 to binary fixed-point and single precision IEEE floating-point representation

(expressed in hexadecimal ).

binary fixed-point __________________________________ x 2^0

IEEE floating-point _______________________________________ ( hexadecimal )

b) Convert 0xC27E8000 (single precision IEEE floating-point representation) to fixed-point decimal.

fixed-point decimal ______________________________ ( decimal / no exponential notation)

(over)

#3. Given

int a = 420; static void fubar( int b ) { static int c; int *d = &b; ... }

When this function is called, identify which area of the C Runtime Environment each of the following will be

allocated and its scope or visibility.

Area of Runtime Env. Scope/Visibility (Global/File/Function)

a ____________ ___________

b ____________ ___________

c ____________ ___________

d ____________ ___________

fubar ____________ ___________

Where d

is pointing ____________

If the function above is called 5 times, indicate how many times will d be initialized to &b? _________

#4. What gets printed with the function call mystery( 11 );? (Hint: Draw stack frames!)

int mystery( int param ) { int local = 5;

if ( local < param ) { local = local + param; printf( "%d\n", local ); /* Output the value of local followed by a newline / param = mystery( param - 2 ) + local; printf( "%d\n", param ); / Output the value of param followed by a newline */ } else { printf( "Stop\n" ); }

return local; }

Put answer here