Question
Writting MIPS Assembly code Assume that a list A (array A) of integer numbers (each integer is 4-bytes) have been stored in memory (in consecutive
Writting MIPS Assembly code
Assume that a list A (array A) of integer numbers (each integer is 4-bytes) have been stored in
memory (in consecutive memory locations). MIPS register $s0 holds the base address of this
list and register $s1 stores the size of the array. Please write a MIPS assembly code that finds
the difference of farthest pair (difference between maximum and minimum elements in the
list) of the list.
In your MIPS code, hold the value of the difference of farthest pair (max-min) in register $s2.
Hold the values of maximum and minimum elements of the list in register $t0 and $t1,
respectively.
Note: For this question, start with the code (answer2.asm) that has been provided to you with
the assignment. This code defines a list, stores the base address of the list to the register $s0
and the size of the list to the register $s1. The values of list A in this code are given as
examples. Your code should work for any list of integers. If the size of the list is changed, the
value of $s1 needs to be updated manually.
answer2.asm:
#A list is defined here
.data
my_array: .word 10, 9, 2, 3, 1, 4, 6, 7, 32
.text
la $s0, my_array # based address of list loaded into $s0
addi $s1, $zero, 9 # $s1 is set to the size of the list. If you change the size of my_array, change this number accordingly
# Now you have the size and the base address of the list
# You should be able to find the difference between maximum and minimum elements in the list.
# Continue to write your code here
Step by Step Solution
3.43 Rating (153 Votes )
There are 3 Steps involved in it
Step: 1
Size word 10 Size is 10 myarray word 38 3 71 16 12 4 8 1 18 83 myarray 10 12 Article Important la ...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