# Starter file for ex1.asm .data 0x0 magic: space 5 # more than enough space to read in "P3\n" plus null ... .text 0x3000 main: ... ... #------------------------------------------------------------# # Write code here to do exactly what main does in the C program. # That is, read and write the magic numbers, # read and write the number of cols and rows, # and read and write the ppm_max values. The output's # magic number will be "P2". And, regardless of the input's # ppm_max, the output will always have 255 as its ppm_max. #------------------------------------------------------------# #------------------------------------------------------------# # Write code here to implement the double-for loop of the C # program, to iterate through all the pixels in the image. # # The actual conversion from RGB to gray value of a single # pixel must be done by a separate procedure called rgb_to_gray #------------------------------------------------------------# ... ... jal rgb_to_gray ... ... end: ori $v0, $0, 10 # system call 10 for exit syscall # exit rgb_to_gray: #------------------------------------------------------------# # $a0 has r # $a1 has g # $a2 has b # $a3 has ppm_max # # Write code to compute gray value in $v0 and return. #------------------------------------------------------------# ... ... jr $ra