Question: Can i get help with this in MIPs assembly language. In this subprogram you will be working with a simple map data structure, which consisting
Can i get help with this in MIPs assembly language. In this subprogram you will be working with a simple map data structure, which consisting of double precision floating point number as key and integer as value (in this order). Further, we will call the double precision variable of the structure as value and integer variable as count.
This program will dynamically allocate an array of data structures and ask user to fill it out. It will then print the data structure into console and do following operations:
Iterate the array and calculate the sum and average of the data structure. Please notice that the total value of each element is (value*count) and the average of the array is (total sumtotal count).
Iterate the array and find minimum value and maximum value of the array. Again, please notice the total value of each element is (value*count).
Finally, main should print out the sum, average, minimum and maximum value.
To write this program, you will need a main associate with five subprograms. We provide a program structure design for you:
main:
allocate_structure:
read_structure:
print_structure:
sum_average:
get_min_max:
Subprograms:
allocate_structure:
This subprogram has No Argument IN and Two Arguments OUT:
$sp+0 array base address (OUT)
$sp+4 array size (OUT)
It will prompt user for an array size and dynamically allocate an array of data structures, then return array base address and array size to main.
read_structure:
This subprogram has Two Arguments IN and No Argument OUT:
$sp+0 array base address (IN)
$sp+4 array size (IN)
It will iterate through the array and read each element from user input. Please notice that each element should be a [key, value] pair with a double number as key and integer as value
print_structure:
This subprogram has Two Arguments IN and No Argument OUT:
$sp+0 array base address (IN)
$sp+4 array size (IN)
It will iterate the array and print the content of each element. Again, each element should be in [key, value] pair.
sum_average:
This subprogram has Two Arguments IN and Two arguments OUT:
$sp+0 array base address (IN)
$sp+4 array size (IN)
$sp+8 sum of calculated sums in data structure array (OUT)
$sp+16 average of calculated sums in data structure array (OUT)
It will iterate the array and calculate the sum and average of the array. Please notice that the total value of each element is (value*count) and the average of the array is ((total sum)/(total count)).
get_min_max:
This subprogram has Two Arguments IN and Two arguments OUT:
$sp+0 array base address (IN)
$sp+4 array size (IN)
$sp+8 minimum value of array (OUT)
$sp+16 maximum value of array (OUT)
Iterate the array and find minimum value and maximum value of the array. Again, please notice the total value of each element is (value*count).
###########################################################
# Program Description
###########################################################
# Register Usage
# $t0
# $t1
# $t2
# $t3
# $t4
# $t5
# $t6
# $t7
# $t8
# $t9
###########################################################
.data
###########################################################
.text
main:
li $v0, 10 #End Program
syscall
###########################################################
###########################################################
# Subprogram Description
###########################################################
# Arguments In and Out of subprogram
#
# $a0
# $a1
# $a2
# $a3
# $v0
# $v1
# $sp
# $sp+4
# $sp+8
# $sp+12
###########################################################
# Register Usage
# $t0
# $t1
# $t2
# $t3
# $t4
# $t5
# $t6
# $t7
# $t8
# $t9
###########################################################
.data
###########################################################
.text
jr $ra #return to calling location
###########################################################
###########################################################
# Subprogram Description
###########################################################
# Arguments In and Out of subprogram
#
# $a0
# $a1
# $a2
# $a3
# $v0
# $v1
# $sp
# $sp+4
# $sp+8
# $sp+12
###########################################################
# Register Usage
# $t0
# $t1
# $t2
# $t3
# $t4
# $t5
# $t6
# $t7
# $t8
# $t9
###########################################################
.data
###########################################################
.text
jr $ra #return to calling location
###########################################################
###########################################################
# Subprogram Description
###########################################################
# Arguments In and Out of subprogram
#
# $a0
# $a1
# $a2
# $a3
# $v0
# $v1
# $sp
# $sp+4
# $sp+8
# $sp+12
###########################################################
# Register Usage
# $t0
# $t1
# $t2
# $t3
# $t4
# $t5
# $t6
# $t7
# $t8
# $t9
###########################################################
.data
###########################################################
.text
jr $ra #return to calling location
###########################################################
###########################################################
# Subprogram Description
###########################################################
# Arguments In and Out of subprogram
#
# $a0
# $a1
# $a2
# $a3
# $v0
# $v1
# $sp
# $sp+4
# $sp+8
# $sp+12
###########################################################
# Register Usage
# $t0
# $t1
# $t2
# $t3
# $t4
# $t5
# $t6
# $t7
# $t8
# $t9
###########################################################
.data
###########################################################
.text
jr $ra #return to calling location
###########################################################
###########################################################
# Subprogram Description
###########################################################
# Arguments In and Out of subprogram
#
# $a0
# $a1
# $a2
# $a3
# $v0
# $v1
# $sp
# $sp+4
# $sp+8
# $sp+12
###########################################################
# Register Usage
# $t0
# $t1
# $t2
# $t3
# $t4
# $t5
# $t6
# $t7
# $t8
# $t9
###########################################################
.data
###########################################################
.text
jr $ra #return to calling location
###########################################################
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
