Question

write a MIPS program that does the following Create an array of 10 INTEGERS.  Create procedures to...

write a MIPS program that does the following

Create an array of 10 INTEGERS.  Create procedures to find the largest, and find the smallest. Create another procedure called range, which is the difference between largest and smallest (range should call findLargest and findSmallest)

Convert your find largest procedure to be recursive

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER:

Please find the code below:::

.data
prompt: .asciiz " Smallest number is : "
prompt1: .asciiz " Biggest number is : "
prompt2: .asciiz " Range of number is : "
array : .word 10,-5,-30,15,20,-1,-26,-18,64
.text
.globl main
main :

j range #only call to function from main


range:
la $s7,array #store array index
li $s1,0 #store index to pass to array
li $s0,10 #size of array
lw $s2,array
jal findLargest
move $t7,$s2 #get largest


li $s1,0 #store index to pass to array
li $s0,10 #size of array
lw $s2,array
jal findSmallest
move $t6,$s2 #get largest


li $v0,4
la $a0,prompt1 #it will print prompt
syscall
li $v0,1
move $a0,$t7 #print number of items
syscall

li $v0,4
la $a0,prompt #it will print prompt
syscall
li $v0,1
move $a0,$t6 #print number of items
syscall


li $v0,4
la $a0,prompt2 #it will print prompt
syscall
li $v0,1
sub $a0,$t7,$t6 #print number of items
syscall


li $v0,10
syscall


findLargest:
subu $sp,$sp,4 # point to the place for the new item,
sw $ra,($sp) # store the contents of $ra as the new top.
blt $s1,$s0,else
j skipCall
else:
mul $t0,$s1,4 #get integer index
add $t0,$t0,$s7
lw $t0,($t0)
ble $t0,$s2,skipAssignBig
move $s2,$t0
skipAssignBig:
add $s1,$s1,1
jal findLargest
skipCall:
lw $ra,($sp) # store the contents of $ra as the new top.
addu $sp,$sp,4 # point to the place for the new item,
move $v1,$s4
jr $ra


findSmallest:
subu $sp,$sp,4 # point to the place for the new item,
sw $ra,($sp) # store the contents of $ra as the new top.
blt $s1,$s0,else2
j skipCall2
else2:
mul $t0,$s1,4 #get integer index
add $t0,$t0,$s7
lw $t0,($t0)
bge $t0,$s2,skipAssignSmall
move $s2,$t0
skipAssignSmall:
add $s1,$s1,1
jal findSmallest
skipCall2:
lw $ra,($sp) # store the contents of $ra as the new top.
addu $sp,$sp,4 # point to the place for the new item,
move $v1,$s4
jr $ra

output:

Add a comment
Know the answer?
Add Answer to:
write a MIPS program that does the following Create an array of 10 INTEGERS.  Create procedures to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In MIPS Create array of 11 float numbers, Call the procedures findLargestFloat, findSmallestFloat, and rangeFloat. Range...

    In MIPS Create array of 11 float numbers, Call the procedures findLargestFloat, findSmallestFloat, and rangeFloat. Range float is the difference between largest float and smallest float. Also, Create a recursive procedure to find the largest (call it findLargestRecursive), to find largest float in array

  • I need help with this MIPS program. Write a program that makes an array of integers...

    I need help with this MIPS program. Write a program that makes an array of integers called array in the .data section. It should print the number of zeroes in that array. You should also have a variable called array_size in the .data section which is set to the number of elements in your array. Let's say you name your program count_zeroes.s. To submit your program, you must upload it to hills and run the following command (assuming you are...

  • Please write a Java program that does the following: Create an array of 100 integers. Store...

    Please write a Java program that does the following: Create an array of 100 integers. Store 100 random integers (between 1 and 100) in the array. Print out the elements of the array. Sort the array in ascending order. Print out the sorted array. Prompt the user to enter a number between 1 and 100. Search the array for that number and then display "Found" or "Not Found" message. Display each number from 1 to 100 and the number of...

  • Write a MIPS program that reads (with an appropriate prompt) a sequence of 20 integers and...

    Write a MIPS program that reads (with an appropriate prompt) a sequence of 20 integers and stores them in an array, and then calls the following two functions and prints the results in a readable format. The two functions are: smallestLargest: computes the smallest and the largest values in the array. oddEven: computes the number of even integers and the number of odd integers.

  • 2. Write the statements to do the following tasks. • Create an array of 10 integers...

    2. Write the statements to do the following tasks. • Create an array of 10 integers and initialize the array by 10 user's input from the console window, assume the Scanner class has been imported to your program and a Scanner object input has been created. Scanner input = new Scanner(System.in); • Find the smallest number in the array . Find the number of times (occurrence) that the smallest number appears in the We were unable to transcribe this image

  • Assembly Language////Write a program that read in 10 integers from the user. Save the numbers into...

    Assembly Language////Write a program that read in 10 integers from the user. Save the numbers into an array; reverse the array and display the reversed array. .data arrayInt DWORD 10 DUP(?) Your program consists of 4 procedures: 1. main procedure: call procedures getInput, reverseArray, displayArray 2. getInput procedure: prompt user to enter 10 integer numbers, save the numbers into the memory for the arrayInt 3. reverseArray: reverse arrayInt 4. displayArray: display the reversed array

  • Write a C program that uses the random number generator rand( ) to create an array...

    Write a C program that uses the random number generator rand( ) to create an array with 20 numbers with value in the range from 1 to 100. The program calculates and displays the difference between the largest array element and the second largest array element in the array.

  • Write a C++ program that does the following : 1. Accepts array size from the keyboard....

    Write a C++ program that does the following : 1. Accepts array size from the keyboard. The size must be positive integer that is >= 5 and <= 15 inclusive . 2. Use the size from step 1 in order to create an integer array. Populate the created array with random integer values between 10 and 200. 3. Display the generated array. 4. Write a recursive function that displays the array in reverse order . 5. Write a recursive function...

  • Write a C++ program that will create an array with a given number of elements. Use...

    Write a C++ program that will create an array with a given number of elements. Use size = 10 for demonstration purposes, but write the program where the size of the array can be changed by changing the value of one constant. Fill the array with random numbers between 0 and 100. Write the program to perform the following operations: 1. Find and display the largest value in the array. 2. Find and display the smallest value in the array....

  • Write a Java program that allows the following: 1.Create an array list of 20 integers. The...

    Write a Java program that allows the following: 1.Create an array list of 20 integers. The 20 integers are generated randomly with possible values from 0 to 10. 2.Print the content of the array list. 3.Find how many of these values are multiple of 3. Show a screenshot of the output with your name and Id in the first line (if there is no screenshot of the output, the student shall get a zero mark for this question). Program typical...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT