Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Show me the steps to solve . data amount _ to _ add: . word 3 array _ length: . word 8 input _ array:

Show me the steps to solve
.data
amount_to_add:
.word 3
array_length:
.word 8
input_array:
.word 3,2,8,4,6,7,0,1
output_array:
.word 0,0,0,0,0,0,0,0
.text
main:
# 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++
# 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.
# The code below prints all the elements of output_array
# $t0: number of elements remaining
# $t1: pointer into output array
la $t0, array_length
lw $t0,0($t0)
la $t1, output_array
# while ($t0!=0){
# print(*$t1)
# $t0--
# $t1++
# }
print_loop_begin:
beq $t0, $zero, print_loop_end
# print the integer
lw $a0,0($t1)
li $v0,1
syscall
# print a newline
li $a0,'
'
li $v0,11
syscall
# adjust variables
addi $t0, $t0,-1
addiu $t1, $t1,4
j print_loop_begin
print_loop_end:
# exit the program
li $v0,10
syscall

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions

Question

4. Label problematic uses of language and their remedies

Answered: 1 week ago