Exam 1: MidtermSolutions and Commentary
Part of
the homework for 22C:60, Fall 2010
|
Mean = 6.69 X X Median = 6.9 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 ^ ^
X X X Mean = 8.50 X Median = 9.0 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.94 Median = 13.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___ . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10. 11. 12. 13. 14. 15. 16. 17. 18. ^ ^
Mean = 27.12 Median = 29.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__ . 10. 12. 14. 16. 18. 20. 22. 24. 26. 28. 30. 32. 34. 36. 38. ^ ^
| 10 | 9 | 3 8 | 1 1 7 | 1 1 4 Conclusion: 6 | 1 2 2 EX 5 | 2 2 Effort put into doing the 4 | 1 machine problems pays off 3 | 1 1 1 on the exams. 2 | 1 | 0_|_______________________ |0 1 2 3 4 5 6 7 8 9 10 MP
Bit Pattern x 011000 101000 110110 000010 110111 Unsigned decimal ___24___ ___40___ 54 ____2___ ___55___ 1's complement of x _100111_ 010111 _001001_ _111101_ _001000_ 2's complement of x 101000 _011000_ _001010_ _111110_ _001001_ x as a 1's comp num ___24___ __-23___ ___-9___ ____2___ -8 x as a 2's comp num ___24___ __-24___ __-10___ 2 ___-9___
13 had perfect scores, 5 or more had trouble with each of the one's complement numbers, positive or negative, while 2 or more had trouble with the negative two's complement numbers.
. = 0 || Address 3 2 1 0 H #4567,#0123 || |----|----|----|----| ; --solved to here-- || 000000: | 01 | 23 | 45 | 67 | A: W #89ABCDEF || |----|----|----|----| ALIGN 4 || 000004: |(89 | AB | CD | EF)| B: B C || |----|----|----|----| C: H #2468 || 000008: | |(24 | 68)|(09)| ALIGN 2 || |----|----|----|----| D: B #C,"C" || 00000C: | | |(43 | 0C)| ALIGN 4 || |----|----|----|----| B D,C,B,A || 000010: |(04)|(08)|(09)|(0C)| END || |----|----|----|----| || 000014: | | | | | |----|----|----|----|
6 did perfect work, 2 earned no credit at all. 5 or more had difficulty with questions byte order. 5 or more had difficulty with the aligh directives. The translation of ASCII "C" posed problems for 6 or more. The label C posed special problems for at least 4.
|| Label Opcode Operands 001000: 00D3 || LIS R3,0 || _____ ______ ________________ 001002: E400 || BR (way back somewhere) || _____ ______ ________________ 001004: 0603 || BVS (forward just beyond) || _____ ______ ________________ 001006: 3533 || L: ADD R3,R3,R5 || _____ ______ ________________ 001008: CF14 || ADDSI R4,-1 || _____ ______ ________________ 00100A: FD0E || BGT L || _____ ______ ________________
1 did perfect work, 5 earned no credit (2 of which left the problem blank). 8 or more had trouble with all of the branches. The ADDSI posed problems for 6. 4 gaven +15 instead of -1 as the operand on the ADDSI.
Note that there was an error in the preparation of this exam leading to an incorrect problem statement in the first two instructions. As a result, the code did not make as much sense as it was supposed to.
b) What does this do? (The answer is very short.) (0.5 points)
__Add_up_some_numbers_or_branch_away_around_this_nonsense__
Most left this blank or wrote nonsense that had little connection to their answers to part a. One noticed that there was a loop adding up some numbers, the other commented correctly that, because of the error, the code began with a branch to somewhere else.
SUBTITLE "PLOT routine" ; activation record of plot XCOORD = 4 ; x coordinate YCOORD = 6 ; y coordinate ;#### 6; should be 8 ARSIZE = 8 ;#### 8; should be 12 PLOT: ; plot a recursively defined series of x marks ; expects R3,R4 - x and y coordinate ; conforms to usual calling conventions STORES R1,R2 STORE R3,R2,XCOORD STORE R4,R2,YCOORD ADDI R2,R2,ARSIZE LIL R1,DSPAT JSRS R1,R1 ; dspat( xcoord, ycoord ) LIS R3,"x" LIL R1,DSPCH JSRS R1,R1 ; dspch( 'x' ) ADDI R2,R2,ARSIZE ; #### 13; should be -ARSIZE LOADCC R3,R2,XCOORD ; if ((xcoord > 0) BLE PLOTQT ; #### 3; should be BGT PLOTON LOADCC R4,R2,YCOORD BLE PLOTQT ; || (ycoord > 0)) { PLOTON: LOAD R4,R2,YCOORD SR R3,1 SR R4,2 ; #### 14; should be R4,1 ADDI R2,R2,ARSIZE JSR R1,PLOT ; plot(xcoord/2,ycoord/2) ADDI R2,R2,-ARSIZE PLOTQT: ; } LOADS R1,R1 ; #### 8; should be R1,R2 JUMPS R1 ; return
Changes above are shown with ####. The number of students who correctly fixed the problem is given before the correction. Nobody got all of the changes, and there were penalties for adding changes that further broke the code. Several students noted that the above code is partially optimized and made an effort to further optimize this code. If the changes they proposed made no damage, there was no penalty for this. Several students noticed the problem with the BGT instruction, but did additional damage in their effort to correct it.