Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a mips assembly program that will have a 10 element array and output the m

ID: 3575823 • Letter: W

Question

Write a mips assembly program that will have a 10 element array and output the min and max number from the array.

Explanation / Answer

.data abc1: .asciiz " enter a positive number (negative number to exit) : " abc2: .asciiz " maximum value is : " abc3: .asciiz " minimum value is : " endl: .asciiz " " .text .globl __start __start: # execution begins here la $a0,array # $a0 will point to the elements of array lw $a1,count # exit loop when $a1 == 0 {a1 keeps count of elements} lw $a2,($a0) # initialise min = arr[0] {a2 has min} lw $a3,($a0) # initialise max = arr[0] {a3 has max} add $a0,$a0,4 # pointer points to start of arr[1] add $a1,$a1,-1 # repeat count - 1 times loop: lw $a4,($a0) # {a4 represents each word from array} bge $a4,$a2,notMin # ignore if arr[i] >= min move $a2,$a4 # copy arr[i] to min notMin: ble $a4,$a3,notMax # ignore if arr[i] 0 la $arr0,abc1 # print prompt on terminal li $v0,4 # system call to print syscall # out "min = " move $arr0,$a2 # print result min li $v0,1 syscall la $arr0,abc2 # print out "maximum value is = " li $v0,4 syscall move $arr0,$a3 # print result max li $v0,1 syscall la $arr0,endl # syscal to print out li $v0,4 # a new line syscall li $v0,10 # Exit syscall
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote