Exam 1: MidtermCommentary and Solutions
Part of
the homework for 22C:60, Spring 2005
|
X X Mean = 8.27 X Median = 8.5 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_X_ 0 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10.
Mean = 10.75 X X Median = 10.5 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_X_X___ 0 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10. 11. 12. 13. 14. 15
X Mean = 18.70 X X X X Median = 18.9 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. 22. 24. 26 A very rough grade scale F D C B A
Bit Pattern x 101100 001101 010001 100111 010111 Unsigned decimal ___44___ ___13___ 17 ___39___ ___23___ 1's complement of x _010011_ 110010 _101110_ _011000_ _101000_ 2's complement of x 010100 _110011_ _101111_ _011001_ _101001_ x as a 1's comp num __-19___* ___13___ ___17___ __-24___* 23 x as a 2's comp num __-20___ ___13___* ___17___* -25 ___23___*
19 students did perfect work here, but 1/4 of the class made more than 3 errors. Stars above indicate problems where more than 6 students made mistakes.
. = 0 || Address 3 2 1 0 W #01234567 || |----|----|----|----| ; --solved to here-- || 000000: | 01 | 23 | 45 | 67 | A: B #01, #23 || |----|----|----|----| ALIGN 4 || 000004: | ? | ? | 23 | 01 | B: H #ABCD || |----|----|----|----| ALIGN 4 || 000008: | ? | ? | AB | CD | C: B #34 || |----|----|----|----| ALIGN 2 || 00000C: | 42 | 41 | ? | 34 | D: ASCII "ABCD" || |----|----|----|----| ALIGN 4 || 000010: | ? | ? | 44 | 43 | B D,C,B,A || |----|----|----|----| END || 000014: | 04 | 08 | 0C | 0E | |----|----|----|----|
Half the class scored above 1.6, 1/4 scored below 1.2. The hardest problem was getting the corrrect values for the labels A, B, C and D assembled into the 4 bytes at address 1416; half the class had problems here. The next hardest problem was the ASCII text, wheree 1/4 of the class had difficulty. The ALIGN 2 directive also caused difficulty for a similar number.
|| 000100: D300 LIS R3,0 || ; --solved to here-- || 000102: __14CF__ LAB1: || ADDSI R4,-1 || 000104: __0102__ ** BNS LAB2 || ADD R3,R3,R5 || 000106: __3335__ BR LAB1 || LAB2: || 000108: __00FC__ * || || 00010A: ________
Half the class earned at least 1.7, but 1/4 earned 11.4 or less. Stars indicate difficulty. Branch displacements were a problem for half the class, and getting the correct opcode for BNS was a problem for 1/4 of the class.
Extra Credit: What does this probgram fragment do (the answer is very short)? (1 point max)
__The program multiplies R4 times R5 and puts the result in R3__ __except when R4 is negative____________________________________
Few had perfect scores; the hardest part was noticing that this program does not multiply when R4 is negative. Most answers were long winded descriptions that said, in English, what the assembly code does, instruction by instruction, with no evidence of any decoding of the algorithm (the stupidest multiplication algorithm known to man).
SUBTITLE GCD - integer greatest common divisor function ; activation record structure RA = 0 ARSIZE = 4 ; ------------------- GCD: ; function called with return address in R1 ; on entry ; R3 unsigned positive integer i ; R4 unsigned positive integer j ; on exit ; R3 greatest common divisor of i and j STORES R1,R2 _CMP_____R3,R4______ * BEQ GCDQT ; if (i != j) { BGT GCDEL ; if (i < j) { ; R4 = R4 - R3 _SUB_____R4,R4,R3___ _BR______GCDEI______ GCDEL: ; } else { SUB R3,R3,R4 ; R3 = R3 - R4 GCDEI: ; } _ADDSI___R2,ARSIZE__ * JSR R1,GCD ; R3 = GCD(R3,R4) ADDSI R2,-ARSIZE GCDQT: ; } _LOADS___R1,R2______ JUMPS R1 ; return R3
Half the class got 1.6 or better. 1/4 scored 1.0 or worse. Stars indicate particularly difficult instructions, but errors were scattered randomly over all instructions. Wrong addressing modes (indexed instead of short, for example) received partial credit.