Docsity

CSE 30 Fall 2001 Midterm Exam: Computer Organization - Prof. Richard Ord, Exams of Computer Science

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

Partial preview of the text

Download CSE 30 Fall 2001 Midterm Exam: Computer Organization - Prof. Richard Ord and more Exams Computer Science in PDF only on Docsity!

Name _________________________

Signature_______________________

cs30x_______

CSE 30

Fall 2001

Midterm Exam

**1. Number Systems ___________________ (15 points)

  1. Binary Addition/Condition Code Bits/Overflow Detection ___________________ (12 points)
  2. Branching ___________________ (15 points)
  3. Bit Operations / C Runtime Environment ___________________ (16 points)
  4. Parameter Passing and Return Values (Structures) ___________________ (10 points)
  5. Local Variables, The Stack and Return Values ___________________ (14 points)**

SubTotal ___________________ (82 points)

Extra Credit ___________________ (4 points)

Total ___________________

1. Number Systems

Convert DADA 16 (2’s complement, 16-bit word) to the following. (6 points)

decimal ____________________________________

octal 0 ___________________________________

binary ____________________________________

Convert +431 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 _______________________________________________

Convert -274 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 _______________________________________________

4. Bit Operations / C Runtime Environment

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

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

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

set 0xFEEDFACE, %l sra %l0, 9, %l

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

set 0xFEEDFACE, %l set 0xCDCAB072, %l xor %l0, %l1, %l

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

Fill in the names of the 5 areas of the C Runtime Environment as layed out by most Unix operating systems. Then state what parts of a C program are in each area. (10 points) low memory

__________________________________________________________

__________________________________________________________

__________________________________________________________

__________________________________________________________

__________________________________________________________

high memory

5. Parameter Passing and Return Values (Structures)

Write the equivalent unoptimized SPARC assembly language instructions to perform the following C code frag- ment. You can assume just this one local variable. (10 points)

C SPARC assembly

/* Function Prototype */

int foo( short, char );

/* ... Other code ... */

/* Assume this local variable is declared appropriately and is the only local var. */

struct fubar { int a; char b; int c; short d; long e; } fb; /* Local variable fb */

/* ... Other code ... */

*Write the code for just this function call saving the return value appropriately /

fb.c = foo( fb.d, fb.b );

Extra Credit (4 points)

Optimize your solution to the checkRange() problem #3 earlier in this exam. The restrictions now are:

The only instructions you can use are: save , cmp , ble , bge , ba , restore , mov , ret The following instructions can be used only once: save , ble , bge , ba , restore , ret The other instructions can be used more than once: cmp , mov The only registers you can use are: %i0 , %i1 , %i Note: there can be no nops It is up to you whether you use annulled branches or not (it really doesn’t matter if you do or not).

/* int checkRange( long value, long minRange, long maxRange ); / / Return value of 0 means No, theValue was not in the range; 1 otherwise. */

Scratch Paper