Docsity

Quiz #2 - Computer Organization and Systems Programming | CSE 30, Quizzes of Computer Science

Toggle sidebar
bg1
Name:
cs30x____
Score:
Quiz 2
CSE 30
Spring 2001
#1. a) Write the SPARC assembly instructions to define the following global variables in the data segment:
char ch = ’a’;
int i = 405;
char *fmt = “Hello World\n”;
#2. What is the value (in hex) of %o1 after each set of instructions:
a) set 0xDEADF00D, %o1
sll %o1, 12, %o1
Value in %o1 at this point is 0x______________________________________________
b) set 0xDEADF00D, %o1
sra %o1, 20, %o1
Value in %o1 at this point is 0x______________________________________________
c) set 0xDEADF00D, %o1
set 0x9C9C9C9C, %o2
and %o1, %o2, %o1
Value in %o1 at this point is 0x______________________________________________
d) set 0xDEADF00D, %o1
set 0x9C9C9C9C, %o2
btog %o2, %o1
Value in %o1 at this point is 0x______________________________________________
(over)
pf2

Partial preview of the text

Download Quiz #2 - Computer Organization and Systems Programming | CSE 30 and more Quizzes Computer Science in PDF only on Docsity!

Name:

cs30x____

Score:

Quiz 2

CSE 30

Spring 2001

#1. a) Write the SPARC assembly instructions to define the following global variables in the data segment: char ch = ’a’; int i = 405; char *fmt = “Hello World\n”;

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

a) set 0xDEADF00D, %o sll %o1, 12, %o

Value in %o1 at this point is 0x ______________________________________________

b) set 0xDEADF00D, %o sra %o1, 20, %o

Value in %o1 at this point is 0x ______________________________________________

c) set 0xDEADF00D, %o set 0x9C9C9C9C, %o and %o1, %o2, %o

Value in %o1 at this point is 0x ______________________________________________

d) set 0xDEADF00D, %o set 0x9C9C9C9C, %o btog %o2, %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.

C SPARC assembly

x = -8118; /* x is mapped to %l4 */

do { x = x + 15; --x; } while( x <= 420 );

Now optimize your answer to eliminate any delay slots:

Optimized version of above SPARC assembly