Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Description of program in the associated file CSC303_CodingAssignment2-NeedToModify.s: This program declares an array of 7 integers in the data section. Each integer is a word
Description of program in the associated file CSC303_CodingAssignment2-NeedToModify.s: This program declares an array of 7 integers in the data section. Each integer is a word in size. A function called find42 is defined in the code which called from main. The find42 function implements a loop which goes through the array of integers looking for the specific value 42. It returns the index of the number 42 if it is found, or the value - 1 if 42 is not there in the array. Specification of what you need to do: In the associated file, the 7 integers of the array are given different values in the data section. You must first change all those values to o in the data section. Next, implement a loop within the main function that assigns 7 integer values taken as inputs from the user, to the 7 locations of the array. After that loop ends, take one more integer input from the user - this value should be the value to find (not the fixed value 42 as in the associated code file). Next call the function findN, where the function find42 should be replaced by findN. The findN function must return the index of the number N if it is found, or the value -1 if N is not there in the array. Here N is the value to search for. Make necessary changes to the file and upload solution within a file of the name CSC303_CodingAssignment2_Solution_.s Note that you must use the MARS MIPS software for this and other coding assignments. Information about how to download this software is available under the module named Links and Documents Used Through Semester. CSC303_CodingAssignment2_Need To Modify.s No Selection 1 W##############*****###################****###################******** 2 # Programmer: 3 # Course: CSC 303-01 4 ##################################################################### 5 # Functional Description: 6 # This program searches for the number 42 in an array of integers. 7 # Returns the index where 42 is found or returns -1 if not found. 8 ##############*****################################################## 9 .data 10 array: .word 10, -2, 34, 110, 42, 55, 725 11 size: .word 7 12 outstr: .asciiz "The index found is 13 .text 14 main: lw $a1, size la $ao, array jal find42 move $t0, $ve #save the returned index value in $te, la $a, outstr # load the addr of outstr into $a li $v0, 4 # 4 is the print_string syscall syscall # print the prompt move $a0, $to li $v0, 1 syscall # load the index value into $a # 4 is the print integer syscall # print the integer li $v0, 10 syscall 30 find42: addi $t0,$0, 0 # $t0 = i = @ addi $t1, $0, 42 # $t1 = 42 loop: slt $t3, $t0, $a1 # $t3 = 1 if i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started