Exam 1: MidtermSolutions and Commentary
Part of
the homework for 22C:60 (CS:2630), Fall 2014
|
X X Median = 7.5 X X X Mean = 7.15 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_X_X_X_X_X_X_X_X____ 0 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10
XXX XXX XXXXX XXXXX XXXXX XXX Median = 10.0 XXX Mean = 8.98 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 Median = 12.2 X Mean = 11.57 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_X_X_X_X_X_X_X_X_X_X_X____ 0 . 2 . 4 . 6 . 8 . 10. 12. 14. 16. 18
X Median = 28.8 X X X X Mean = 27.70 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_X_X_X_X_X_X_X_X____ 10. 12. 14. 16. 18. 20. 22. 24. 26. 28. 30. 32. 34. 36. 38 Midterm Grades: D | C | B | A |
Version 1
Bit Pattern x 101110 011110 001100 100101 001010 Unsigned decimal ___46___ ___30___ ___12___ ___37___ ___10___ 1's complement of x _010001_ _100001_ _110011_ _011010_ _110101_ (binary) , 2's complement of x _010010_ _100010_ _110100_ _011011_ _110110_ x as a 1's comp num __-17___ ___30___ ___12___ __-26___ ___10___ (signed decimal) x as a 2's comp num __-18___ ___30___ ___12___ __-27___ ___10___
Version 2
Bit Pattern x 011101 110010 010001 001110 101010 Unsigned decimal ___29___ ___50___ ___17___ ___14___ ___42___ 1's complement of x _100010_ _001101_ _101110_ _110001_ _010101_ (binary) 2's complement of x _100011_ _001110_ _101111_ _110010_ _010110_ x as a 1's comp num ___29___ __-13___ ___17___ ___14___ __-21___ (signed decimal) x as a 2's comp num ___29___ __-14___ ___17___ ___14___ __-22___
There were two versions of this problem. In each version, one solution was given in each row and column, but there was an error in Version 1 of the exam (the two's complement of 101110). 7 students corrected or at least noted this error, and because of it, some wrong answers had to be given credit.
32 students had perfect scores, while 16 had difficulty. There were random clerical errors in the unsigned decimal and in the 1's and 2's complement binary rows. Among the students with problems, the most serious problems involved systematic misunderstanding of one's and two's complement decimal interpretations of the value. On the order of 12 students had clearly not mastered this crucial topic.
Version 1
. = 0 || Address 3 2 1 0 D: B #21 || |----|----|----|----| C: H #6543 || 000000: | |[65 | 43]|[21]| ; solved to here || |----|----|----|----| ALIGN 2 || 000004: |[00 | 43]|[00 | 0D]| H #D,"C" || |----|----|----|----| ALIGN 4 || 000008: |[00 | 00 | AB | CD]| B: W #ABCD || |----|----|----|----| B D,C,B,A || 00000C: |[10]|[08]|[01]|[00]| ALIGN 4 || |----|----|----|----| A: H D,#A || 000010: |[00 | 0A]|[00 | 00]| END || |----|----|----|----| || 000014: | | | | | || |----|----|----|----|
Version 2
. = 0 || Address 3 2 1 0 0 A: B #21 || |----|----|----|----| 1 B: H #6543 || 000000: | |[65]|[43]|[21]| ; solved to here || |----|----|----|----| ALIGN 2 || 000004: |[00 | 0C]|[00 | 44]| 4 H "D",#C || |----|----|----|----| ALIGN 4 || 000008: |[00 | 00 | AB | CD]| 8 C: W #ABCD || |----|----|----|----| C B D,C,B,A || 00000C: |[00]|[01]|[08]|[10]| ALIGN 4 || |----|----|----|----| 10 D: H A,#D || 000010: |[00 | 0D]|[00 | 00]| END || |----|----|----|----| || 000014: | | | | | || |----|----|----|----|
As with problem 1, there were two versions. The answers to both are given above. More extra space was provided than is shown above.
9 did perfect work here, 3 earned no credit. Careless errors accounted for some of the partial credit, but there were also systematic problems: Many students mistook #A (a hexidecimal number) for "A" (an ASCII code or for A, a label. Some did not understand the ALIGN directives. Some did not understand that the B (byte), H (halfword) and W (word) directives determin how much storage is allocated. Instead, they allocated storage to fit the number of digits in the hex constants. Students with fewer of these misunderstandings tended to earn more credit.
Addr: Val || Addr: 0 1 || LABEL: OPCODE OPERAND(S) || || 1000: E3F001D4 || 1000: _D4_ _01_ || _FUNC:_ _LIS__ _R4,1_____ || || || 1002: _F0_ _E3_ || _______ _TESTR _R3_______ || || 1004: 01A40302 || 1004: _02_ _03_ || _______ _BZS__ _QUIT_____ || || || 1006: _A4_ _01_ || _LOOP:_ _SL___ _R4,1_____ || || 1008: FD0ACF13 || 1008: _13_ _CF_ || _______ _ADDSI _R3,-1____ || || || 100A: _0A_ _FD_ || _______ _BZR__ _LOOP_____ || || 100C: B1F0F4F3 || 100B: _F3_ _F4_ || _QUIT:_ _MOVE_ _R3,R4____ || || || 100C: _F0_ _B1_ || _______ _JUMPS _R1_______ || ||
There are no long instructions above. The middle column is for your convenience to use in unpacking the instructions and arranging their bytes in the order they would be shown in the Hawk manual. Leave the label field blank except when there are branch instrucitons to that label.
There was just one version of this probem.
Three did peerfect work, while 4 gave answers that earned no credit and an additional 5 left the entire question blank. Among those earning partial credit, many did not use branch labels, but just gave the numeric branch displacements. The BZS (or its synonym BEQ) and The BZR (or BNE) instructions were particular sources of problems, many identified the fact that these were branches but could not identify the correct one. The negative branch displacement caused much more difficulty than the positive one. Many students took this to be a branch back to FUNC -- and as a result, destroyed the logic of the code because it reinitialized R4 to one on each iteration. Finally, the ADDSI instruction puzzled many, primarily because they could not relate the constant F16 to –1.
It is a subroutine. If FUNC is called with the integer 3 in R3, what value is returned? (0.5 points)
___8_____________________________________________________ ___(that is, 2 to the 3)_________________________________
13 got this right, and 10 left it blank. The answers students gave were evaluated in terms of the logic they decoded, so, for example, if a student gave an answer of 8 but gave code for part a) that could only produce the values 1 or 2, that student earned no credit here. Among the answers students gave that were not supported by the logic of the code they worked out were: 0, 1, 2, 3, 4, 5, 6, 8, 15, 20, 21 and 27. Most of these were given by just one student each.
; -- given w in R3, h in R4 SR___ R3,1_____ ;v1 ; -- compute w/2 ADDSI R4,-1 ; -- compute h - 1 CMP__ R3,R4____ ;v2 BGE__ ENDIF____ ;v1 ; if (w/2 < (h - 1)) { MOVE R4,R3 ; m = w/2 ; } else { m = h - 1 ENDIF: ; } ; -- m in R4 is min( w/2, h - 1 ) LIS R3,1 ; p = 1 LOOP: CMP__ R3,R4____ ;v1 BGT__ EXIT_____ ;v2 ; while (p <= m) { SL R3,1 ; p = 2*p BR LOOP ; } EXIT: SR___ R3,1_____ ;v2 ; p = p/2 ; -- now p in R3 is ...
a) Three instructions are missing from the above (they have been replaced by underlined blank lines). Fill them in in the code above. (1 point)
As with problems 1 and 2, there were two versions of this code. They were both based on the same original program, but with different lines of code deleted. The entire program is given above, with comments added to indicate which lines were deleted in each version.
9 got this right, while only 2 earned no credit. Among those earning partial credit, the branch instructions posed the biggest difficulty. Many inverted the branch sense, using BLT (v1) or BLE (v2). Fewer students also inverted the order of the operands on the CMP instructions, an error that complements the inversion of the branch sense. A few students wrote CMPI R3,R4 (this would earn an assembly error).
b) The final comment has been cut short. Given the value of w and h, the screen width and height, this code computes p, the ... (complete the sentence in the blanks below): (1 points)
___... the largest power of 2 such that p ≤ m____________ ___... the size of the largest Sierpinski triangle that__ ___will fit in a screen of size w by h___________________
Two answers are given above, the first is purely with respect to the code given, while the second requires considerable understanding of machine problem 3.
7 students did perfect work, 1 left this blank, and 19 more earned no credit. A very common error was to get distracted by the relationship between this problem and MP3 and then speculate about centering a Seirpinki triangle on the screen or something similar. Another common error was to just say "the size of the triangle" or "a power of two" without saying that it was the largest triangle that would fit or the largest power of two within the bound. By far the most common problem was to fail to state (or even imply) that the code computed a power of two. A related error was to state that the code computed i when it actually computes 2i, or equivalently that it computes the order of the Sierpinski triangle when it actually computes its height.