Part B: The task is to intialize an array of size ten and add each number to the
ID: 3584958 • Letter: P
Question
Part B: The task is to intialize an array of size ten and add each number to the array. Then iterate the array and print each number out in order. This is to be done in MIPS
Homework 3 pdf Clegg Study | Guided Sc O My Pitt Home Recitation4 2181-CSO > d Secure | https://coursewebpitt.edu/bbcswebdav/pid-240601 91-dt-content-rid-22008127 2/courses/2181 UPITT CS 0447 SEC1070/Lab%204.pdf Lab 4.pdf 1/2 Array: space 40 In example t initializes an array of data with the size of 10 elements inside that array. However example 2 reserves a space in the data segment with the space directive, which means it reserves a space for a ten integer array (int = 4 bytes). To access certain location of the array, we need to figure out the address of that location. The address of the array (base array) is the location of the 0th element of the array and the address of ith element can be calculated as BaseAddress + ofer. For example, the offset of the 5th element of the array 4 * 4 16 (each element is 4 bytes long). B. Iterating the Array: Initializing an array of integers with size 10 in the data segment and adding each element to the array Iterate the array and print cach number in order. The array is arrayl: word 0,1,2,3,4,5,6,7,8,9 Save your answers as "lab4_B.asm" on courseWeb C. Adding Two Arrays using function calls: Create functions in MIPS and use these functions to add two arrays (element-by-element addition) and prints their sum. The two arrays are: Array I = 2 | 4 | 6 | 8 | 10112|14116118120 Array2 =-110111-210121-310131-4 11:48 AMM 1022017 lype here to searchExplanation / Answer
Here is the program In MIPS for intialize of an array of ten size
i.e :-
.data
arrary1: .word 0,1,2, 3,4, 5,6, 7,8,9 #Here's an array initialization of integer values
size: .word 10
. . .
lw $t3, size
la $t1, list # get array address
li $t2, 0 # set loop counter
prnlp:
beq $t2, $t3, prndn # check for array end
lw $a0, ($t1) # print list element
li $v0, 1
syscall
la $a0, NL # print a newline
li $v0, 4
syscall
addi $t2, $t2, 1 # advance loop counter
addi $t1, $t1, 4 # advance array pointer
b prnlp # repeat the loop
prndn: