Please write in MIPS assembly code which, when run under QtSpim, will do the following:

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question

Please write in MIPS assembly code which, when run under QtSpim, will do the following:

Step 3: Edit add_amount.asm
Now move to add_amount.asm. This program works with two arrays of the same length: an input array, and an output array. Additionally, it contains a value to add to each element of the array (amount_to_add). For
each element of the input array, it should add this amount, putting the result in the output array. A code snippet below illustrates this behavior:
for (int index = 0; index < array_length; index++) {
output_array[index]
=
}
The end of the code (provided) will print each element of the output array. As with the prior problem, this code MUST work for any values of amount_to_add, array_length, input_array, and output_array. You
may make the following assumptions in your code:
input_array [index] + amount_to_add;
●
array_length will always be at least 1, and will be an unsigned integer
input_array and output_array will always contain exactly array_length .word s.
• The values of input_array will all be non-negative.
amount_to_add will always be an unsigned integer.
●
Transcribed Image Text:Step 3: Edit add_amount.asm Now move to add_amount.asm. This program works with two arrays of the same length: an input array, and an output array. Additionally, it contains a value to add to each element of the array (amount_to_add). For each element of the input array, it should add this amount, putting the result in the output array. A code snippet below illustrates this behavior: for (int index = 0; index < array_length; index++) { output_array[index] = } The end of the code (provided) will print each element of the output array. As with the prior problem, this code MUST work for any values of amount_to_add, array_length, input_array, and output_array. You may make the following assumptions in your code: input_array [index] + amount_to_add; ● array_length will always be at least 1, and will be an unsigned integer input_array and output_array will always contain exactly array_length .word s. • The values of input_array will all be non-negative. amount_to_add will always be an unsigned integer. ●
.data
amount_to_add:
array_length:
.word 3
. word 8
input_array:
main:
. word 3, 2, 8, 4, 6, 7, 0, 1
output_array:
.word 0, 0, 0, 0, 0, 0,
.text
# num_remaining = array_length
# input pointer = input_array
0, 0
# input_pointer++
# output_pointer++
# output_pointer = output_array
# while (num_remaining != 0) {
# *output_pointer = *input_pointer + amount_to_add
# num_remaining--
# }
add_amount.asm
# TODO: add your code below.
# This should take each input_array element, add amount_to_add,
# and store the result in the corresponding output_array element.
# The elements in input_array should never change. You can
# implement this however you'd like, though it's recommended to
# follow the above pseudocode.
Transcribed Image Text:.data amount_to_add: array_length: .word 3 . word 8 input_array: main: . word 3, 2, 8, 4, 6, 7, 0, 1 output_array: .word 0, 0, 0, 0, 0, 0, .text # num_remaining = array_length # input pointer = input_array 0, 0 # input_pointer++ # output_pointer++ # output_pointer = output_array # while (num_remaining != 0) { # *output_pointer = *input_pointer + amount_to_add # num_remaining-- # } add_amount.asm # TODO: add your code below. # This should take each input_array element, add amount_to_add, # and store the result in the corresponding output_array element. # The elements in input_array should never change. You can # implement this however you'd like, though it's recommended to # follow the above pseudocode.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Fundamentals of Computer System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage