Assignment 4, due Sept. 18
Part of
the homework for 22C:60, Fall 2009
|
Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated (usually a Friday). The only exceptions to this rule will be by advance arrangement unless there is what insurance companies call "an act of God" - something outside your control. Homework must be turned in on paper and in class! Late work may be turned in to the teaching assistant's mailbox, but see the late work policy. Never push late work under someone's door!
PC: ???????? R8: 00000080 PSW: 00000000 R1: 00000001 R9: 00000100 NZVC: 0 0 0 0 R2: 00000002 RA: 00000200 R3: 00000004 RB: 00000400 R4: 00000008 RC: 00000800 R5: 00000010 RD: 00001000 R6: 00000020 RE: 00002000 R7: 00000040 RF: 00004000
That is, Ri has the value 2i for all i from 1 to 15. Obviously, you could begin your code to set up these values with:
LIS R1,1 LIS R2,2 LIS R3,4
a) The above pattern does not work for all 15 general purpose registers. What is the highest numbered register where the above pattern does work? (0.3 points)
b) Suggest at least two different ways to get the intended value into the next higher numbered register after the point where pattern breaks down. (0.4 points)
c) How many halfwords of program does the shortest solution to this problem require to fill all of the general purpose registers from 1 to 15 with the correct values. (0.3 points)
. = 0 X: LIL R1,X LOADS R2,R1
a) When this code is assembled, what values are placed in memory? Show the result as a sequence of 16-bit halfwords, expressed in base 16. (0.5 points)
Note: That this is not the way the SMAL assembler shows the results; the assembler shows the results as a mix of bytes, halfwords and three-quarter words. If you use the SMAL assembler to help solve this problem, you will have to hand-transform the result to a sequence of halfwords. (0.5 points)
b) When this code runs, what value does it leave in R2? (0.5 points)
000000: F463C113 000004: E501000A 000008: 355486A0
A question: This represents a sequence of Hawk instructions. Give SMAL Hawk assembly code for this sequence of instructions. (1.0 points)
Hint: You can actually use the Hawk emulator to help you interpret this code, if you first create a SMAL program that loads it into memory for the interpreter to interpret. However, it is recommended that you learn how to do this using the manuals.