ENEE 350H - Fall 2004

HW1 (Due in Class on September 14th)

[DLX Assembly programming]  In this question you will write a new DLX assembly language program and simulate it a the DLX simulator.  DLX is the name of a simple RISC ISA.  Before attempting to do this question, familiarize yourself with the DLX ISA and how to use the software by visiting the class website and reading all the documents in the "DLX" link.

Write a DLX assembly language programs that takes a single positive integer A, computes ceiling(log2 A), and prints out the answer on the screen.  For example, if A=13 or A=16 the answer should be 4; if A=20 or A=32 the answer should be 5.  In writing the program, do not attempt to call any library function for log; instead, repeatedly integer-divide the number by two, until the quotient is zero.  To integer-divide, do not use a division instruction; instead use the appropriate right-shift instruction.  Please your entire code in the _main function itself.

Your program should not take any input from the screen.  Instead, it should hard-code in the value of A in the program.  Do this by declaring a global variable A in your program, and initializing it to its known constant value, such as 13.  (To see how to declare an initialized global, look at example program add.c/ add.s in ~/dlx/test.)

Example: If A = 13, then your DLX session on glue should look like the following:

> dlxsim
(dlxsim) load log2.s
(dlxsim) go _main
Log of input is 4
TRAP #0 received

When debugging your program, you may find it helpful to use DLXSIM to step through the program instruction by instruction, examine the values of registers during execution and set breakpoints.  These are very easy to do -- use the DLX simulator manual to learn to do these tasks and try them out for your program.

Please submit the following: