# Starter file for ex1.asm .data 0x0 magic: space 5 ... .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. # # Then simply call iterate_through_pix to process the # actual pixel data. #------------------------------------------------------------# jal iterate_through_pix end: ori $v0, $0, 10 # system call 10 for exit syscall # we are out of here. iterate_through_pix: #------------------------------------------------------------# # $a0 has rows # $a1 has cols # $a2 has ppm_max # # Write code here to implement the double-for loop of the C # program. Include appropriate stack management code. # # 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 ... ... jr $ra 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. # This is a leaf procedure, so you won't need stack here # if you don't modify any "non-temporary" register here. #------------------------------------------------------------# ... ... jr $ra