Exam 3: Final
Part of
the homework for 22C:60, Summer 2005
|
Median = 10.1 X X X ___________X___X_X_X___X___X_X___X_____X_____ 0 . 2 . 4 . 6 . 8 . 10. 12. 14. 16. 18. 20
Mean = 23.8 X X X ______________X_X_X_________X_______X_____X___X_____X_X______________ 8 . 10. 12. 14. 16. 18. 20. 22. 24. 26. 28. 30. 32. 34. 36. 38. 40.
Mean = 22.6 X X X X X X ____________________X___________________X_X_____X_X_X_ 0 . 2 . 4 . 6 . 8 . 10. 12. 14. 16. 18. 20. 22. 24.
Mean = 23.5 X X X X ________________________________X_______X___X_X_______X_X_X_X____ 0 . 2 . 4 . 6 . 8 . 10. 12. 14. 16. 18. 20. 22. 24. 26. 28. 30
Mean = 70.0 X __X_____________X_X___X_____X_____X___X_X_X___X_X________________ 40. 44. 48. 52. 56. 60. 64. 68. 72. 76. 80. 84. 88. 92. 96. 100 | - D + | - C + | - B + | - A + |
JUMPS R1 ; return subroutine A _ALIGN_ _4_____ PSTR: W STR _______ _______ STR: ASCII "A longish string",0 _______ _______ COMMON BVAR,4 ; used only by subroutine B _ALIGN_ _4_____ PBVAR: W BVAR _______ _______ ARSIZE = 4 ; size of subroutine B AR _______ _______ B: STORES R1,R2 ; entry point of subroutine B
Note that the second ALIGN directive could optionally be put before the COMMON, and note that a third ALIGN directive is within reason before the final line, but this should align to the halfword, not the word.
Only one did perfectly here. 4 filled in 6 ALIGN directives, an additional 3 added unnecessary alignment before the ASCII directive and an additional 2 added unnecessary alignment before the definition of ARSIZE. 5 forgot to align after the first line (an instruction) before the word at PSTR.
a)
If a = 0000 and b0 = 1, what will the output be?
(1 point)
m = __1111__
b4 = _1__
5 did well here, 4 had difficulty with m, and 2 had difficulty with b4.
ai | bi | mi | bi+1 | |
---|---|---|---|---|
0 | 0 | 0 | 0 | |
0 | 1 | 1 | 1 | |
1 | 0 | 1 | 0 | |
1 | 1 | 0 | 0 |
5 did well here. Among those who had difficulty, the most common errors involved wrong outputs on rows 10 and 11 of the truth table.
c) Draw the logic circuit, using standard symbols for logic gates (and, or, not, xor, etc) in the space below. (2 points)
4 did well here, with 2 giving the circuit shown on the left and 2 giving variations on the circuit to the right. Three earned partial credit for circuits that gave at least one correct output that in some way matched the contents filled into the truth table for part b).
a) Show, on the following diagram, where the point goes: (1/2 point)
__ __ __ __ __ __ __ __ |__|__|__|__|__|__|__|__| o
8 got this, while on the other extreme, 2 had odd answers with the point way out in the middle of the byte.
b) What is the smallest positive nonzero value in this system? Give your answer as a fraction in the form 1/n. (1/2 point)
_____ 1/128 ___________
8 got this, a few gave answers that were incompatable with the answer given for part a), and one gave an answer that was very strange.
__ __ __ __ __ __ __ __ |__|__|__|__|__|__|__|__| (s is the sign of the mantissa) |s | exponent |fractional magnitude of the mantissa
The value 01111111 is the closest possible approximation of +1 in this system.
a) What is the exact value of 01111111 in this system? (1 point)
____ 7/8 or 0.875 ____
b) What are the maximum and minimum exponent values (in decimal)? (1 point)The reasoning behind this is as follows: The least significant 3 bits are 111, and the format declares these to be the fractional magnitude of the mantissa, so they must represent 0.111 or 7/8. We know that this is the closest possible approximation of +1 in this system, so the exponent 1111 must mean zero so that this is 7/8×20.
4 got this, while 5 earned partial credit for 0.9375 or 15/16ths. Presumably, those students forgot that the most significant bit of the mantissa was the sign, so there were only 3 fractional bits.
1111 = _____ 0 ______________ 0000 = _____ -15 ____________
The reasoning behind concluding that 1111 is the largest possible exponent value follows from 01111111 being the closest possible approximation of +1 in this system. Since we are uninterested in representing any numbers above 1, other exponent values must be negative, so 4 bits gives the range from 0 to -15. If we use either a biased system (with a bias of 15) or a one's complement system for the exponent, the representation of -15 comes out as 0000.
2 gave this answer, 5 earned partial credit for flipping the sign of one or the other answer (-0 to +15) or off-by-one errors (1 to -14) or off-by-one errors in the exponent (-7).
c) Therefore, what is the smallest positive nonzero non-normalized number in this system? Give your answer as a fraction in the form 1/n. (1 point)
___ 1/262144 _________
This is 0.0012 × 2-15. Note that 0.001 is not normalized! The smallest normalized fraction is 0.100.6 got this right, in light of their answers to part b). Some had very odd answers such as 2-3 or 2-48.
MOVE R4,R3 ; copy number in this form ...sxxxxmmm TRUNC R4,3 ; clip off to so it is ...000000000mmm SL R4,14 SL R4,14 ; shift over so it is 0.mmm00000000... BITTST R3,7 ; test sign of original mantissa BCR NOTNEG NEG R4,R4 ; negate if required NOTNEG:
Nobody gave perfect answers. 1 forgot to convert from signed magnitude to two's complement, 2 forgot to shift the result 28 places left. 2 more gave relevant code fragments that did not accomplish much for partial credit. The remainder gave irrelevant code that did nothing except waste time for both the student and grader.
a) Give an appropriate SMAL definition for VA, including any auxiliary material you might need in order to address the variable. (1 point)
COMMON VA,8 PVA: W VA
5 did well here, while 3 earned partial credit for missing the block size or using the wrong block size (64 bit variables require 8 bytes each).
b) Give appropriate SMAL definitions for the entire activation record of the current routiine, VB, assuming that it is the only local variable. (1 point)
;RA = 0 VB = 4 ARSIZE = 12;
c) Give appropriate SMAL Hawk code to be included as part of the body of the current routine, using your definitions above, to load a pointer to VA in R3 and a pointer to VB in R4. (1 point)5 did well here, while 5 earned partial credit for giving the wrong activation record size in the context of the fields they'd included in the activation record.
LOAD R3,PVA LEA R4,R2,VB
3 gave essentially this. 5 had trouble with the LEA, using LOAD instead. 6 loaded the pointer to VA correctly but had trouble dealing with VB.
d) Assuming that a pointer to VA has been loaded in R3 and a pointer to VB has been loaded in R4, write code to copy the 64-bit value of VA to VB. (1 point)
LOADS R5,R3 STORES R5,R4 LOAD R5,R3,4 STORE R5,R4,4
3 gave good answers, and one of these gave correct answers to all 4 parts of the question. Partial credit here was rare, since most of the wrong answers appeared to have no connection to the question.
LIW R3,#FF100100 POLL: LOADS R4,R3 BITTST R4,0 BCR POLL
3 gave good answers. 3 lost credit for problems with the LOADS instruction, 1 lost credit for problems with BITTST, and 3 lost for using BZR to test the result of the BITTST instruction. Of those who earned no credit, most gave answers that had extremely tenuous connections to the problem.