Assignment 4, due Feb 15
Part of
the homework for 22C:60 (CS:2630), Spring 2013
|
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!
USE "hawk.h" LIS R15, 1 LIS R14, 2 ADD R13, R14, R15 MOVE R12, R14 ADDSI R12, 2 ADDI R11, R14, 3 LIL R10, #FFFFFF ADDSI R10, 7 ORIS R9, 7
All of the instructions used here are discussed in Chapter 4 of the notes, and for all of them, the chapter shows both the (somewhat) human readable form of the instructions and the binary, as well as showing the form of the assembly listing when working with these instructions.
a) Assemble this code into memory. Show the contents of memory as a column of 11 16-bit halfwords in hexadecimal, with the address of each halfword written off to the side. (1 point)
Hint: The first entry in this column would be 00: 01DF
Suggestion: As in last week's assignment, do it by hand first, converting the code to binary and then hexadecimal, and then shuffling the pieces into the correct order. Then check your work by assembling this code using the SMAL assembler and then loading the resulting object file into the Hawk emulator to see what data actually lands in memory. (You do not need to link this code.) If you do this both ways, you prove that you understand what the assembler did and you check your work.
b) After these instructions are executed, what data registers (R1 through R15) are changed and what are their new values? (1 point)
Suggestion: Do it by hand first! Then check your work by loading the object code in the Hawk emulator and using the s command (single step) to run each of the 9 instructions in succession. If you do it both ways, you will both maximize your learning and be able to check your work.
c)
The program above begins with a line saying USE "hawk.h". This
causes the assembler to read the file hawk.h, and since that file
is not defined in your directory, it looks for it in the hawk library.
A copy of that file is available on line, at
Assume that all registers (including the program counter)
initially contain zero, as if the machine was just started.
A problem:
How many fetch-execute cycles must finish before register 1 is assigned the
value 3? Equivalently, how many times must you hit the emulator's s (single
step) key before R1 is set to 3?
Hint:
The point of this problem is to get you to look into Chapter 5 before
Friday's lecture. As usual, consider solving this problem on paper and
then checking your work using the Hawk emulator.
--
http://homepage.cs.uiowa.edu/~dwjones/arch/hawk/hawk.txt
Take a look, and see if you can find all of the different macro calls that
are executed in order to
assemble the third instruction of the file,
ADD R13,R14,R15.
List the macro calls involved, giving, for each, the name and the values
of the parameters.
(0.5 points)
JSRS R1,R1
LIS R1,3