Homework 6, A Functioning Program.

Short Description:

Write a fully interactive program to compute n! recursively.

Goals

When you finish this homework, you should have:

Formal Description

Write a program that will compute n! using a recursive function.

As part of this requirement, you must develop a library that contain functions to:

  1. Print a null terminated string.
  2. Print a non-negative integer.
  3. Read in a non-negative integer.

Please name your library MY_IO.asm. This should use the definitions in IO_DEFS.asm. You may not use libraries (follow the examples and Jorgensen, not Carter).

You must observe the following:

For now, you may use a global variable for your text buffer for integer conversion.

You should then build a recursive function to calculate n!. n! is defined for any non-negative integer as : $$n! = \begin{cases} 1, & n= 0,1 \\n(n-1)!, & \text{otherwise} \\ \end{cases}$$ This function should use the calling convention to properly preserve and restore the base pointer and the stack pointer. In addition, for debugging purposes, the parameter n should be stored in the stack frame (or activation record). You must pass the parameter n as a parameter and return a value properly. No global variables in this function.

Your program should use the exact verbiage listed below:

This program will compute n! for a non-negative integer.
Enter a value for n: 5
5! = 120 

Please follow this format as I will grade your program with a script. There should be no spaces at the end of any line except the prompt line. There should be a newline at the end of every line except the newline. The user, in this example enters a 5, followed by newline.

Required Files

A single tar or zip file containing ALL code needed to build this program along with the Makefile.

Submission

Submit the assignment to the D2L folder Homework 6 by the due date.