Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Convert (findlargest) procedure to be recursive? .data prompt: .asciiz Smallest number is : prompt1: .asciiz Biggest number is : prompt2: .asciiz

Convert (findlargest) procedure to be recursive?

.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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

Describe the linkages between HRM and strategy formulation. page 74

Answered: 1 week ago

Question

Identify approaches to improving retention rates.

Answered: 1 week ago