Docsity

SPARC Assembly Instructions and Optimization for C Code - Prof. Richard Ord, Quizzes of Computer Science

Toggle sidebar
bg1
Signature __________________ Name_________________
cs30x____
Student ID _________________ Score:
Quiz 2
CSE 30
Spring 2004
#1. a) Write the SPARC assembly instructions to define the following global variables in the data segment:
char jet[] = "Cold Hard B!!!!!";
double mint = 103.5;
short stop = -420;
#2. What is the value (in hex) of %o1 after each set of instructions:
a) set 0xCAFE5742, %o1
set 0xC359C359, %o2
btog %o2, %o1
Value in %o1 at this point is 0x______________________________________________
b) set 0xCAFE5742, %o1
sll %o1, 8, %o1
Value in %o1 at this point is 0x______________________________________________
c) set 0xCAFE5742, %o1
set 0xC359C359, %o2
or %o1, %o2, %o1
Value in %o1 at this point is 0x______________________________________________
d) set 0xCAFE5742, %o1
sra %o1, 12, %o1
Value in %o1 at this point is 0x______________________________________________
(over)
pf2

Partial preview of the text

Download SPARC Assembly Instructions and Optimization for C Code - Prof. Richard Ord and more Quizzes Computer Science in PDF only on Docsity!

Signature __________________ Name_________________

cs30x____

Student ID _________________ Score:

Quiz 2

CSE 30

Spring 2004

#1. a) Write the SPARC assembly instructions to define the following global variables in the data segment: char jet[] = "Cold Hard B!!!!!"; double mint = 103.5; short stop = -420;

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

a) set 0xCAFE5742, %o set 0xC359C359, %o btog %o2, %o

Value in %o1 at this point is 0x ______________________________________________

b) set 0xCAFE5742, %o sll %o1, 8, %o

Value in %o1 at this point is 0x ______________________________________________

c) set 0xCAFE5742, %o set 0xC359C359, %o or %o1, %o2, %o

Value in %o1 at this point is 0x ______________________________________________

d) set 0xCAFE5742, %o sra %o1, 12, %o

Value in %o1 at this point is 0x ______________________________________________ (over)

#3. Write the equivalent unoptimized SPARC assembly language instructions to perform the following C code fragment. Do not use the ba test way of setting up a loop.

C SPARC assembly for ( i = 420; i < 4902; ++i ) { /* i is mapped to %l1 / x = i / 17; / x is mapped to %l3 */ } x = x + 5;

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