Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A dd the contents of an Array and print out the total value and the current element you just read . E.g. The current element

Add the contents of an Array and print out the total value and the current element you just read. E.g. The current element is: and The total value of the array is: XX.Make sure you comment your code so I (and more so you) understand what you are doing.

For printing each element, use the jal command to jump to a section of the code for printing (dont worry about saving specific registers for the call just use any current registers for the reading the appropriate values).

Your program should be similar to the following C-code:

i=0;

while (i<>

{

sum = sum + A[i];

i++;

}

Construct the loop via slt and a conditional branch. Assume you only have 5 elements and that your array holds the following C-equivalent.

int A[] = 1, 2, 3, 4, 5;

image text in transcribed
base address of array A[] word 1, 2, 3, 4,5 esult_text: .asciiz "The final sum of array elements is:" ur ele text: .asciiz "The current element is: " ewline: byte n' # Program body text globl main main: # Add the array. eleaents. loop: print zesult: print the tat pzint current

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

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

Students also viewed these Databases questions