Question 1.
This assignment needs at computing the function (where n! is the factorial of n) for several n values.
Write an assembly program that computes f(1), f(2), f(3),..., and f(10). Note that n! is defined as follows: or . Also, note that 1! = 0! = 1.
Here are the requirements of your program:
- Use the minimum amount of instructions.
- Use the minimum amount of variables.
- Only instructions described in Chapter 4 of your textbook are allowed.
For example, no multiplication instructions are allowed.
- Use extensive comments to describe your program.
- You can use the Irvine32 library procedure DumpRegs to display the contents of the registers.
Produce an executable version of your program and make sure that it runs correctly.
HINT: To compute 5!, you can use the subsequent algorithm:
1. Compute 4!
2. Add 4! five times and you get: 4! + 4! + 4! + 4! + 4! = 5 x 4! = 5! 2.
The above program can be solved with approximately 20 instructions and no data variables. So, do not use excessive number of data variables or instructions.