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

The sparc assembly instructions to define global variables and performs optimization on a given c code fragment. It includes instructions to set and manipulate registers, as well as an optimized version of the assembly code.

Typology: Quizzes

2010/2011

Uploaded on 06/07/2011

koofers-user-xut
koofers-user-xut 🇺🇸

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 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