-
Conversion of unsigned numbers between number bases:
Base 2 Base 8 Base 10 Base 16
110010101101 6255 3245 CAD
101100 __54__ __44__ __2C__
_11010001_ 321 _209__ __D1__
_101000001_ __501_ 321 __141_
_1100100001_ _1441_ __801_ 321
About half the class got all of the above correct. Not surprisingly,
decimal conversions were slightly more difficult than conversions
between octal, hex and binary. Many people, however, made clerical
errors, probably in counting strings of ones and zeros, and as a result,
there were many random errors the octal to binary to hex arena.
-
Two's complement numbers:
Decimal -21 25 -6 __28__ __-7__
Binary 101011 _011001_ _111010_ 011100 111001
About 2/3 of the class got all of the above correct. Among those
who had problems, converting 111001 to -7 posed the greatest difficulty.
As predicted, some students had problems that involved negating their
answers, so they gave 100111 for 25 (that's -25!) and 000110 for -6
(that's 6!).
-
Assembly operations:
Location Value
X = 1
. = #100 ________100:_____ ____00030201_____
B X
B Y ________104:_____ ____00000102_____
Z: H X+Y
W Z ________108:_____ ____44434241_____
Y = X+1
ASCII 'ABCD'
Only 4 students had all of the above correct, while 1/3 of the class received
essentially no credit, despite the warning that problems of this sort would
be on the exam. The hardest part of the problem was giving the correct value
for the line that reads "W Z". The value of Z is not X+Y, the value
of Z is the value of the location counter for that halfword, hex 102.
-
Hawk instruction format:
Location Value
LEA R5,R2,#0123
loop: LOADS R6,R5 ___00:__ _______F5C2________
EXTH R7,R6,R5
BZS exit ___02:__ _______0123________
ADDSI R5,2
BR loop ___04:__ _______F665________
exit:
___06:__ _______4765________
___08:__ _______BA02________
___0A:__ _______1552________
___0B:__ _______B8FB________
Without question, the hardest part of this exam was figuring out
the displacements on the location-counter relative branches. All but
a few students got this wrong, but many got reasonable partial credit.
A number of students simply left out the hex constant 0123 following
the LEA instruction, and there were a variety of careless errors.
-
Hawk Programming:
; Precondition: R3 points to a record in memory.
; The constant X is the offset of a field in that record.
; Field X is an array of 20 words, indexed from 0 up.
; R4 holds an integer.
______ ADDS R4,R3,2 _________________________________
______ LOAD R5,R4,X _________________________________
; Postcondition: R5 holds R3->X[R4] (R3^.X[R4] in Pascal).
The answer given here is the best known answer for this machine.
It does:
R5 = M[R3 + X + 4*R4]
\/ --- address of record
\----/ --- address of array X in record
\--/ --- offset of array element in bytes
\-----------/ --- address of array element
Two students had good working code, a few more forgot to multiply the
array index by 4 (there are 4 bytes per integer), but most wrote little
or wrote large irrelevant blocks of code. I am particularly puzzled by
those who wrote iterative code, since the problem involves no iteration!