Exam 1: MidtermSolutions and Commentary
Part of
the homework for 22C:60, Fall 2007
|
X Median = 8.1 X X Mean = 7.73 X X X X X X X X X X X X X _____________X_____X_X_X_X_X_X_X_X_X_X_X_X_X_ 0 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10
Mean = 11.69 X X X X X X X X X X X X X X X X _______X_X_X_X_____X_X_X___X_X_X_X_X_X_X_____ 0 . 2 . 4 . 6 . 8 . 10. 12. 14. 16. 18. 20
Mean = 7.40 Median = 7.0 X X X X X X X X X X X X X X X X X ___X_______X___________X_X_X_X_X_X_X_X_X_X_X_ 0 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10
Mean = 26.07 X Median = 27.6 X X X X X X X X X _____X_X___X___X_X_____X___X_____X___X_X___X_X___X___X_X_X_X_X___X_X______ 6 . 8 . 10. 12. 14. 16. 18. 20. 22. 24. 26. 28. 30. 32. 34. 36. 38. 40 | | | | | Rough Grades: D C B A
Bit Pattern x 010010 101101 001101 101110 001110 Unsigned decimal ___18___ ___45___ 13 ___46___ ___14___ 1's complement of x _101101_ 010010 _110010_ _010001_ _110001_ 2's complement of x 101110 _010011_ _110011_ _010010_ _110010_ x as a 1's comp num ___18___ __-18___ ___13___ __-17___ 14 x as a 2's comp num ___18___ __-19___ ___13___ -18 ___14___
20 did perfectly. The negative one's complement numbers were the hardest problem here for the minority that had difficulty.
. = 0 || Address 3 2 1 0 W #01234567 || |----|----|----|----| ; --solved to here-- || 000000: | 01 | 23 | 45 | 67 | A: B A,B,C,D || |----|----|----|----| ALIGN 4 || 000004: |(0E)|(0B)|(08)|(04)| B: B B,"B",#B || |----|----|----|----| C: H #3210 || 000008: | 10)|(0B)|(42)|(08)| ALIGN 2 || |----|----|----|----| D: H #DCBA || 00000C: |(DC | BA)| |(32)| ALIGN 4 || |----|----|----|----| W #76543210 || 000010: |(76 | 54 | 32 | 10)| END || |----|----|----|----| || 000014: | | | | | |----|----|----|----|
10 did perfectly here. The values of the labels posed the greatest difficulty, with the second two being more difficult tha the first two. Some people aligned the un-aligned halfword constant #3210. At the bottom of the curve, there were those who had serious problems with B,"B",#B and those who tried to interpret #DCBA as a byte string or as labels.
|| 001000: ??E8 . = #1000 || LIL R8,ARRAY || 001002: ???? ; --solved to here-- || LIS R9,COUNT || 001004: __??D9__ LOOP: || ADDSI R9,-1 || 001006: __CF19__ BNS ENDLOOP || STORES R0,R9 || 001008: __0301__ ADDSI R8,4 || BR LOOP || 00100A: __A9F0__ ENDLOOP: || || 00100C: __C418__ || || 00100E: __FB00__
5 did perfect work, 4 switched the byte order (for 0.4 point deduction) and many made a variety of clerical errors. Only 2 got no credit.
b) What does this do? (The answer is very short.) (0.5 points)
__Iterate_through_ARRAY,_if_the_STORES_used_R8,_zero_the_array_______
3 did well, most got partial credit. Mentioning the array got partial credit.
I = 4 ; activation record field J = 8 ; activation record field K = 12 ; activation record field ARSIZE = (16) ; activation record size ROUTINE: ; expects I in R3 ; expects J in R4 STORES R1,R2 TESTR R3 BZS ROUELS TESTR R(4) BZS ROUEL(S) ; if (i != 0) && (J != 0) { STORE R3,R2,I STORE R4,R2,J ; save i and j ADDSI R3,-1 ADDI R2,R2,ARSIZE JSR R1,ROUTINE ADDI R2,R2,(-)ARSIZE STORE R3,R2,K ; k = routine( i - 1, j ) LOAD R3,R2,I LOAD R(4),R2,J ADDSI R4,-1 ADDI R2,R2,ARSIZE JSR R1,ROUTINE ADDI R2,R2,-ARSIZE ; R3 = routine( i, j - 1 ) LOAD R4,R2,(K) ADD R3,R3,R4 ; R3 = R3 + k BR ROUEX ROUELS: ; } else { LIS R3,1 ; R3 = 1 ROUEX: ; } LOADS R1,R(2) JUMPS R1 ; return R3
4 found all of the errors above, 6 more found at least 5 errors to earn full credit. The most frequently found errors were the TESTR R4 and the -ARSIZE. The least frequently noted error was the ROUELX. There were no obvious patterns in the errors people pointed out that were not really errors.