Problem 2 (60 points) Write a MIPS program (which must be named as hw4 prob2.s)
ID: 3732837 • Letter: P
Question
Problem 2 (60 points) Write a MIPS program (which must be named as hw4 prob2.s) that will 1) read in an image name (gray level image in binary format), the number of rows and the number of columns, 2) read in the image (must be implemented using a function), 3) compute its histogram (must be implemented using a function), and 4) then output the histogram (must be implemented using a function). You can use the provided program test histogram.s" on the class web site) for 1) and 2). You can assume the image size is no larger than 500x500. Then you need to test your program using three different cases and include the results in the pdf file you need to submit. You can use the three images that can be found on the class web site at http://www.cs.fsu.edu/~liux/courses/cda3100/assignments/seminoles tiny.bin, http://www.cs.fsu.edu/liux/courses/cda3100/assignments/seminoles.bin, http://www.cs.fsu.edu/-liux/courses/cda3100/assignments/lena.bin. and Additional information: The histogram of an image is widely used to characterize the image in content-based retrieval and other applications. It counts the number of occurrences of all the pixel values (0-255 in this case). The following C/C++ function computes the histogram of the input image / Here image is the starting address of image which has nrow rows and ncol columns. h is the histogram of the image int histogram (unsigned char *image. int nrow, int ncol. int xh) int i. j. k: unsigned char *p for (i:0; iExplanation / Answer
MIPS program:
Here we can wrote a mips program as shown as below.
jal print_menu
li $v0, 5
syscall
beq $v0, 1, new
beq $v0, 2, print
beq $v0, 3, quit
j do # end do
new:
jal new_user
j do
print:
jal print_user
j do
j quit
print_menu:
la $a0, menu
li $v0, 4
syscall
jr $ra
new_user:
la $a0, prompt
li $v0, 4
syscall
enter_loop:
la $t0, array
li $t1, 10
enter_loop_2:
la $a0, prompt1
li $v0, 4
syscall
li $v0, 5
syscall
sw $v0, ($t0)
addi $t1, $t1, -1
beqz $t1, end_loop_2
addi $t0, $t0, 4
j enter_loop_2
end_loop_2:
jr $ra
print_user:
la $t0, array
li $t1, 10
pLoop:
la $a0, space
li $v0, 4
syscall
asterisk_fun:
li $v0, 1
lw $a0, ($t0)
syscall
counter:
la $a0, asterisk
li $v0, 4
syscall
addi $a0, $a0, -1
beqz $a0, asterisk_end
j counter
asterisk_end:
jr $ra
addi $t1, $t1, -1
beqz $t1, endpLoop
addi $t0, $t0, 4
j pLoop
endpLoop:
jr $ra.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.