Department of Electrical and Computer Engineering
The University of Texas at Austin
EE 306 Fall 2002
Yale Patt, Instructor
TAs: Asad Bawa, Linda Bigelow, Mustafa Erwa, Lester Guillory, Kevin Major,
Moinuddin Qureshi, Paroma Sen, Tanay Shah, Santhosh Srinath,
Matt Starolis, David Thompson, Vikrant Venkateshwar
Programming Assignment 1 (Machine Code)
Due October 20, 2002 at 11:59pm
Integer division is the kind we all learned in third grade,
where we get a quotient and a remainder (i.e. 11/4 = 2 , with a remainder of 3).
Computers perform similar division on integers, but the remainder is
discarded. This is called integer division (IDIV) (i.e. 11 IDIV 4 = 2).
X modulo Y is defined as the remainder of X IDIV Y. This is commonly
seen as X % Y (i.e. 11 % 4 = 3).
Your will implement two functions, modulo and integer divide.
Y = A / B
Z = A % B
In high level statment above, Y and Z are destinations in memory, and A
and B are sources in memory. Recall that the LC-2 is a Load/Store
machine. Before operating on the values stored in A and B, we must first
load them into registers.
After computing the integer quotient and the modulus, we must store these
results into memory.
The source operand A is stored in location 0x3100 in memory.
The source operand B is stored in location 0x3101.
The result Y should be stored in location 0x3102.
The result Z should be stored in location 0x3103.
Your program should start at location 0x3000.
You should make the following assumptions:
A > 0
B > 0
3. Initial Values
You should write your program assuming that there are already values stored
in memory at locations 0x3100 and 0x3101. When using the LC-2 simulator to test
your program, you should manually load test values into these memory locations
before running your program.
Your program must be a text file of binary characters. Each line contains
a 16 character string of ones and zeros followed by a carriage return.
The first line will give the starting address of the sequence of memory
locations containing the program.
Each line may have a comment, written as a string of ASCII codes, or not, as
you wish. Comments are useful for helping you understand what the instruction
does six months from now. The comment is separated from the 16 0's and 1's by
a semi-colon. That is, the semi-colon denotes the end of what is actually
stored in the memory location. Everything beyond that is discarded before the
16 bits are stored in the memory location.
Example: Suppose you were being asked to submit the program that was the
subject of our multiply routine. The first two lines might be:
0011000000000000 ; The program will be stored, starting with location x3000.
0101011011100000 ; Clear R3, which will be used to keep the intermediate results.
It is not necessary to have a comment next to every instruction.
5. Submission Instructions
You will submit your program electronically using a submit script.
See the following submission instructions.