Question: Answer in MIPS ##################################################################### ## PROBLEM 3 ## ## Given a zero-terminated list of 4 byte integers ranging from 1-100 ## (inclusive), count the number

Answer in MIPS

#####################################################################

## PROBLEM 3

##

## Given a zero-terminated list of 4 byte integers ranging from 1-100

## (inclusive), count the number of elements in the list.

## - The terminating zero should not be included in the count.

## - If a value outside of legal range (1 >= x <= 100) is found

## indicate an error by returning -1.

## - Function takes one argument, a pointer to the start of the list

#####################################################################

length:

##Your Code Here

########################################

## TEST PROBLEM 3 ## Do Not Modify

########################################

li $a0, 3

jal print_problem_header

la $a0, vec1

jal length # length = 3

move $a0, $v0

jal print_int

jal print_space

la $a0, vec2

jal length # length = -1

move $a0, $v0

jal print_int

jal print_space

la $a0, vec3

jal length # length = -1

move $a0, $v0

jal print_int

jal print_space

la $a0, vec4

jal length # length = 0

move $a0, $v0

jal print_int

jal print_newline

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!