CS30 Spring 2007 Quiz 3 - Assembly Instructions and Array Index Access - Prof. Richard Ord, Quizzes of Computer Science

The instructions for allocating stack space and writing unoptimized sparc assembly instructions for local variables, as well as the equivalent c expression for array index access.

Typology: Quizzes

2010/2011

Uploaded on 06/07/2011

koofers-user-iew
koofers-user-iew 🇺🇸

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 3
CSE 30
Spring 2007
#1.
a) Write the appropriate save instruction to allocate stack space for the following local variables and any
padding.
short a;
char b;
unsigned short c;
int d;
char e;
float f;
save _________ , ______________________________ , _________
(Use the formula, not an absolute value)
b) Write the appropriate unoptimized SPARC assembly instructions using the above local variables.
d = b;
a = -9876;
e = ’B’;
a = c;
(OVER)
pf2

Partial preview of the text

Download CS30 Spring 2007 Quiz 3 - Assembly Instructions and Array Index Access - Prof. Richard Ord and more Quizzes Computer Science in PDF only on Docsity!

Signature __________________ Name___________________

cs30x____

Student ID _________________ Score:

Quiz 3

CSE 30

Spring 2007

a) Write the appropriate save instruction to allocate stack space for the following local variables and any

padding.

short a; char b; unsigned short c; int d; char e; float f;

save _________ , ______________________________ , _________

(Use the formula, not an absolute value)

b) Write the appropriate unoptimized SPARC assembly instructions using the above local variables.

d = b;

a = -9876;

e = ’B’;

a = c;

(OVER)

#2. a) Write the appropriate save instruction to allocate stack space for the following local variable declaration.

short a[9];

save _________ , ______________________________ , _________

(Use the formula, not an absolute value)

b) Write the appropriate instructions to perform the following assignment statements.

a[7] = a[4];



a[5] = a[1];



short ptr; / ptr mapped to %l5 */

ptr = &a[1];


++ptr; /* ptr mapped to %l5 */


short d = ptr; / d mapped to %l2; ptr to %l5 */


ptr = d; / d mapped to %l2; ptr to %l5 */


#3. Write the equivalent C expression for an array index access. Remember scaling is done automatically by

the compiler.

float a[10];

a[i] is equivalent to _____________________________ (equivalent pointer expression).