Exam 2: MidtermSolutions and Commentary
Part of
the homework for CS:2630, Spring 2023
|
Mean = 3.88 Median = 3.8 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_X_X_X_X_X_X_X_X_X_X___X___________ 0 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10
Mean = 10.15 X Median = 10.1 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_X_X_X_X_X_X_X_X_X_X_X_X_______ 0 . 2 . 4 . 6 . 8 . 10. 12. 14. 16. 18. 20
X Mean = 23.90 X Median = 25.8 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___X___X_X_X_X_X_X_X_X_X_ 0 . 2 . 4 . 6 . 8 . 10. 12. 14. 16. 18. 20. 22. 24. 26.
Mean = 11.70 X Median = 12.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 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 = 45.58 X median = 48.1 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_X_X_X_X_X_X_X_X_X_X_X_X___ 20. 24. 28. 32. 36. 40. 44. 48. 52. 56. 60. 62 D C B A
If this was the end of the semester, the grade scale might look something like the above. The D-C division is largely decided by the fact that those with overall scores below 33 have generally failed to demonstrate competence in programming.
Note: We will only count the top 10 homework scores, no matter how many are assigned.
HAWK EMULATOR /------------------CPU------------------\ /----MEMORY----\ PC: 00000000 R8: 00000050 FFFFFC: -- PSW: 0000FF03 R1: 000010B2 R9: 00000009 FFFFFE: -- NZVC: 0 0 1 1 R2: 00010080 RA: 00000000 ->000000: LIL R2,#010070 R3: 16710189 RB: 00000000 000004: JSR R1,#00032C R4: 00084F70 RC: 00000000 000008: LIL R1,#00109E R5: 00000050 RD: 00000000 00000C: JSRS R1,R1 R6: 00000000 RE: 00000000 00000E: BR #000000 R7: FF000000 RF: 00000000 000010: CPUSET R2,#3 **HALTED** r(run) s(step) q(quit) ?(help) Bus Trap. Trap PC = #00001022 Trap MA = #16710188 invalid addr
+0000000C: F1 A2 25 PLOTIT: STORES R1,R2 +0000000E: F8 22 0004 26 STORE R8,R2,X +00000012: F9 22 0008 27 STORE R9,R2,Y +00000016: F2 62 000C 28 ADDI R2,R2,ARSIZE +0000001A: F3 D8 29 LOADS R3,R8 +0000001C: F4 D9 30 LOADS R4,R9 +0000001E: 93 01 31 SR R3,1 +00000020: 94 01 32 SR R4,1 +00000022: F8 D3 33 LOADS R8,R3 +00000024: F9 D4 34 LOADS R9,R4 +00000026: E1 +000000 35 LIL R1,PUTAT
The LOADS R3,R8 on line 33 is at address 2216,
and R3 agrees with the trap MA.
Most of the class got this right.
Every single LOADS in the above code shoul have been MOVE!
Only 1/4 of the class got this.
Only 1/5 of the class got this.
MOVESL R1,R3,5 ADDSL R3,R1,3 |
1/3 got this, 1/4 got 288, 1/9 got 297. The wrong answers came from looking at shift counts without close attention to the use of R1.
_ADDSL___R3,R2,2_ _SL______R3,3____ |
1/2 the class were able to multiply by their answer to the previous question.
FUNC: ; expects __R3_=_x_______________ ; __R4_=_y_______________ ; uses __R3,_R4,_R5_=_z_______ ; returns __R3___________________ TESTR R4 BZS LABEL2 ; _if_(y_!=_0)_{______ LABEL1: ; ___do_{_____________ MOVE R5,R3 AND R5,R4 ; _____z_=_x_&_y______ EQU R3,R4 NOT R3 ; _____x_=_x_^_y______ MOVESL R4,R5,1 ; _____y_=_z_<<_1_____ BZR LABEL1 ; ___}_while_(y_!=_0)_ LABEL2: ; _}__________________ JUMPS R1 ; _return_x___________
1/10 did well here. Many students said that R4 was the return value, despite a) the fact that our convention is that R3 is always the return value and b) the fact that this code can only return when R4 is zero.
Only 1/20 did well here. Most used if-goto style comments, or worse, comments that suggested calls to labels instead of just branches. Those who commented the loop as a loop rarely indicated the end of loop with a closing brace. Hardly anyone used indenting to set off the loop body.
Perhaps 1/6 did well here. Many gave verbose English instead of boiling their comments down to assignment statements. Most either did not understand the EQU instruction or ignored it. Few correctly understood that the combination of EQU and NOT used her is an exclusive or, which is ^ in C, C++, Java and Python. Many used && when they should have used &. Most correctly understood the shift instruction.
Only 1/20 got this. Here is a table of successive register values (in binary) through the computation:
x | y |
---|---|
0011 | 0101 |
0110 | 0010 |
0100 | 0100 |
0000 | 1000 |
1000 | 0000 |
1/11 did well here. Wild guesses seemed common.
2 did well here. Most of the logic diagrams had an and gate and not gate with interconnections unrelated to the code given. Most only had one output, despite the explicit statement in the question that the circuit should update "the two primary variables." Many had input or output labels unrelated to either the registers used in the code or to names used for those variables in the comments written for problem 7.
_xi_ | _yi_ | _xi_ | yi+1 |
---|---|---|---|
_0__ | _0__ | _0__ | _0__ |
_0__ | _1__ | _1__ | _0__ |
_1__ | _0__ | _1__ | _0__ |
_1__ | _1__ | _0__ | _1__ |
1/4 gave labels that matched the logic circuit drawn in answer to problem 12. 1/4 earned partial credit, usually by adding spurious outputs. 1/6 gave answers with no discernible connection to the logic diagram. 1/5 left it blank.
5/7 gave the standard arrangement of input values for a 2-input truth table. 1/6 gave no answer. The most common error leading to partial credit was to give the values in some kind of nonstandard order. Those who claimed the circuit had more than 2 inputs but only gave 4 rows earned no credit.
1/3 gave output values that corresponded to what their answer to problem 12. 1/3 earned no credit, typically by filling in outputs with no discernible relationship to the logic diagram. would produce.
2 got this. Most gave wild guesses. Greatest common divisor? Least common multiple? Definitely not.
; Fibonacci code to test ADD and SUB functions ;RETAD = 0; I = 4; ARSIZE = 8; FIB: ; expects R3 = i STORES R1,R2 ADDSI R2,ARSIZE CMPI R3,1 BLE FIBQ ; if (i > 1) { // recursive case STORE R3,R2,I-ARSIZE ; -- save i LIS R4,1 ; -- param JSR R1,SUB ; -- sub( i, 1 ) JSR R1,FIB ; -- fib( i - 1 ) LOAD R4,R2,I-ARSIZE STORE R3,R2,I-ARSIZE ; -- save fib( i - 1 ) MOVE R3,R4 ; -- param i LIS R4,2 ; -- param JSR R1,SUB ; -- sub( i, 2 ) JSR R1,FIB ; -- fib( i - 2 ) LOAD R4,R2,I-ARSIZE ; -- param fib( i - 1 ) JSR R1,ADD ; i = add( fib( i - 2 ), fib( i - 1 ) ) FIBQ: ; } LOADS PC,R2 ; return i;
1/5 did well. 1/9 understood that the problem involved something about the activation record. 1/2 gave answers unrelated to the problem, many of which could not possibly lead to the symptom described. 1/11 left it blank.
1/6 got this. 2/7 understood that the issue involved something about the activation record. Almost all of the rest gave answers that didn't seem to connect with the issue.
1/9 got this, 1/9 earned good partial credit for saying it had something to do with recursive calls. 1/8 earned a bit of credit for saying something about needing to save something to compute the sum. 1/2 gave answers that didn't seem to indicate a useful level of understanding of the code.
1/4 got this. 1/8 gave strong hints for strong partial credit. Most of the remainder earned no credit. The most common useless answer was that if ARSIZE was bigger, the definition of ARSIZE would need to be changed. (Yes, but that is trivially implied by the question.)
For the curious: The code used for problems 7 to 16 is the add function called by the code for problems 17 to 20. The entire program is here.