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 (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.sCopy 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 (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.sCopy this program, and add the four missing functions:
print_integer()
setPowers()
setPowers() receives 4 parameters, which
are exactly as defined for assignment 1.
The first parameter is the user entered integer that will be
raised to the various powers.
The second parameter is
base address of the array.
The third parameter is the lower bound exponent,
and
the last parameter is the upper bound exponent.
For each of the integers in the range,
this function calls power(),
and then places the return value into the array.
power()
power() calculates and returns (in $v0)
the correct power.
The two parameters are exactly as defined for assignment 1:
the first parameter is the base, and the second
parameter is the exponent.
print()
print() does the output for the program.
For each power calculated, there is one line of output,
formatted just as in assignment 1.
print() receives 4 parameters, which
are exactly as defined for assignment 1.
The first parameter is
base address of the array.
The second parameter is
the user entered integer that was
raised to the various powers.
The third parameter is the lower bound exponent,
and
the last parameter is the upper bound exponent.
For each and every integer to be printed,
this function calls print_integer().
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.
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.
ints.s
and powers.s
will be turned in.
They must have these names to make the lab-supported handin program work.
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).
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.
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.