CS/ECE 354, Assignment 4

Assignment 4

CS/ECE 354, Spring 2009


Send e-mail questions to Somayeh Sardashti, somayeh@cs.wisc.edu
Due Friday, November 6, before 5pm.


Goals of this Assignment

The goal of this assignment is to understand conventions for parameter passing and register usage with respect to implementing functions. Towards that end, you will be given two separate, partial MAL assembly language programs with functions to complete.

The First Program

The first program (called ints.s) loops, requesting an integer, reading an integer, and then printing the integer entered. The printing of the integer is to be accomplished by a missing print_integer() function. Find this program at

/p/course/cs354-common/public/html/homeworks/ints.s
Copy this file, and add the missing function. The function must be able to print any 0 or positive integer value.

Do not forget to completely document the function.

The Second Program

The second program (called powers.s) has functionality similar to assignment 1, the C program. The major difference is that for this program, input is prompted from the user, instead of using command line arguments. Find this second program at

/p/course/cs354-common/public/html/homeworks/powers.s
Copy this program, and add the four missing functions:

Note that the print_integer() procedure is exactly the same for both programs. A goal of this assignment is to realize that any program that follows the conventions for parameter passing and register usage can utilize the same function code.

Also note that both setPowers() and print() are both a caller and a callee.

Requirements

  1. Your code must follow style guidelines as given in Style Guidelines.

    Place your name (and your partner's name, if working in a pair) at the top of the source code within both files.

    See Guidelines for Programs to see an indication of point allocation used in program grading.

  2. The two files ints.s and powers.s will be turned in. They must have these names to make the lab-supported handin program work.
  3. Follow all parameter passing and register usage conventions as described in MIPS register usage. This program will have a lot of points dedicated to the following of the conventions.
  4. Do not change code outside of the functions you are writing, other than to put your name(s) at the top of each file.

Notes

Remember that the I/O instructions getc, putc, and puts are implemented as functions within the operating system's code, and they overwrite registers $v0 and $4 (alias $a0).


Collaboration Policy

For this assignment, you may work in pairs (2 people). All students (whether working in a pair or not) must individually turn in the assignment by individually running the handin program. Therefore, 2 copies of the assignment will be turned in for those working as a pair. The grader will choose to grade only one copy of a pair's work, and assign the same score to both students.

If working in a pair, the names of BOTH students must appear at the top of the turned in assignment.


Handing In the Program

Your MAL source code must be in the 2 files named ints.s and powers.s. Turn in your program by running the lab-supported handin program.

Use the following command to run the handin program:


  /s/handin/bin/handin -c cs354-1 -a a4 -d .

while your current working directory is the one containing both the ints.s and powers.s files. This handin program copies the specifically named files to a directory accessible by the instructor and TAs.