CS301 – Fall 2003

Prof. Hartman

Homework #6

Due Wednesday, November 5th by 4:45 pm


  1. Write a complete assembly language program which asks the user for a number n, and calculates and prints n! (n!, or n factorial, is 1 * 2 * 3 * … * n). (Your program does not have to be recursive.) What is the largest value of n for which n! is correctly calculated by your program?
  2. Modify the program from the previous part to compute n! using single precision floating point numbers.
    • Now what is the largest value of n for which n! is computed exactly?
    • What is the largest value for which the value of n! is approximately correct?
  3. Assume xmem is a memory location containing a double precision floating point number x. Write an assembly language code fragment to calculate x^3/13.0 – x. [That’s “x cubed divided by 13.0 minus x” .] (You aren’t required to assemble and run this code, but it might be a good idea to make sure you’ve done it correctly.)