Question: I need help on this MIPS Code: #Write MIPS that searches array of words for the biggest and smallest element #the directive .word is used

I need help on this MIPS Code:

#Write MIPS that searches array of words for the biggest and smallest element

#the directive .word is used to set up an array of 20 4-byte words

#in the data section

#t1-- contains count of elements #t2-- contains min value #t3-- contains max value #t4-- each word from array in turn

.data

anArray: .word 3,4,2,6,223,345,121,92,99,14,7,76,67,49,56,43,7,81,21,31 count: .word 20 Thursday: .asciiz "TODAY IS THURSDAY FEB 09, 2017" result1: .asciiz " The minimum value is =" result2: .asciiz " The maximum value is =" bye: .asciiz " You have anice weekend and I will see you on Tuesday Feb 14 "

.text .globl main main:

la $s0, anArray li $v0,4 syscall

la $s1, count li $v0,4 syscall

la $a0, Thursday li $v0,4 syscall

la $a0, result1 li $v0,4 syscall

la $a0, result2 li $v0,4 syscall

la $a0, bye li $v0,4 syscall

search: lw $s1, 4($s2) # get &anArray lb $s2, 4($s2) # get count move $s3, $s4 addi $s4, $s4, 20 # $s4 = count + 20

Loop:

la $t0, 4 beqz anArray ($t4), $s0, result2 blt anArray ($t1), $s1, result1 addi $t1, $t1,1 # increment addi $t3, $t3, +4 # decrement loop counter li $t4, +4

j Loop

result1: move $v0, anArray($t1) syscall

result2: move $v0, anArray($t2) syscall

la $a0, bye li $v0,4 syscall

li $v0, 10 syscall

I don't know if I'm on the right way.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!