Docsity

SPARC Assembly Instructions for CS30x Quiz 2 - Prof. Richard Ord, Quizzes of Computer Science

Toggle sidebar
bg1
Signature _______________________ Name_________________
cs30x____
Student ID ______________________ Score:
Quiz 2
CSE 30
Spring 2005
#1. a) Write the SPARC assembly instructions to define the following global variables in the data segment:
char MarsVolta[] = "The Widow";
double mirror = 420.024;
#2. What is the value (in hex) of %o1 after each set of instructions:
a) set 0xFACEBABE, %o1
sll %o1, 20, %o1
Value in %o1 at this point is 0x______________________________________________
b) set 0xFACEBABE, %o1
sra %o1, 8, %o1
Value in %o1 at this point is 0x______________________________________________
c) set 0xFACEBABE, %o1
set 0xDCDCDCDC, %o2
and %o1, %o2, %o1
Value in %o1 at this point is 0x______________________________________________
#3. Write the save SPARC instruction to allocate 3 shorts as local variables on the stack.
save %sp, ______________________________________ , %sp
(over)
pf2

Partial preview of the text

Download SPARC Assembly Instructions for CS30x Quiz 2 - Prof. Richard Ord and more Quizzes Computer Science in PDF only on Docsity!

Signature _______________________ Name_________________

cs30x____

Student ID ______________________ Score:

Quiz 2

CSE 30

Spring 2005

#1. a) Write the SPARC assembly instructions to define the following global variables in the data segment: char MarsVolta[] = "The Widow"; double mirror = 420.024;

#2. What is the value ( in hex ) of %o1 after each set of instructions:

a) set 0xFACEBABE, %o sll %o1, 20, %o

Value in %o1 at this point is 0x ______________________________________________

b) set 0xFACEBABE, %o sra %o1, 8, %o

Value in %o1 at this point is 0x ______________________________________________

c) set 0xFACEBABE, %o set 0xDCDCDCDC, %o and %o1, %o2, %o

Value in %o1 at this point is 0x ______________________________________________

#3. Write the save SPARC instruction to allocate 3 shorts as local variables on the stack.

save %sp, ______________________________________ , %sp

(over)

#4. Write the equivalent unoptimized SPARC assembly language instructions to perform the following C code fragment. Use the loop construct specified in class/Notes.

C SPARC assembly x = 6789; /* x is mapped to %l2 / / a is mapped to %l6 */ while ( x >= 195 ) { a = x - 127; --x; }

#5. Write the equivalent unoptimized SPARC assembly language instructions to perform the following C code fragment.

C SPARC assembly x = x / 4420; /* x is mapped to %l2 */

Now optimize your answer to eliminate any delay slots: Optimized version of above SPARC assembly