Project #2
(Due 20 October 2005)
A file named thenumbers.txt contains a lot of positive numbers, sometimes one on a line, sometimes several on a line with one or more spaces between each two. The number of values in this file is not known; however, the file contains fewer than 30,000 bytes.
You are to write a MIPS assembly language program that reads a file such as thenumbers.txt and displays two items of information about the values in it: how many numbers there are and their sum.
Your program should prompt for the file name and then open whatever file is specified and count the numbers in it. In this way, you can create your own small file of numbers to test your program on. When you test-run the program, enter your sample data file name. When you get the program working, then run it and enter thenumbers.txt as the file name.
You can get a copy of thenumbers.txt from the I:\ drive at I:\jlwolfe\300\fall05\thenumbers.txt or from the P:\ drive at P:\courses\fall05\cosc\cosc300\001\information\thenumbers.txt or from WebCT under Class Handouts, Project #2
Hand in a printout of your well-documented
program and a printout of the program's output. You can capture the
output in the log file, paste the register section and console section
into a notepad file and print it. You can also use notepad to print
the program. Make sure the printout does NOT have lines that wrap.
It is nearly impossible to read an assembly language listing which is full
of wrapped lines.
Note: Upon first reading, this program
should seem fairly simple. However, there are two interesting small
tasks (setting up the filename for the open and reading a number) that
need to be carefully handled to make it work.