Exam 1: MidtermSolutions and Commentary
Part of
the homework for 22C:60, Fall 2005
|
X Mean = 7.57 X Median = 7.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___ 0 . 1 . 2 . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10
X X Mean = 7.32 X Median = 8.0 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.6 X Median = 11.3 X 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
Mean = 24.80 X Median = 27.3 X X X X X X X X X X _________X_______________X___X_X_X_X_________X___X___X_X_X_X_X___X_X___ 2 . 4 . 6 . 8 .10 .12 .14 .16 .18 .20 .22 .24 .26 .28 .30 .32 .34 .36 F D C B A
Bit Pattern x 011101 011000 101010 111001 100101 Unsigned decimal ___29___ ___24___ 42 ___57___ ___37___ 1's complement of x _100010_ 100111 _010101_ _000110_ _011010_ 2's complement of x 100011 _101000_ _010110_ _000111_ _011011_ x as a 1's comp num ___29___ ___24___ __-21___ ___-6___ -26 x as a 2's comp num ___29___ ___24___ __-22___ -7 __-27___
14 did perfect work here. 5 gave strange values for all of the positive 2's complement numbers, despite warnings in class about this problem. Overall, the 1's and 2's complement number systems posed the greatest challenge. 3 students had trouble with carry propagation in performing the 2's complement operation, and a few students made clerical errors elsewhere.
. = 0 || Address 3 2 1 0 W #01234567 || |----|----|----|----| ; --solved to here-- || 000000: | 01 | 23 | 45 | 67 | H #5678 || |----|----|----|----| ALIGN 4 || 000004: | | | 56 | 78 | A: B #89,#67 || |----|----|----|----| ALIGN 4 || 000008: | | | 67 | 89 | B: B #9A || |----|----|----|----| ALIGN 2 || 00000C: | 31 | 30 | | 9A | C: ASCII "0123" || |----|----|----|----| ALIGN 4 || 000010: | | | 33 | 32 | D: B A,B,C,D || |----|----|----|----| END || 000014: | 14 | 0E | 0C | 08 | |----|----|----|----|
8 did perfect work here. 9 had serious problems with the string "0123", and 9 had serious problems with the label values A, B, C and D. Because of the ALIGN 2 directive, the label C was particularly difficult, giving problems for another 6.
|| 001000: D300 LIS R3,0 || ; --solved to here-- || 001002: __F0E4__ LAB1: || TESTR R4 || 001004: __0203__ BZS LAB2 || ADDSI R3,1 || 001006: __13C1__ LOADS R4,R4 || BR LAB1 || 001008: __F4D4__ LAB2: || || 00100A: __00FB__
3 did perfect work here. 12 had difficulty with the first branch displacement (the forward branch), while 15 had difficulty with the second one (the backward branch). Aside from this, there were a scattering of clerical errors.
b) What value does this put in R3 (the answer is very short)? (0.5 points)
__ the length of the chain of pointers referenced by R4 _______________________
3 did perfect work here. 18 earned no credit. Partial credit was given for answers such as "the number of iterations of the loop"
; record structure for an object NEXT = 0 X = 4 Y = 8 TEXT = 12 ; activation record structure for PUTOBJECT RETADDR = 0 P = 4 ARSIZE = 8 PUTOBJECT: ; on entry, R1 = return address ; R3 = p, pointer to an object ; displays that object, unless p = null STORES R1,R2 ; save return address STORE R3,R2,P ; save parameter p TESTR R3 _BZS_____PUTDONE_______ ; if (p != NULL) { LOAD R4,R3,Y ; parameter p->y LOAD R3,R3,X ; parameter p->x ADDI R2,R2,ARSIZE LOAD R1,PDSPAT _JSRS____R1,R1_________ ; call dspat(p->x,p->y) ADDI R2,R2,-ARSIZE LOAD R3,R2,P _LOAD____R3,R3,TEXT____ ; parameter p->text ADDI R2,R2,ARSIZE LOAD R1,PDSPST JSRS R1,R1 ; call dspst(p->text) _ADDI____R2,R2,-ARSIZE_ PUTDONE: ; } LOADS R1,R2 ; restore return address _JUMPS___R1____________ ; return
4 did perfect work here. 7 had no clue about the ADDI -ARSIZE instruction. 8 had trouble with register usage on the LOAD TEXT instruction, and 8 had trouble with the return, mostly using JSRS instructions to do it. Other errors were more difficult to classify.