Docsity

CSE 30 Summer 2000 Midterm Exam - Computer Science - Prof. Richard Ord, Exams of Computer Science

Toggle sidebar
bg1
1
Name _________________________
Signature_______________________
cs30x_______
CSE 30
Summer 2000
Midterm Exam
1. Number Systems ___________________ (15 points)
2. Binary Addition/Condition Code Bits/Overflow Detection ___________________ (12 points)
3. Branching ___________________ (13 points)
4. Bit Operations ___________________ (10 points)
5. Parameter Passing and Return Values ___________________ (12 points)
6. Local Variables, The Stack, and Return Values ___________________ (18 points)
SubTotal ___________________ (80 points)
Extra Credit ___________________ (4 points)
Total ___________________
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download CSE 30 Summer 2000 Midterm Exam - Computer Science - Prof. Richard Ord and more Exams Computer Science in PDF only on Docsity!

Name _________________________

Signature_______________________

cs30x_______

CSE 30

Summer 2000

Midterm Exam

**1. Number Systems ___________________ (15 points)

  1. Binary Addition/Condition Code Bits/Overflow Detection ___________________ (12 points)
  2. Branching ___________________ (13 points)
  3. Bit Operations ___________________ (10 points)
  4. Parameter Passing and Return Values ___________________ (12 points)
  5. Local Variables, The Stack, and Return Values ___________________ (18 points)**

SubTotal ___________________ (80 points)

Extra Credit ___________________ (4 points)

Total ___________________

1. Number Systems

Convert EBBE 16 (2โ€™s complement, 16-bit word) to the following. (6 points)

decimal ____________________________________

octal 0 ___________________________________

binary ____________________________________

Convert -171 10 to the following (assume 16-bit word). Express answers in hexadecimal. (6 points)

sign-magnitude 0x _______________________________________________

1โ€™s complement 0x _______________________________________________

2โ€™s complement 0x _______________________________________________

Convert +142 10 to the following (assume 16-bit word). Express answers in hexadecimal. (3 points)

sign-magnitude 0x _______________________________________________

1โ€™s complement 0x _______________________________________________

2โ€™s complement 0x _______________________________________________

4. Bit Operations

What is the value of %l0 after each statement is executed? Express your answers in hexadecimal.

set 0xBEADFDAD, %l set 0xB9653, %l or %l0, %l1, %l

Value in %l0 is 0x _______________________________________ (2 points)

set 0xBEADFDAD, %l sll %l0, 11, %l

Value in %l0 is 0x _______________________________________ (2 points)

set 0xBEADFDAD, %l sra %l0, 5, %l

Value in %l0 is 0x _______________________________________ (2 points)

set 0xBEADFDAD, %l set 0xB65, %l xor %l0, %l1, %l

Value in %l0 is 0x _______________________________________ (2 points)

Write the single SPARC assembly instruction to multiply the value in %l0 by 1024 without the use of .mul. Store the result back in %l0. (2 points)

____________________________________________

5. Parameter Passing and Return Values

Write the equivalent unoptimized SPARC assembly language instructions to perform the following C code frag- ment. (10 points)

C SPARC assembly

x = foo( 172, -9876 ); /* x is mapped to %l0 */

Now optimize your answer to eliminate any delay slots. (2 points)

Optimized version of above SPARC assembly

Extra Credit

Optimize the following SPARC assembly language code fragment. There may be many ways of optimizing this code fragment, but some optimizations may be better than others. The better optimizations eliminate as many cycles as possible. The better optimizations get more points. (4 points)

Unoptimized Version Optimized Version

/* some code above here */

mov %l0, %o mov 16, %o call .mul nop

mov %o0, %l

add %fp, array_offset, %l ldub [%l2 + %l1], %l cmp %l3, โ€™\nโ€™ be no_inc nop

inc %l

no_inc:

/* other code */

Scratch Paper