Computer Science 281
Hour Exam #1
Name
____________________________
Friday, Feb. 20
100 pts.
1. (5 pts.) Fit nop’s into the following code to make it work correctly (i.e., assuming that the programmer is not trying to be careful, but just forgot the nop’s). Don’t try to make too much sense of the code fragment.
mov %i0, %o0
mov %i1, %o1
call .mul
tst %o0
beq one
add %i0, 1, %i0
2. (5 pts.) What is the value of %i1 after the conclusion of the following code, if
%i0 is 0? :
%i0 is 1? :
clr %i1
tst %i0
be, a one
mov 1, %i1
one: rest of the program
3. (20 pts.) Consider the following bit of code:
int
while (a != b) /* while a is not equal to b */
{
if (a < b) b = b-a; else a = a – b;
}
return a;
Implement this in a complete assembly language subroutine. An example of the usage of the subroutine is:
mov 12, %i0
mov 15, %i1
call
4. (15 pts.) Briefly describe the instruction-fetch-execute cycle and explain how pipelining helps increase throughput (i.e., helps increase the number of instructions that can be processed in a given period of time). What are some of the problems?
5. (5 pts. each)
Suppose that X = ox1b, Y = oxe, and X = ox5. Calculate (showing work for the arithmetic problems:
X + Y
X AND Y
(continued on next page)
(continuation of problem #5)
X XOR Y
X divided by Z. Show your work, and identify quotient and remainder.
6. (10 pts.) Write down the internal representation of the integer -27. Give your answer in hex, and use 32 bits for an integer.
7. (10 pts.) Show (i.e., draw a circuit diagram) how a transistor may be used to implement an inverter.
8. (5 pts.) Suppose x is low (x = 0), and y is high (y = 1). What is the output (Z) of the following circuit? Indicate the value after each gate. Please notice that we have NAND, NOR, and AND gates in the following:
9: (10 pts.) Using the systematic process discussed in class for one-output circuits, draw the diagram (using AND, OR, and Inverter gates) for the following truth table:
X |
Y |
OUT |
0 |
0 |
1 |
0 |
1 |
1 |
1 |
0 |
0 |
1 |
1 |
1 |