Assignment 2, due Jan 31Solutions
Part of
the homework for 22C:60 (CS:2630), Spring 2014
|
On every assignment, write your name legibly as it appears on your University ID card! Homework is due on paper at the start of class on the day indicated (usually Friday). Exceptions will be made only by advance arrangement (excepting "acts of God"). Late work must be turned in to the TA's mailbox (ask the CS receptionist in 14 MLH for help). Never push homework under someone's door!
W #756E614A H 8#071141 B 4#1321 B 4#0201
a) Convert the operand on each of the above SMAL directives to binary, using correct SMAL syntax for binary numbers. (0.5 points)
W 2#01110101011011100110000101001010 H 2#0111001001100001 B 2#01111001 B 2#00100001Some students converted to binary without bothering to use the correct SMAL syntax for binary numbers.
b) Convert it to an equivalent series of 8 SMAL B (byte) directives, one per byte, expressing the value of each byte in binary. Warning: Check the first sections of Chapter 3 to get this right. (0.5 points)
B 2#01001010 B 2#01100001 B 2#01101110 B 2#01110101 B 2#01100001 B 2#01110010 B 2#01111001 B 2#00100001Some students didn't bother keeping SMAL syntax here, although a strict reading of the question makes it clear that they should have done so. The TA was lenient here. Of more importance, the byte order within a word (or halfword) really matters here. Many students got the order wrong.
c) Convert the result of part B to a single SMAL ASCII directive. Hint: The character string is readable English. (0.5 points)
ASCII "January!"Some students didn't bother with the ASCII directive and just gave the string. The TA was lenient here. Students who had difficulty with byte order, naturally, had difficulty decoding this string.
a) –100
b) +100
c) –1
d) +50
e) –75
a) –100 = 10011100
b) +100 = 01100100
c) –1 = 11111111
d) +50 = 00110010
e) –75 = 10110101
Most did well here.
a) –99
b) +99
c) –0
d) +49
e) –74
a) –99 = 10011100
b) +100 = 01100100
c) –0 = 11111111
d) +49 = 00110001
e) –74 = 10110101
Most did well here, but –0 caused trouble for some, and others had more general problems with negative numbers.
a) 01011101
b) 11100010
c) 01101010
d) 11110011
e) 01111011
a) –01011101 = 10100010+1 = 10100011 = 163
b) –11100010 = 00011101+1 = 00011110 = 30
c) –01101010 = 10010101+1 = 10010110 = 150
d) –11110011 = 00001100+1 = 00001101 = 13
e) –01111011 = 10000100+1 = 10000101 = 133
A fair number gave negative answers even though the question asked for the positive unsigned interpretation of the two's complement.