Question: write a mips program that read in 20 integers stores them in an array then calls the following funtion then print the appropriate result: minmax:

write a mips program that read in 20 integers stores them in an array then calls the following funtion then print the appropriate result:

minmax: find the smallest and the largest number in the array

divisible: show how many numbers in the array are divisible by 4

so far i have done reading the 20 integers and store them in an array, how do i do the 2 functions?

.data array: .space 80 prompt: .asciiz "Enter an integer for the array: " snumber: .asciiz "The smallest number is: " lnumber: .asciiz "The largest number is: " divide4: .asciiz "Number of integers divisible by 4: "

.globl main .text

main: li $t0 20 #initialize 20 spaces la $a1 array #load array li $t1 0 #index i = 0

loop1: la $a0 prompt #ask to enter integers li $v0, 4 #print prompt syscall

li $v0, 5 #read integers from console syscall sw $v0, 0 ($a1) #store it addi $a1 $a1 4 #increments the array addi $t1 $t1 1 #increments the index bne $t1 $t0 loop1 #check if condition is true

la $a1 array #reload the arrray li $t1 0 #counter start from 0

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!