Assignment 2, due Sep 5Solutions
Part of
the homework for CS:2630 (22C:60), Fall 2014
|
a) Convert 10010 to octal. (0.2 point)
10010 = 1448
b) Convert 10010 to hexidecimal. (0.2 point)
10010 = 6416
c) Convert ADD16 to binary. (0.2 point)
ADD16 = 1010110111012
d) Convert ADD16 to decimal. (0.2 point)
ADD16 = 278110
e) Convert ADD16 to base 5. (0.2 point)
ADD16 = 421115
Note that, in some of the above, you will find the results of one of the previous conversions to be useful.
Specifically, parts a) and b) were easy to do by hand by converting to binary first and then grouping the bits for bases 8 and 16. The base 5 in part e) is easier to compute (with pencil and paper) from the decimal result in part d), and that was easy to compute from the binary result in part c).
a) A 6-bit one's complement signed binary number. (0.2 point)
~1011102 = 0100012, so the answer is –1710
b) A 6-bit two's complement signed binary number. (0.2 point)
–1011102 = 0100102, so the answer is –1810
c) A 6-bit signed magnitude binary number. (0.2 point)
it is interpreted as –011102, so the answer is –1410
d) A 6-bit biased binary number (with the default bias). (0.2 point)
1011102 – 1000002 = 0011102, so the answer is –1410
TITLE "mp1.a alternative version, Aug. 26, 2014" INT ARRAY ; make ARRAY visible to the test program ARRAY: W 1,1,LINE1 ; array[0] -- x, y, text W 1,10,LINE2 ; array[2] -- x, y, text W 1,6,LINE3 ; array[3] -- x, y, text W 1,2,LINE4 ; array[4] -- x, y, text W 0,0,0 ; array[5] -- x, y, text LINE1: ASCII "Abalone rod",0 LINE2: B #65,#6C,0 LINE3: B 32,119,111,0 LINE4: B 8#154,0 END
A problem: What is the final text that this places on the screen after it finishes overwriting some of its previous output? (1.2 points)
Suggestion: You can solve this problem by hand, first doing conversions between number bases before interpreting your numbers as ASCII characters, and then working out which characters are plotted where on the screen. You can also solve this problem by using the SMAL assembler and then linking and running the program, following the instructions for testing a solution to MP1. If you do it both ways, you will not only check your work but maximize your learning.
Here is the result of running the code:
Abalone rod l wo el(Actually, that was not what was intended. In making up the assignment, the X and Y coordinates got switched. Once the error was posted to the web, there was no point in fixing it -- someone would have solved the problem as originally posted, so it was better to leave things along. Had the error not occurred, however, the answer would have been:
Alalo worelSo much for cleverly designed questions.)