CMPS-2240 Lab-7
Gordon Griesel
Fall 2022

Required header:
Every program you write should have a header at the top. An example follows.


# Your Name
# Fall 2022
# 2240 lab 7 assignment
# This program displays the contents of a file. 
# Usage: spim -f lab7a.s
#        spim -f lab7a.s <filename>
#

This lab is build around the file structure of PPM images.
Read about PPM files here:
http://netpbm.sourceforge.net/doc/ppm.html

/home/fac/gordon/public_html/2240/code/lab7/lab7a.s
/home/fac/gordon/public_html/2240/code/lab7/csub3.txt
Function Calls:
Your program should have functions that do the following tasks.

main
your main function

read until whitespace
read from the file until you find a whitespace character

read until non-whitespace
read from the file until non-whitespace is found

read until newline
read from the file until a newline is found

show file descriptor
display the file handle number

atoi
the atoi function from other assignments

check for "P3" at start of file
function to check for valid file

newline
function to do a newline

Program

Write a MIPS program to read a file.
Display the following information about the file.

Sample output is here.
$ spim -f lab7a.s csub.txt 2240 lab7a.s Read an image file. File descriptor: 3 Good P3 file found. Image width: 60 Image height: 30 Maximum color value: 255



Additional output...

When you finish the program, the output will show
a rectangular area filled with characters.

After reading the "Maximum color value", read one more character.

Then do the following...

1. Read (height * width * 3) numbers from the file.

   Just like we read numbers in the lab5a.s program.
   Display all the numbers and show Gordon or Yeana.
   Do not move on until you have done this.


2. Next your will display the numbers as characters in a rectangle.

   To get the characters do this:

      Read until whitespace.
      Send the string to atoi.
      Now you have a value.
      Divide the value by 64.
      Add 32 to the value.
      Display that value as a character using syscall.
      Read 2 more numbers and throw them away. Skip them.

      Do the steps above "width" times.
      Then print a newline character.

      Do the above "height" times.

3. Show Gordon or Yeana your work.