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
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