write MIPS assembly code which, when run under QtSpim, will do the following: 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] = input_array[index] + amount_to_add; } 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: 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 .words. The values of input_array will all be non-negative. amount_to_add will always be an unsigned integer.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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

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] = input_array[index] + amount_to_add;

}

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:

  • 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 .words.
  • 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:
main:
.word 3
. word 8
input_array:
output_array:
.word 3, 2, 8, 4, 6, 7, 0, 1
.word 0, 0, 0, 0, 0, 0,
0, 0
.text
# num_remaining = array_length
# input pointer = input_array
# output_pointer = output_array
# while (num_remaining != 0) {
# *output_pointer = *input_pointer + amount_to_add
# input_pointer++
# output_pointer++
add_amount.asm
# num_remaining--
# }
# 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: main: .word 3 . word 8 input_array: output_array: .word 3, 2, 8, 4, 6, 7, 0, 1 .word 0, 0, 0, 0, 0, 0, 0, 0 .text # num_remaining = array_length # input pointer = input_array # output_pointer = output_array # while (num_remaining != 0) { # *output_pointer = *input_pointer + amount_to_add # input_pointer++ # output_pointer++ add_amount.asm # num_remaining-- # } # 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 4 steps with 2 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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education