Question: I need help programming a function in mips that will help me create a histogram. this is my current code but I need help with
I need help programming a function in mips that will help me create a histogram. this is my current code but I need help with my output. My output is: 7,2,6
the number of unique values is:
0 0.
0 0.
0 0.
I need to count the numbers and how many times they appear.
hist:
add $t0, $zero, $zero #i = 0
add $t5, $zero, $zero #k = 0
hist_loop:
slt $t1, $t0, $a1
beq $t1, $zero, end_hist
sll $t1, $t0, 2
add $t1, $a0, $t1 #array a[i]
lw $t2, 4($t1) #array a[a + i]
beq $t1, $t2, counter
addi $t5, $t5, 1 #i++
addi $t0, $t0, 1 #k++
j hist_loop
counter:
subu $t5, $t5, 1
j hist_loop
end_hist:
move $v0, $t5 #return number of k values
jr $ra
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
