Exam 1: MidtermSolutions and Commentary
Part of
the homework for 22C:60, Fall 2007
|
Mean = 6.49 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_X_X_X_______ 0 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10
Mean = 4.95
mean = 10.67 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_X_X_X__ 0 . 2 . 4 . 6 . 8 . 10. 12. 14.
mean = 21.53 X median = 23.7 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_X_X_____ 0 . 2 . 4 . 6 . 8 . 10. 12. 14. 16. 18. 20. 22. 24. 26. 28 Rough Grades F D C B A
Bit Pattern x 101111 010101 011001 110011 001101 Unsigned decimal ___47___ ___21___ ___25___ 51 ___13___ 1's complement of x _010000_ _101010_ 100110 _001100_ _110010_ 2's complement of x _010001_ 101011 _100111_ _001101_ _110011_ x as a 1's comp num -16 ___21___ ___25___ __-12___ ___13___ x as a 2's comp num __-17___ ___21___ ___25___ __-13___ 13
Well over half the class did perfectly here. 10 students made 3 or fewer errors, while 4 made 5 or more errors. The most common errors had to do with problems with negative numbers, with 1's complement being more difficult than 2's complement.
. = 0 || Address 3 2 1 0 W #01234567 || |----|----|----|----| ; --solved to here-- || 000000: | 01 | 23 | 45 | 67 | B A,"A",#A || |----|----|----|----| ALIGN 4 || 000004: | | 0A | 41 | 08 | A: B A,B,C,D || |----|----|----|----| B: H #ABCD || 000008: | 10 | 0E | 0C | 08 | ALIGN 2 || |----|----|----|----| C: H #0123 || 00000C: | 01 | 23 | AB | CD | ALIGN 4 || |----|----|----|----| D: W #01234567 || 000010: | 01 | 23 | 45 | 67 | END || |----|----|----|----| || 000014: | | | | | |----|----|----|----|
Only 3 did perfectly here, while 1 earned no credit. 13 earned more than 1.5 points, 10 earned more than 1 point, but less than 1.5. The most common error had to do with byte order. Unfortunately, many students confused "A" (the ASCII character), A (the label) and #A (the hexidecimal value). Another common problem had to do with alignment.
|| 001000: ??E8 LIL R8,ARRAY || ; --solved to here-- || 001002: ???? LIS R4,0 || LOOP: || 001004: __00D4__ LOADSCC R3,R8 || BZS ENDLOOP || 001006: __C8F3__ ADDSI R8,4 || ADD R4,R4,R3 || 001008: __0302__ BR LOOP || ENDLOOP: || 00100A: __C418__ || || 00100C: __4334__ || || 00100E: __FB00__
One student left this blank. Half the class had problems with byte order. The branch instructions posed special problems for many.
b) What does this do? (The answer is very short.) (0.5 points)
__Sum_the_words_of_an_array_up_to_the_first_zero_______________________________
Half the class tried to give answers that were short and to the point. Three of these were correct, while others omitted or made mistakes with key aspects such as summation, loop termination, or the fact that the array elements were words. 6 left this blank. Most of the remaining answers were not in the form of explanations, but rather, restatements of the computation in a slightly higher level language. In many cases, these attempts were longer than the original program.
TITLE "Similar to MP2, find and print max key in ARRAY" USE "hawk.macs" USE "monitor.h" EXT UNUSED EXT ARRAY S START ; record structure for an object STRING = 0 KEY = 4 ; main program START: LIL R2,UNUSED LIL R1,DSPINI JSRS R1,R1 ; end of prologue to program LIL LOAD R8,ARRAY ; R8 points to the array A LIS R9,0 ; R9 = i = 0 is the loop index LIS R10,0 ; R10 = max = is the largest element LOOP: ; for (;;) { MOVE R1,R9 ADDSL R1,R8,3 ; R1 is address of A[i] LOAD ADDI R4,R1,KEY ; R4 = A[i].key LOADCC R3,R1,STRING ; R3 = A[i].string A[i].string BZS ENDLOOP ; if (A[i].key == NULL) break; CMP R4,R10 ; if (A[i].key > max) BLE ENDIF ; { MOVE LOADS R10,R4 ; max = A[i].key ENDIF: ; } ADDSI R9,1 ; i = i + 1 BR LOOP ENDLOOP: ; } MOVE LIL R3,R10 ; parameter 1 = max LIS R4,1 ; parameter 2 = 1 LIL R1,DSPDEC JSRS R1,R1 ; call putdec( max, 1 ) LIL R1,EXIT JSRS R1,R1 END
The notes in the right margin above give the corrections, a missing specification of the starting address and 4 incorrect instruction names.
13 earned no credit. Only one student noticed the missing starting address. Half the class correctly noticed the LOAD instruction that should have been LIL. About 8 students noticed each of the other mistakes.
Because of the mistake in one comment, grading on that part of the code was lenient, but many students found large numbers of errors that were not there, in some cases, leading to attempts to completely redesign the control structures or register usage of the program.