Write a program in MIPS to find the largest element of an array, the array size...

60.1K

Verified Solution

Question

Programming

  1. Write a program in MIPS to find the largest element of anarray, the array size should be less than or equal to 10.

Has to be extremely basic, cannot use stuff like move.Very basic.

Here is what I already have and I am stuck.

.datamyarray: .word 0,0,0,0,0,0,0,0,0,0invalid: .asciiz \"Number is invalid, store a number in the array that is from 0-10.\n\"large: .asciiz \"The largest element is \"colon: .asciiz \" :\t\"enter: .asciiz \"Store a value in the array \".textmain:li $v0, 4la $a0, enter #asking the user to input how many numbers they would like to entersyscallli $v0, 5syscall #user inputadd $s1, $v0, $0 #declaring v0 to s1blt $s1, $0, error #if # isn't +bgt $s1, 10, error #if # is greater than 10beq $s1, $0, error #if # is 0add $s0, $s1, $s2addi $s0, $s1, -50la $s6, myarraysw $t0, 32($s6)swap:add $t0, $a1, $0loop:beq $t0, $t1, doneaddi $s0, $s0, 4add $s2, $s2, $t5j loopdone: li $v0, 4la $a0, largesyscall#need to print biggest array here#li $v0, 10syscallerror:li $v0, 4la $a0, invalidsyscallj main

Answer & Explanation Solved by verified expert
4.4 Ratings (680 Votes)
Please upvote comment if any query i will change Besafe Note check attached image for output code compiledand tested in MARS MIPS simulatorthis program    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students