Question: Write MIPS assembly language code, that initializes every element of the array to a random number. I use an ide called MARS. Choose a register
Write MIPS assembly language code, that initializes every element of the array to a random number. I use an ide called MARS.
Choose a register to use as the loop index counter
Initialize the loop counter to a value of 16.
Put the address of arrayA into a register, using the la instruction.
Create a random number using a syscall (Note: please read the documents about syscall and use code 42 instead of code 41).
Use sw instructions to store the random number at the present array location.
Increment the base address in the register that originally contained the address of arrayA, for use during the next iteration of the loop
Increment the loop counter value
o Then: write a procedure named as sum to calculate the sum of an array. This procedure has two parameters, which are the array and the number of elements in this array (Note pass by using $a0 and $a1, return the results by $v0, then in the caller to print the result).
jal sum to calculate the sum of array, and then return the result of sum to the main program. Then Print out your results by syscalls.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
