CMPS-2240 Semester Project
Gordon Griesel
Fall 2022


Write your project code in your /2240/proj folder.
Copy these files to your 2240/proj folder now.
   lab5.s
   lab5a.s
   lab7a.s
   csub3.txt


Project Phase 1 --------------- Start with your lab7a.s program. Copy it to a program named proj75.s Please copy your proj75.s to xproj75.s Then do your work in your xproj75.s Extend your xproj75.s program to do the following... 1. Read a P6 PPM file. Your program should test for a P3 and also a P6 file. If P6 is detected, call a subroutine that will process a P6 image. Name your default P6 PPM file: img75.ppm I will collect this image from your 2240/proj folder. 2. Skip any comments in the P6 file. Read the PPM file specifications. A comment begins with a '#' character. A comment ends with a newline character. Suggestion... If '#' is found at the start of your buffer, read until newline. What you do with the comment text is your decision. Display it? Discard it? 3. Read all 3 color components for each character in the color stream. Find the average of the 3 values. Use the average value to derive an ASCII character to display. 4. To derive the character to display... Divide your character value by 32. You will now have a value between 0 and 7. Use the value as an index into a string array holding some characters. See Paul Bourke's website for ideas on defining a character array. PPM file specifications <--- are there. A P6 file is very similar to a P3 file. The file header is the same, the image data is different. Once you get to the image data, there is no whitespace! Each pixel's color is stored in three consecutive bytes. Each byte will hold a value between 0 and the max-color that you read. The color section of a P6 file is much smaller than a P3 file, so the image can be read much faster than a P3. Also, the file requires less memory for storage. How to create a P6 PPM file for testing? 1. Find one on the internet. 2. Make one from a jpg or png image. from the command-line: convert my_image.jpg my_image.ppm We will review these requirements in class.
Project Phase 2 --------------- Start with your xproj75.s. Copy it to xproj85.s The program will read a P6 file. Read the image portion of the file with one file read command. Using syscall. How to do it... Setup a large memory buffer in your .data section. Make it large enough to store the largest file that you might want to read and display. After performing the read, display the image by stepping through the memory buffer holding the image colors.
Project Phase 3 --------------- Start with your xproj85.s. Copy it to xproj95.s Remove the data buffer you defined in .data section. Use syscall 9 to allocate just the exact amount of memory needed to read the image colors. Use the image dimensions for this. The call will return you an address of a buffer. The buffer will reside in the "heap" memory rather than in your program's .data section. It will work the same way as a buffer. Give it a try.